Commit Graph

660 Commits

Author SHA1 Message Date
Simon Hausmann d4239d2bf9 Fix maximum call stack depth for clang ASAN builds
For clang we need to use has_feature to detect the presence of an ASAN
build. Amends commit eb363c3a0b

Task-number: QTBUG-75410
Change-Id: I2adb69deb07f8c6b77be8c2f23751fd0a2bbdb95
Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
2019-04-29 09:43:58 +00:00
Ulf Hermann 9e5ca92712 Remove tracing JIT infrastructure
The tracing JIT won't be finished. Therefore, remove the parts that have
already been integrated.

Change-Id: If72036be904bd7fc17ba9bcba0a317f8ed6cb30d
Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
2019-04-29 09:16:34 +00:00
Qt Forward Merge Bot 23f988fe48 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/compiler/qv4compilercontext.cpp
	src/qml/qml/qqmlmetatype.cpp

Change-Id: I02e0216961b92ff68a3f91a70edc33fe9e8db147
2019-04-29 09:12:31 +02:00
Qt Forward Merge Bot 332e514fb4 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I552629813ea8100d04ea19e51fe7198931082e19
2019-04-27 01:00:40 +02:00
Simon Hausmann eb363c3a0b Fix maximum call stack depth limits for ASAN builds
ASAN enabled builds require more stack space and therefore our call
depth limits should be lower.

In my measurements with a recursion through arrow functions with the
interpreter, as per the test case in the bug report, different types of
builds require different amounts of stack space. On x86-64 Linux, I
measured, by printing $rsp and subtracting:

    Debug: ~6k
    Debug with -Og: ~590 bytes
    Release with -O2: ~570 bytes
    Release (-O2) with ASAN: ~40k

Fixes: QTBUG-75410
Change-Id: I403b261c677b1adb9f349958339b5a1294ae4d5d
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-04-26 13:36:22 +00:00
Ulf Hermann 561a2cec9b Transform V4_ENABLE_JIT into a feature
This way you can enable or disable the JIT when configuring Qt. The
conditions for the availability of the JIT have also been cleaned up.
There is no reason anymore to artificially restrict availability on x86
and x86_64. The reason for the existence of those clauses are old
problems on windows that have been fixed by now. However, on arm and
arm64, we need a specialization of the cacheFlush() function for each OS
to be supported. Therefore, restrict to the systems for which such a
specialization exists. iOS and tvOS are technically supported and you
can enable the JIT via the feature flag now. Due to Apple's policy we
disable it by default, though.

Change-Id: I5fe2a2bf6799b2d11b7ae7c7a85962bcbf44f919
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-25 11:07:36 +00:00
Qt Forward Merge Bot 934f25028a Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/qml/qqmlimport.cpp

Change-Id: I6add6267297ea50a646d43d212027a168dca8916
2019-04-18 08:01:45 +02:00
Ulf Hermann 68b7a66a6e Don't use UINT_MAX as invalid array index in PropertyKey
Technically UINT_MAX is actually a valid array index, although that is
an academic problem right now. However, we do have a method
isArrayIndex() and should just use that to determine if a PropertyKey is
an array index.

Fixes: QTBUG-73893
Change-Id: I302e7894331ed2ab4717f7d8d6cc7d8974dabb4e
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2019-04-16 08:06:26 +00:00
Qt Forward Merge Bot 8bc3329e2c Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/3rdparty/masm/assembler/LinkBuffer.h
	src/qmltest/doc/src/qtquicktest-index.qdoc
	tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp

Change-Id: I7d83ad95cf489dda794dd7a0a33bad3ef3b05609
2019-04-15 09:36:12 +02:00
Ulf Hermann 0af154c41d Don't create value types for QImage and QPixmap
Those are "scarce" resources which need to be kept as QVariant.

Fixes: QTBUG-74751
Change-Id: I28381e2a754ed4bbf4e409dc275f6288b64416cc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-12 12:13:54 +00:00
Friedemann Kleint 34c98070d1 Fix deprecation warnings about QVariant API
Fix warnings like:
sruntime/qv4serialize.cpp:378:45: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlListModelWorkerAgent::VariantRef]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qml/qqmlvmemetaobject.cpp:597:61: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1319:66: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1350:60: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8396:78: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8693:80: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:126:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:127:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:713:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:714:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qquickcustomparticle.cpp:416:89: warning: 'QVariant qVariantFromValue(const T&) [with T = double]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qqmlenginedebugclient.cpp:403:47: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlEngineDebugObjectReference]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]

Task-number: QTBUG-74043
Change-Id: I14cb7d7c1fb8dc6321e32208a7de15f6bdb19065
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-04-08 08:44:15 +00:00
hjk 2895402cf6 Add another helper function for stack extraction
This makes the use of the feature easier and lowers the dependency
on setup of internal structures.

Also, evaluation of expressions is notoriously expensive and unreliable
on the gdb side, so moving the complexity to the compiled side is
an advantage.

Task-number:  QTCREATORBUG-22209
Change-Id: Id43d5c2bf4d852d496ceb59189209d167213afcb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-04-08 08:28:20 +00:00
Qt Forward Merge Bot f385f6b39f Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I9ba374f0c652628b7c84c36893c32b22529e384f
2019-03-29 01:00:40 +01:00
Qt Forward Merge Bot 4407f1f818 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I910618824785f9119b1e1da9a82e998fd645a96f
2019-03-28 01:00:54 +01:00
Ulf Hermann b6d0ed435d Scope intermediate values when allocating objects
Otherwise the garbage collector might interfere and we might end up
with dangling pointers in random places.

Task-number: QTBUG-74190
Change-Id: I253c526ef930b8f0be14e96a42af8b66fda3b22d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-03-27 09:23:03 +00:00
Ulf Hermann a768780f36 Merge remote-tracking branch 'origin/5.13' into HEAD
Conflicts:
	src/qml/compiler/qv4compileddata_p.h
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jit/qv4jithelpers.cpp
	src/qml/jsruntime/qv4lookup.cpp
	src/qml/jsruntime/qv4runtime.cpp
	src/qml/jsruntime/qv4runtimeapi_p.h
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/qml/qqmltypemodule_p.h

Change-Id: If28793e9e08418457a11fc2c5832f03cab2fcc76
2019-03-22 14:57:04 +01:00
Qt Forward Merge Bot 7a349710cc Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qv4bytecodehandler.cpp
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/compiler/qv4compiler.cpp
	src/qml/compiler/qv4instr_moth.cpp
	src/qml/compiler/qv4instr_moth_p.h
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jit/qv4baselinejit_p.h
	src/qml/jsruntime/qv4function.cpp
	src/qml/jsruntime/qv4vme_moth.cpp

Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
2019-03-21 10:59:45 +01:00
Robin Burchell 8704c64094 QV4Engine: Unify fromValue and metaTypeToJS
Somehow, we ended up with two codepaths doing essentially the same
thing: constructing a JS value from a QVariant. metaTypeToJS is invoked
from QJSEngine::toScriptValue, whereas fromVariant() is used in various
places internally.

metaTypeToJS lacks proper handling for a number of cases, such as
builtin types like QPointF, which lead to toScriptValue(QPointF)
(incorrectly, and uselessly) constructing a VariantObject which couldn't
then do anything useful.

[ChangeLog][QtQml] QJSEngine::toScriptValue will now return correct
JavaScript objects in more cases, for example, for gadget types like
QPointF.

[ChangeLog][QtQml] QJSEngine::toScriptValue now uses the same
behavior as the rest of the engine when building JavaScript values, which
will cause the types of some returned JavaScript objects to change. For
instance, string lists are now returned as sequence objects, not array
objects, and QChar now constructs a JavaScript string.

Change-Id: I0290eb7c9c46e7b508d497cc33cd61d9378f3872
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-03-21 03:08:27 +00:00
Simon Hausmann c9e6251cc8 Implement dummy QML lookups for "global" variables
When resolving names in the context of QML bindings, we now direct
runtime access to QQmlContextWrapper::resolveQmlPropertyLookupGetter. At the
moment this does basically the same as Runtime::method_loadName, which
we called earlier. However this now provides the opportunity to optimize
lookups in the QML context in a central place.

When performing a call on a scope or context object property, we also
did not use a CallName() instruction - which would have gotten the
thisObject wrong - but instead we use a dedicated
CallScopeObjectProperty and CallContextObjectProperty instruction. These
rely on identifying these properties at compile time, which goes away
with lookups (and also doesn't work when using ahead-of-time
compilation). Therefore the qml context property lookup is using a
getPropertyAndBase style signature and
Runtime::method_callQmlContextPropertyLookup uses that.

For the tests to pass, some error expectations need adjusting. In
particular the compile-time detection of write attempts to id objects is
now delayed to the run-time.

The old code path is still there and will be removed separately in the
next commit (as it is massive).

Task-number: QTBUG-69898
Change-Id: Iad1ff93d3758c4db984a7c2d003beee21ed2275c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-20 09:16:02 +00:00
Ulf Hermann d2fd8010d3 Support QRegularExpression on the same level as QRegExp
QRegularExpression is the recommended way to do regular expressions
nowadays. Support assignment of JavaScript regular expressions to
QRegularExpression properties of QObjects and the other way around.
QJSValue::toVariant() will create a QRegularExpression from a JavaScript
RegExp by default now.

[ChangeLog][QtQml][Important Behavior Changes] QRegularExpression is now
supported the same way QRegExp is in QML. QJSValue::toVariant() creates
a QRegularExpression variant rather than a QRegExp one from a JavaScript
regular expression now.

Fixes: QTBUG-73429
Change-Id: I301a02771cd17903406c2bc5c7aaeca6cce629f0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-20 08:05:04 +00:00
Erik Verbruggen 784a55a15d V4: Collect trace information in the interpreter
Collect type information about values used in a function. These include
all parameters, and the results of many bytecode instructions. For array
loads/stores, it also tracks if the access is in-bounds of a
SimpleArrayData.

Collection is only enabled when the qml-tracing feature is turned on
while configuring.

In subsequent patches this is used to generated optimized JITted code.

Change-Id: I63985c334c3fdc55fca7fb4addfe3e535989aac5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-01-25 10:26:13 +00:00
Liang Qi 1b4d2741f9 Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	.qmake.conf
	tests/auto/quick/qquickpathview/tst_qquickpathview.cpp

Change-Id: Ic1f5e219a255d0613f7654368a5ce3eccb8f0ee9
2019-01-22 11:20:29 +01:00
Erik Verbruggen 8fd3cfe7d0 Annotate stack traces when frames are elided through tail calls
Task-number: QTBUG-72407
Change-Id: I98b96852309fc783a945797185f666196513d24b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-01-15 17:35:46 +00:00
Qt Forward Merge Bot 24dfffe33b Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ic5a0c02ab45aac18c218dbeb8cd4b4cd3b609eb6
2018-11-17 01:01:00 +01:00
Qt Forward Merge Bot 8a9a907fc9 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I85be5e6ef173fa733d7febd3209164bb31762e0d
2018-11-06 01:00:09 +01:00
Lars Knoll 6746417e71 Don't crash when compiling with QT_FORCE_ASSERTS enabled
Change-Id: I9af3dc69cc5baf1c35e836345590baf5b55b1bed
Fixes: QTBUG-70937
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-11-02 13:29:23 +00:00
Allan Sandfeld Jensen 7f0db6d047 Add convenience functions for creating and inspecting error objects
Serves to simplify porting from QtScript by replacing
QScriptContext::Error and QScriptContext::throwError().

Change-Id: I4bfe404c358c50aaf3b5469a4304fec97552bf24
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-10-30 12:41:54 +00:00
Qt Forward Merge Bot 8092a4e247 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I0ad1a3aa3a211ef86c4baf605361de860266dde1
2018-10-12 01:00:07 +02:00
Valery Kotov f47c87e75f QML Engine: Support for JavaScript Promises
Support for JavaScript Promises.

Change-Id: I90ce328b35f3bdf3fd666a8829f22b5d56b6f861
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-10-11 08:27:48 +00:00
Jędrzej Nowacki 01ed625542 Teach QML that it is possible to treat custom QObjects as QObject
It is always better to treat a QObject child as QObject then a QVariant.

Change-Id: I4ac069e85232dd4d1411e325bc5b858bd001f9a6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-10-08 10:02:04 +00:00
Jędrzej Nowacki 5f4b3fa3ca Add support for QSequentialIterable in QML
That means that now QML understand many sequential value types
and it is able to convert it to a JS array.

Fixes: QTBUG-60338
Change-Id: I46943b7c130296bb64c23008ce2e52a55d7f019d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-10-08 10:01:54 +00:00
Lars Knoll 20a434faa8 Speed up instanceof operations
Introduce a shortcut if the rhs is a functionobject with the
regular function proto as prototype.

Add an optimized instanceOf implementation when we already have some
checks done, and inline some methods.

Change-Id: Iab9b648ae7bbec749b319e883b6ae90a23875454
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-09-27 08:34:14 +00:00
Lars Knoll 7c59262503 Unify layout of function objects
Ensure we have the proto property at always the same place.
This will be used in a subsequent commit to optimize accesses
to the prototype property e.g. when doing instanceof
operations or constructor calls.

Change-Id: I6e9a19e0b7d0e8ab583648a60d1978f5cf838b06
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-09-27 08:34:10 +00:00
Lars Knoll 7cc66a996e Get rid of remaining assumptions about setter being next to getters
The only place where we now assume that getters and setters are
next to each other in the MemberData is in the internal class.

Change-Id: I3285f3abb1cbfe051853e808339cd360eb602262
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-09-27 08:33:59 +00:00
Lars Knoll 1804fea889 Refactor InternalClass::find()
Specialize find() into several methods for different purposes.
Prepares for further cleanups and being able to split up
getter and setter for accessor properties.

Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-09-27 08:33:52 +00:00
Lars Knoll a97d118bf5 Better inheritance structure for functions
Give Arrow functions their own representation. This also prepares
for further optimizations especially for the instanceof operator.

Change-Id: I1f70c0271169a237e1acdeb7fe855be957ba2ea5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-09-23 17:27:43 +00:00
Lars Knoll 1dac47c141 Cleanups in Value/Primitive
Get rid of Primitive and move the corresponding methods
directly into Value. Mark many methods in Value as
constexpr and turn Value into a POD type again.

Keep Primitive as a pure alias to Value for source
compatibility of other modules that might be using it.

Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-09-17 07:47:09 +00:00
Lars Knoll ff5bc526b4 Add support for yield*
Change-Id: I5b054b59519ed825459a5b0b0a7cd2c6fc8a3797
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-09-07 10:32:01 +00:00
Lars Knoll 656db7a425 Don't define a prototype property for most functions
Only functions that are constructors should have a prototype
property.

Change-Id: Ifcf6f8b6c38de055d871d57ada38a23432974263
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-09-04 18:25:10 +00:00
Lars Knoll 94f0d86b5d Add support for WeakSet
Change-Id: I5cee2bf0c6a45ad2c14b52e1a4fc5ef015e01042
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-28 21:45:48 +00:00
Lars Knoll 464b878b97 Implement support for WeakMap
Change-Id: Id23e80fe5918ba7dc897568123bf3db4d35e9092
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-28 21:45:45 +00:00
Lars Knoll e4e220fb56 Partial Atomics support
Implement support for basic atomic operations on
SharedArrayBuffers.

Half of the methods still need a proper implementation.

Change-Id: Ia88da358e0c2ae6d28e9bcc1feb8980b6f51a812
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-26 16:59:33 +00:00
Lars Knoll 7bdb46c5aa Clean up the code handling reads and writes into typed arrays
This is a preparation for supporting atomic operations on Typed arrays.

Change-Id: I91d00f3aee3f35fc22e74ee010ed2cbec2d46aae
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-25 08:30:04 +00:00
Lars Knoll 860807b22a Implement support for SharedArrayBuffer
We'll still need to hook this up with Worker threads to become
useful.

Change-Id: Iedae7307edd76368aeba163731856ebe9b32c6b6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-25 08:30:00 +00:00
Lars Knoll 732c25029e Implement support for call/callAsConstructor in Proxy objects
This adds the last missing piece of functionality for
Proxy objects.

Also fix a bug where we ignored the newTarget in
Reflect.construct.

Change-Id: I2443470f2ca13fb6223768c3bf6bdc3766bb4fc3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-23 19:18:19 +00:00
Lars Knoll 34094f6918 Fix toLocaleString implementations in (Typed)Array.prototype
Change-Id: Idcabd68b1651ad3cae315a16cb0e1361cba21253
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-23 08:13:35 +00:00
Simon Hausmann 4b2b1fc121 Add support for compiling ES modules ahead of time
This is also pretty straight-forward by adding .mjs as supported
extension in the qmake and cmake support.

This also tweaks qv4engine.cpp to share the same module compilation
function across all code paths.

Change-Id: Ia0e23c78a794f2330ecf8f991ee6ea948f4ac89d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-17 11:06:18 +00:00
Simon Hausmann 29e4b97bad Add support for disk caching of ES modules
Two minor fixes needed for this otherwise straight-forward change:

    (1) When compiling modules, use the full url for the source file of
    the compilation unit, as that's what we use for the relocation check
    when loading the cache file.

    (2) Record the proper source time stamp for cache invalidation.

As a bonus, when importing scripts from .qml files, we now also attempt
to use the cached version that we created on the fly in an effort to
replace heap memory with mmap backed memory - just like we do for .qml
files.

Change-Id: I5b03a18e3c44d537c3242cb1d969636df32fe42a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-17 11:06:16 +00:00
Simon Hausmann f43c1d902d Add support for importing ES modules in .qml files
This is a straight-forward hook into the module implementation in
QV4::ExecutionEngine. Modules are pre-compiled in the QML type loader
thread. That thread keeps track of all pending loading scripts through
the type loader's m_scriptCache. Once a module is compiled, it's
thread-safely registered with the execution engine.

Script instantiation and evaluation is done solely in the QQmlEngine's
thread.

ES Modules are identified in imports as well as qmldir files by the .mjs
extension.

Change-Id: Ie9c59785118afcb49f43a1e176a9f7db00f09428
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-17 11:06:12 +00:00
Simon Hausmann 0e45db9a04 Fix order of own property names of module namespace objects
They must be sorted, no duplicates and only one default entry at most.

Change-Id: Ia9c0e54a761ce7cbfebb837330bf3769d505eb3b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-15 18:55:53 +00:00
Lars Knoll 5819700e0c Fix spec compliance for the RegExp constructor
Change-Id: I767b27faab912e91962797ca154d929473113cc1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-15 14:24:45 +00:00
Lars Knoll b862d429b1 Fix some details in RegExp handling
Change-Id: If9f7c07ea657ba8503b9188a7b77e301f23423ef
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-15 14:24:41 +00:00
Lars Knoll cda5885efa Improve RegExp.prototype[Symbol.match] implementation
Change-Id: Id632a4f4648f68f3b46d31f84e4ee05c86391f3e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-15 14:24:26 +00:00
Lars Knoll a1964f0b8e Cleanup RegExpObject
Move properties from RegExpObject to getters in RegExp.prototype
to be compliant with the JS spec.

Implement support for the sticky flags ('y') and correctly parse
the flags in the RegExp constructor.

Change-Id: I5cf05d14e8139cf30d46235b8d466fb96084fcb7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-15 14:24:23 +00:00
Simon Hausmann 8bebd12c1b Improve error handling for non-existent file imports
Change-Id: Ic043d30738c97836cf6afada6ee7cade23bf50f9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-14 17:45:41 +00:00
Lars Knoll 886d463061 Enable unicode regular expressions
Add support for the 'u' flag for regular expressions.

Change-Id: I409054eaa9c50183619752d14f2638f5a38c0ea7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-10 14:16:12 +00:00
Simon Hausmann 82da798499 Add initial basic support for ES6 modules
The entry point from the parsing perspective into modules is not
QV4::Script but QV4::ExecutionEngine::compileModule.

For convenience, the ESModule AST node gets a body, which is the
statement list connected between the ModuleItemList items that are not
import/export declarations.

The QV4::Module allocates a call context where the exported variables
are stored as named locals. This will also become the module namespace
object.

The imports in turn is an array of value pointers that point into the
locals array of the context of the imported modules.

The default module loading in ExecutionEngine assumes the accessibility
of module urls via QFile (so local file system or resource). This is
what qmljs also uses and QJSEngine as well via public API in the future.

The test runner compiles the modules manually and injects them, because
they need to be compiled together with the test harness code.

The QML type loader will the mechanism for injection in the future for
module imports from .qml files.

Change-Id: I93be9cfe54c651fdbd08c5e1d22d58f47284e54f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-09 13:18:39 +00:00
Lars Knoll d046de0ddb Setup the prototype correctly when subclassing error objects
Change-Id: I5e394ef8d4d6d87bedb26070d51660e3ebe3ab1b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-06 10:00:45 +00:00
Lars Knoll 245cb6b6a3 Fix a couple of test failures related to error objects
Set up the prototype chain for error objects correctly, and make
them inherit from the right classes.

Change-Id: I7bb12b3bb285950a1bff25e5c62954287a95970a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-02 20:25:18 +00:00
Lars Knoll 4ac9cf7896 Fix the remaining test failures with non strict arguments objects
Change-Id: Ib50f602263dd0146d792fb3d12bd5971585fda30
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-30 20:45:06 +00:00
Lars Knoll fc01254cf8 Fix class members that are generators
Properly support member functions that are generators in classes.

Change-Id: I5fc8d5b58a17c61a446b43d6576bb83de5ecd920
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-03 11:19:03 +00:00
Lars Knoll 2666fe4a14 Move the C++ and JS stack frame definitions into it's own file
Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-03 08:08:49 +00:00
Lars Knoll 0b6bc89c61 Remove ExecutionEngine::setCurrentContext()
It's unused and shouldn't exist. Also de-inline currentContext()
to avoid a dependency on the CppStackFrame in the header.

Change-Id: I44724f8097883dc1b1064430778f45f7811460df
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-03 08:08:46 +00:00
Lars Knoll 32c33ee9ab Get rid of Value::asArrayIndex()
It was only used in a few places now, that can be replaced by
either using a PropertyKey, or by limiting the fast path
optimization in the runtime to array indices smaller than
INT_MAX. Since there are less branches this should even be
faster for pretty much all use cases.

Change-Id: Ib4f2f2f3e27f14ad180b810546e82ac83170b106
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-02 19:29:52 +00:00
Lars Knoll 56bff8f7ab Clean up the property key API in StringOrSymbol
Get rid of makeIdentifier(), as toPropertyKey() will take
care of it.

Rename identifier() to propertyKey() and check that the
key is valid.

Remove String/StringOrSymbol::asArrayIndex(), we don't need it
anymore.

Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-02 19:29:43 +00:00
Lars Knoll db695c5b1d Unify the get and getIndexed vtable functions of QV4::Object
This finalizes the refactoring of Object's vtable API. Also added
the receiver argument to the method as required by the ES7 spec.

Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-02 19:29:29 +00:00
Lars Knoll eae4756f74 Add a MemberFunction function object
Member functions in ES7 can not be called as constructors and
will throw a type error when trying.

Some more fixes are needed here, as they also do not have a
prototype property.

Change-Id: Ieb920163acaa68d4ff0ff73ae4c1015e883b406f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-26 10:04:18 +00:00
Yulong Bai 74f4065caa Add basic support for EcmaScript classes
Most of the class creation is done inside the runtime
in the CreateClass method. Added a corresponding
instruction to the interpreter and jit.

The compiled data now contains an array of classes
containing the compile time generated layout of the class.

Currently, classes without an explicit constructor and
classes with inheritance are not supported.

Done-with: Yulong Bai <yulong.bai@qt.io>
Change-Id: I0185dcc1e3b0b8f44deff74e44a8262fc646aa9e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-26 10:03:56 +00:00
Liang Qi 8597f74e52 Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev 2018-06-25 10:16:26 +00:00
Ulf Hermann fbf6f7400a Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
	src/quick/handlers/qquickhandlerpoint.cpp
	src/quick/handlers/qquicksinglepointhandler.cpp
	tests/auto/qml/ecmascripttests/test262

Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
2018-06-25 12:15:55 +02:00
Lars Knoll 1596112e14 Add Proxy support for prototype handling
Cleanup get/setPrototypeOf and fix some smaller incompatibilities
in the default implementation for Object.

Add the methods to the vtable and reimplement them according to
spec for ProxyObjects.

Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods
and fix a smaller bug in the Reflect API for those methods.

Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-25 07:36:48 +00:00
Lars Knoll f5a7953df3 Partial Proxy support
get, set and deleteProperty proxying is implemented,
the others require some more changes in our engine.

Change-Id: I4dd4b154b1a582f5e36cdc9429fa049fd37d5167
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-25 07:36:17 +00:00
Lars Knoll 12bc11e5af Add support for Reflect
Implemented all methods in Reflect, only some smaller
bugs left in there.

Change-Id: I53d2304d0e59566aec64e200cd995e02afcfc33e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-21 19:43:41 +00:00
Lars Knoll d1693c14b4 revert change 353164263c
The change was too aggressive in trying to avoid marking
the array data. We didn't catch all cases where on could be
inserting a GC controlled object into the array data. Let's
be safe and always mark the content of array data objects.

Task-number: QTBUG-68894
Change-Id: Ifbb628be898c0903596b1a483212384295b01df5
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-06-19 14:20:44 +00:00
Robin Burchell a0fcf724ef Add the start of a Map from ES7
Like Set, for the time being, this is baseed on top of ArrayObject: two
of them, one for keys, one for values. Again, this goes against the
spirit of the spec (which requires nonlinear access), but having the API
present is at least a start, and the implementation is easily changed.

Change-Id: Idcf0ad8d92eb5daac734d52e8e2dd4c8e0dd5109
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-06-01 11:53:37 +00:00
Robin Burchell 19f657d995 Add the start of a Set from ES7
Based on top of an ArrayObject for now, which is admittedly a bit of a
cheat and not matching the "spirit" of the spec. OTOH, that makes it
easy to write, and is presumably quite lightweight, so perhaps this is acceptable
as a starting point.

Change-Id: Ibc98137965b3e75635b960a2f88c251d45e6e837
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-30 20:57:17 +00:00
Lars Knoll 3ccd529e35 Implement toPrimitive() the way the ES7 spec wants it
Add Dat.prototype[Symbol.toPrimitive] and make use of those
methods in the toPrimitive implementation.

Change-Id: I82a9a94dcae6822100de364373b3f4de1e3d749b
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2018-05-28 10:40:08 +00:00
Lars Knoll 6cbc287c06 Cleanup JS stack allocations
Avoid double writes to the stack, and use scope.alloc() for
most allocations on the stack.

Change-Id: I8b89273c1b6796d955fc8eeb72c67cff208ef786
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-26 06:49:04 +00:00
Lars Knoll de95f4da8b Fix the inheritance structure for typed arrays
Change-Id: I8a16c1f5e0252b4ea85ff8f623beb39df747e383
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-24 08:09:33 +00:00
Lars Knoll b254bbb82b Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I0127f2c16de1d930bdd8cbccd42ec6785f31ab96
2018-05-24 09:15:57 +02:00
Lars Knoll 3de014db9e Fixup the throwTypeError internal function
Make the function conform to section 9.2.7.1 of the spec.

Change-Id: Ieb3295198f407d4404e06a54efb51a8b8496bbd7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-23 13:19:28 +00:00
Simon Hausmann 60176efa78 Fix crash when incubating objects with non-existent initial properties
When incubation is triggered from C++ and reaches the state of setting
the initial properties (as supplied to incubateObject), we'd set
engine->currentStackFrame to a CppStackFrame that provides access to the
correct QML context. As we're not called from the interpreter, the
v4Function pointer would be a null pointer. If during the initial
property setting an exception is thrown (due to non-existent property
access) and a back-trace is created, we'd end up dereferencing
v4Function.

Change-Id: I7f6b0ba7893bfb4186f55d4c213b4bb602d29aa0
Task-number: QTBUG-68416
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-23 11:06:34 +00:00
Lars Knoll cc8cb4b442 Implement Symbol.species getter functions
Change-Id: I18b3e382e679f95d7cb53b4ed03be2513ea0204b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-15 18:21:10 +00:00
Lars Knoll c4ef0d6e4b Call iterator.return when required in destructuring assignments
Array destructuring assignments require a call to iterator.return if
the iterator hasn't been exhausted during destructuring.

Change-Id: I39fe4bc01bef6fb2ad3bda92caf6779fbbddc8e2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-14 19:32:42 +00:00
Lars Knoll 3d5ba9f86e Add instructions to simplify for-of loops
Added an IteratorNext instruction to fetch the next
iteration value (empty if the iterator is done).

This will also help to implement array destructuring without
requiring huge amounts of byte code.

Change-Id: If96c1e81471e5e2b0b7b2af122238d87741aa371
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-13 12:55:20 +00:00
Lars Knoll 4cf7e80c57 Ensure we have a lexical scope for global code
This requires a bit more work than simply pushing a
new BlockContext for the lexically declared variables,
as eval() and the Function constructor operate on the
global scope (including the lexically declared names).

To fix this introduce Push/PopScriptContext instructions,
that create a BlockContext for the lexically declared
vars and pushes that one as a global script context that
eval and friends use.

Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-11 07:17:05 +00:00
Lars Knoll 8e69a9868c Avoid accessing an object with this == nullptr
Get rid of a circular dependency when initializing
StringObject.prototype, by setting it's string value
later during the initialization process.

Change-Id: I5bdaff3936c1f8af12c4d53f95747b8aa43f4ef6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-04 18:13:09 +00:00
Lars Knoll 4f086e3aac Rename ForeachIterator to ForInIterator
As it's being used for for(... in ...) loops. Also add a ES6
compatible iterator interface to it, so that we can unify
the handling of for-in and for-of.

Change-Id: I264f88ed049484945f5ea7e8bdf0227187456ba2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-04 18:12:50 +00:00
Lars Knoll 1f9fdd1af7 The length property of function objects is configurable
Change-Id: I657be2e2eb4dfd86850bb73e85d4ddd24f0b8986
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-03 20:05:18 +00:00
Lars Knoll 5747a75302 Add Generator support
Add support for ES6 generators. Those are currently
always executed in the interpreter (we never JIT them),
to simplify the initial implementation.

Most functionality, except for 'yield *' expressions
are supported. 'yield *' will have to wait until we
support for(... of ...)

Change-Id: I7c059d1e3b301cbcb79e3746b4bec346738fd426
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-03 20:05:14 +00:00
Lars Knoll 8761cbd4f7 Implement StringIterator
Add support for String.prototype[Symbol.iterator] and the
StringIterator object.

Change-Id: I72c4f988e4f363be1af51f9cc5f8e83af43cd151
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:20:29 +00:00
Lars Knoll 7d46d72510 Implement support for arguments[Symbol.iterator]
Change-Id: Ieb60e2d8f41c38146b588bc8cd225a2a567e0956
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:20:25 +00:00
Lars Knoll c7fe748850 Cleanup creation code for builtin functions
Centralize the code in FunctionObject::createBuiltinFunction and setup
function names and length properties there.

Change-Id: I21f1d42b475070ee091d96d97387149af1dc47f2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:20:21 +00:00
Robin Burchell a4207b2f95 Add Array Iterator objects from ES6 (22.1.5)
And implement / expose them via:
    22.1.3.4 - Array.prototype.entries()
    22.1.3.13 - Array.prototype.keys()
    22.1.3.29 - Array.prototype.values()
    22.1.3.31 - Array.prototype[Symbol.iterator]

Most tests for Array iterators now pass.

At the same time, expose them on TypedArray's prototype:
    - 22.2.3.15 %TypedArray%.prototype.keys
    - 22.2.3.29 %TypedArray%.prototype.values
    - 22.2.3.6 %TypedArray%.prototype.entries
    - 22.2.3.31 %TypedArray%.prototype[Symbol.iterator]

For TypedArray, test coverage improves a tiny bit (3 passing tests), but the
vast majority fail as it seems like the object structure for TypedArray is
currently incomplete as far as ES6 expects.

It seems that ES6 expects the object structure to be:
* %TypedArray% (inherits FunctionObject)
    (this is the TypedArray intrinsic object, and responsible for initializing
    the TypedArray instances)

* All the TypedArray ctors (e.g. UInt8Array)
    These inherit %TypedArray%, and make a super call to it to do their work

* %TypedArrayPrototype% (inherits Object)
    (this is the initial prototype for %TypedArray%)
    * All the ctors have their own separate instance of this
    * The instances also make use it

So, for instance, a lot of the tests attempt to access the prototype like:
    var proto = Object.getPrototypeOf(Int8Array)
    var keys = proto.prototype.keys

As ES6 expects Int8Array.prototype to be %TypedArray% (22.2.5), this expands to:
    Object.getPrototypeOf(%TypedArray%)
which it expects to be %TypedArrayPrototype%.

But since we have no intrinsic object, and the ctors inherit
FunctionObject, we instead return the wrong prototype into 'var proto'.

Change-Id: I5e1a95a0420ecb70a0e35a5df3f65557510c5925
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:20:13 +00:00
Lars Knoll 37b85ca10e Add SymbolObject, well known symbols and fix most remaining issues
Added SymbolObject, the equivalent to StringObject which was
still missing so far. Added the predefined standard symbols,
and fixed most test failures related to symbols.

Change-Id: I1e28b439e7c4f5141b4a09bd8fb666c60691f192
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:18:45 +00:00
Lars Knoll 360a48aa3f Implement Symbol.for and Symbol.keyFor
Change-Id: I5fde731b3a1a6d7c15154881ed82549b2800d104
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:18:41 +00:00
Lars Knoll bab5e5adf5 Partial Symbol support
Added basic infrastructure to create symbols and convert them
back to strings. In addition, storing and retrieving of symbol
based properties in Objects works.

Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:18:36 +00:00
Lars Knoll a6da23bb5f Garbage collect identifiers
Implemented by storing a backpointer to the Heap object
in the identifier.

Since identifiers now point back to their originating
String or Symbol, we can now easily mark all identifiers
that are still in use and collect those that aren't.

Since Identifiers are 64bit also add support for holding an
array index in there. With that an identifier can describe
any kind of property that can be accessed in an object. This
helps speed up and simplify some code paths.

To make this possible, we need to register all
IdentifierHash instances with the identifier table, so that
we can properly mark those identifiers.

Change-Id: Icadbaf5712ab9d252d4e71aa4a520e86b14cd2a0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:18:32 +00:00
Lars Knoll 3c090c80c5 Remove String dependency from InternalClass
This is required, so we can also use Symbols in
the internal classes.

Change-Id: I630e7aa7b8b16d5a94041f8d18515fd582f94264
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:18:23 +00:00
Lars Knoll 922e6f42b4 Rework catch context handling
Remove the need for a specialized catch context, instead
use a regular block context, that also captures the
catched variable.

This also removes the need to do lookups by name inside
a catch expression.

Change-Id: I8b037add7f423922e2a76b4c0da646ca7e25813a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:17:51 +00:00
Lars Knoll 7e854bc568 Clean up handling of the 'caller' property
This brings it closer in line with the ES8 spec. Also
remove a couple of tests testing the 'caller' property
of non strict functions, as it's not mandated by the
spec and we never set it.

Change-Id: Icece8a03989c474df1eae0e4e77b356e49575b32
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-26 20:26:56 +00:00
Lars Knoll ce2f9621e0 Get rid of some outdated code
There's no point in trying to treat syntax errors specially here.

Change-Id: Idde8f9c9669f183e1b8f5b17bb7e4299fc5f1e5f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:59:21 +00:00
Lars Knoll 6002b48c3c garbage collect InternalClass
Internal classes are now allocated and collected through
the GC. As they are important to the deletion of other
objects (because of the vtable pointer living inside the
internal class), they need to get destroyed after regular
objects have been sweeped. Achieve this by using a separate
block allocator for internal class objects.

Our lookups do often contain pointers to internal classes,
so those need to be marked as well, so we don't accidentally
collect them.

Change-Id: I4762b054361c70c31f79f920f669ea0e8551601f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:59:08 +00:00
Lars Knoll 3932536b59 Better encapsulation for EngineBase::internalClass
Turn it into a method instead of accessing the array directly
to simplify refactoring.

Change-Id: I197b56c8f58cfdfd294f429e6b15268c755f9837
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:59:02 +00:00
Lars Knoll b6bb3fe423 Clean up Engine::newObject/newArrayObject
They don't need a prototype argument neither anymore.

Change-Id: I80fa99cb382e8dca4cfa51fdd87b4c9b0f59573a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:52 +00:00
Lars Knoll 278b144a35 Disambiguate different allocation functions in the memory manager
Some compilers (in this case MingW 5.3) don't manage to properly
disambiguate the template overloads, and try to instantiate the
wrong template function.

Solve this by renaming the one of the template functions.

Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:48 +00:00
Lars Knoll 6c2f6e029e Cleanup MM::allocObject()
The prototype argument has been unused for quite some time,
finally remove it.

Change-Id: Ifcebe413a1951ed972b370afc48640bd22969943
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:45 +00:00
Lars Knoll f3ae6799e1 Optimize MM::allocManaged()
We can manage without calls to changeVTable() here, as the
set of classes allocated with this is rather limited.

Change-Id: I804e4850b91c61ebbca8a04edbe51deac911928d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:41 +00:00
Lars Knoll c7bac1588e Remove the pool allocator from InternalClass
Makes it easier to transition it over to be controlled
by the GC.

Change-Id: I6bea738b3852abfc7870b71e639efc595eeb28fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:30 +00:00
Qt Forward Merge Bot 9477ba4e42 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I2e3ba907a6afcaa69354a894259c7b7accf3e3ac
2018-03-17 20:42:46 +01:00
Simon Hausmann ee89a8c052 Fix lookup of enums declared in QML singletons
Given the following expression

    var x = MySingleton.MyEnumValue

where MySingleton is a QML (composite) singleton and MyEnumValue comes
from a QML declared enum, we had code in place up to (and including)
5.10 to attempt to optimize that expression to a enum constant at
compile time. In 5.10 that optimization does not exist anymore. In <=
5.10 we would also skip the optimization under certain circumstances
(too many statementes, etc.). The fallback that is in place for handling
this at run-time tried to be smart by avoiding the
QQmlContextWrapper::get lookup and return straight a reference to the
singleton as QObject. That works for regular property lookups, but it
fails when trying to look up something like an enum, that isn't a
meta-object property.

Change-Id: I1819b9d8ae06a3f595e067bf5b018c4065be76bb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-03-16 10:42:57 +00:00
Qt Forward Merge Bot bf0603fd03 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I308b964d86ca01916f6af7d6e3f71557e3624eca
2018-03-03 01:00:13 +01:00
Ville Voutilainen d0c1b1e8f9 Silence a GCC 8 warning in qv4engine
qtdeclarative/src/qml/jsruntime/qv4engine.cpp:913:78: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct QV4::Property’ with no trivial copy-assignment [-Werror=class-memaccess]
             memcpy(argumentsAccessors, oldAccessors, oldSize*sizeof(Property));

Change-Id: I6e3d6a1a26fda33aa47c315a183edba9dcd0c0b9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-28 16:10:55 +00:00
Liang Qi bb7a5d0cb6 Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4internalclass.cpp
	src/qml/parser/qqmljslexer.cpp
	src/qml/qml/v8/qv8engine.cpp
	src/qml/util/qqmladaptormodel_p.h
	src/quick/items/qquickanimatedsprite.cpp
	tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp

Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
2018-02-27 08:43:10 +01:00
Shawn Rutledge 499ec43937 use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.

Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).

Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-26 07:13:18 +00:00
Qt Forward Merge Bot d21fd06627 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I8cca650fbb1904ecba59da909a08dba3cc574add
2018-02-22 09:19:15 +01:00
Oliver Wolff ab03ee7b7e WinRT: Do not call canAllocateExecutableMemory from static initializer
When the code generation capability is not set, the first call of
canAllocateExecutableMemory will cause a warning about suboptimal
performance. The qWarning code checks, which thread caused the message
and QThread::current sets QCoreApplicationPrivate;s theMainThread when
it is called for the first time on Windows.

If we call that function inside a static initializer, it will be called
before QCoreApplication is created and thus set the main thread to the
one that called the function. This will cause a warning about QApplication
not being created inside the main() thread, but more importantly,
delivering of events will not work in WinRT applications afterwards.

Task-number: QTBUG-66418
Change-Id: I3b6bf804983644b5ae5fe2288a587dc95fab2c8b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-02-22 06:30:29 +00:00
Ulf Hermann f254b0aa67 Add a feature for QML locale support
Change-Id: I1cfb2da317f52709011b67a68e87a73ed24ef6d6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-15 08:04:43 +00:00
Qt Forward Merge Bot 268931e742 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Ib297817e2fd9b6790d9bc8ee522c32f5b3422574
2018-02-13 20:21:35 +01:00
Ulf Hermann b897a4b9e5 QML: Make mapping of sequence object in JS optional
qv4sequenceobject.o is the largest single object in QtQml.so. This is
probably due to template and macro explosion. Not everyone will want to
pay this price to have Qt containers natively available in JS.

Change-Id: I7dc64566a653c865d5c1b6e4f21a3a9089db100a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-11 19:20:12 +00:00
Simon Hausmann 6a2ebc47cf Fix crashes on WinRT when allocation of executable memory is disabled
This regressed in commit b56f7d6f79. We
need to choose the YARR JIT (as well as the regular JIT) only if we can
allocate executable memory.

Change-Id: I150238fda7b3699cb1d7ffedeeed3c6f3f54132b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-09 13:18:28 +00:00
Lars Knoll ea164ca4a8 Change creation of new internal classes
So far we often began with the empty class again when creating
new internal classes. This allowed for multiple paths through the
internal class hierarchy ending up at the same internal class object.

But to be able to efficiently garbage collect internal classes, we
need to have only one path to each instance of an internal class.

Change-Id: Ic6c1f2b3d021e92b44f76a04a8886820e63e8f26
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-09 07:55:36 +00:00
Ulf Hermann 8419ff45d4 Further simplify relation between different engines
The only engine we ever ask for QJSEngine is QV4::ExecutionEngine.

Change-Id: Ia1354e552bddac72177b7aa62de5a7a502089841
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-07 16:32:48 +00:00
Shawn Rutledge 81b393227d Merge "Merge remote-tracking branch 'origin/5.10' into dev" into refs/staging/dev 2018-02-06 19:40:36 +00:00
Liang Qi a9a9fa0c47 Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
	src/qml/compiler/qqmlirbuilder.cpp
	src/qml/compiler/qqmlirbuilder_p.h
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4codegen_p.h
	src/qml/compiler/qv4compileddata_p.h
	src/qml/compiler/qv4compiler.cpp
	src/qml/compiler/qv4compilercontext_p.h
	src/qml/compiler/qv4isel_moth.cpp
	src/qml/compiler/qv4jsir.cpp
	src/qml/compiler/qv4jsir_p.h
	src/qml/jit/qv4isel_masm.cpp
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4functionobject.cpp
        src/qml/jsruntime/qv4runtimecodegen.cpp
	src/qml/jsruntime/qv4script.cpp
	src/qml/jsruntime/qv4script_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/quick/items/qquickanimatedimage.cpp
	src/quick/items/qquickanimatedimage_p_p.h
	src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp
	tests/auto/qml/qmlplugindump/qmlplugindump.pro
	tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
	tools/qmlcachegen/qmlcachegen.cpp
	tools/qmljs/qmljs.cpp

Done-with: Shawn Rutledge <shawn.rutledge@qt.io>
Done-with: Lars Knoll <lars.knoll@qt.io>
Done-with: Ulf Hermann <ulf.hermann@qt.io>
Change-Id: I010e6525440a85f3b9a10bb9083f8e4352751b1d
2018-02-02 15:59:32 +01:00
Ulf Hermann 65606ea155 Remove double indirection between QJSEngine and QV4::ExecutionEngine
As QJSEngine's handle() method is internal, we can redefine it to return
a pointer to an ExecutionEngine. That makes many things easier.

Change-Id: Ie3df99e0bad5f00ad4fe73182896cd135fa82994
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-02 09:37:40 +00:00
Liang Qi 2570b801c7 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	.qmake.conf
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/debugger/qqmlprofiler_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/memory/qv4mm.cpp
	src/qml/qml/qqmlcomponent.cpp
	src/qml/qml/qqmlobjectcreator.cpp
	src/qml/qml/qqmlobjectcreator_p.h
	src/qml/types/qqmldelegatemodel.cpp
	src/quick/items/qquickitem_p.h
	src/quick/items/qquickwindow.cpp
	tests/auto/quick/touchmouse/BLACKLIST
	tests/benchmarks/qml/holistic/tst_holistic.cpp

Change-Id: I520f349ab4b048dd337d9647113564fc257865c2
2018-01-24 09:34:11 +01:00
Simon Hausmann 4e02776640 Speed up V4 QML context creation
After commit cae7975a03 the vtable became
part of the internal class, which meant that for allocating the
V4::QmlContext and the QV4::QmlContextWrapper we had one additional IC
transition upon allocation. We can avoid that by providing a default IC
for both types.

Task-number: QTBUG-65708
Change-Id: I22815a24a8389b59103309806f6ac4ca382405f0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-01-16 15:32:32 +00:00
Lars Knoll b2be122a78 Get rid of BuiltinFunction
It's now unused.

Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-01-15 08:49:55 +00:00
Lars Knoll 4e1512baf6 Convert more builtin functions to use the new calling convention
Convert most of the methods used QML objects to the new calling
convention. Converted IndexedBuiltinFunction to do the same.

Change-Id: I41b26042c2f56f24988485b06e8ccd214e2573c0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-01-12 07:04:27 +00:00
Ulf Hermann 52bc4fbfba Use potentially intercepted URL as ID for compilation units
We generally have to pass a URL and a file name everywhere because the
logical URL might be something else than the actual file being loaded.
For example a QQmlFileSelector might modify the URL to be loaded for a
specific file. This resulting URL, however, should not be used to
resolve further URLs defined in the file loaded that way.

As we need to access QQmlTypeLoader::m_url as string more often now,
cache it and avoid frequent translations between QUrl and QString.

Furthermore, QQmlDataBlob's URLs are changed to follow the same
semantics. The finalUrl is the one that should be used to resolve
further URLs, the url is the one used to load the content, and subject
to any redirects or interceptions.

This changes the semantics of URL redirects. Previously a redirected URL
was used as the base URL for furher URL resolution. This doesn't work
because redirection occurs after interception and interception should
not influence the resolution of further URLs. We now use the original
URL as base URL for resolution of further URLs and rely on the server to
redirect those, too.

Task-number: QTBUG-61209
Change-Id: I93822f820bed2515995de3cb118099218b510ca4
Reviewed-by: Michael Brasser <michael.brasser@live.com>
2017-12-21 16:02:50 +00:00
Erik Verbruggen 6793683b16 V4: Only start JITting after a minimum of 3 calls
Change-Id: I748e06041f3085980ce48391ba2d829a9d86a727
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2017-12-14 09:24:03 +00:00
Simon Hausmann d373d5e7d7 Merge remote-tracking branch 'origin/wip/new-backend' into dev
Conflicts:
	src/qml/compiler/qv4isel_moth.cpp
	src/qml/compiler/qv4jsir_p.h
	src/qml/jsruntime/qv4engine_p.h
	src/qml/jsruntime/qv4vme_moth.cpp
	tests/auto/qml/qml.pro

Change-Id: Ia7b6ec24c7fcbcbb1786d9e798d2df294020ae37
2017-11-21 12:29:40 +01:00
Erik Verbruggen 3658f534cb V4: Add a baseline JIT
This patch add a JIT back in for all platforms that supported JITting
before, with the exception of MIPS.

Change-Id: I51bc5ce3a2ac40e0510bd72a563af897c5b60343
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-17 11:53:42 +00:00
Lars Knoll 30ada3da86 Clean up ArgumentsObject handling
Introduce a proper strict arguments object.

Change-Id: Ie4e7f904b3a0e03893b18b3c6709f4f25dbc1030
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-11-14 21:46:14 +00:00
Lars Knoll 353164263c Avoid marking on simple array data's
Speeds up things by 2-3%.

Change-Id: Ib17ab126cf91ce48a0ced7dd7b06c4f7f0a70a3b
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-11-14 21:45:54 +00:00
Edward Welbourne 948e24cb6d V4 Date.ParseString(): fix UTC-ness of date-only formats
ECMA-262 stipulates that date-only formats should be treated as UTC,
while date-times are handled as standard time, if no time zone is
explicitly given.  Tidied up the parser a bit in the process and
documented what the spec says.  Fixed some broken test-cases.

Handling of date-times without zone as local time is a correction
since edition 5.1 of ECMA-262 (which said to handle it as UTC):
http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact
We were previously handling both dates and date-times as local time,
violating the old spec for both and the revised spec for dates.

Task-number: QTBUG-56787
Change-Id: I557789d855b910ca6a859fca396af1a0205c9417
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-14 17:18:21 +00:00
Ulf Hermann 4e6d5951ed Make qml-debug a proper feature
Change-Id: Iea33ff0200f0bbf43953fedba030edf91d0f1417
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-08 13:18:25 +00:00
Lars Knoll 0a27a14ec1 Merge remote-tracking branch 'origin/dev' into new-backend
Change-Id: I1a49b4a242ed0764101521d06ec612e96bff0e4c
2017-11-08 12:32:01 +01:00
Ulf Hermann 0855417be4 Re-enable Debug instructions and locations for QML functions
Debug instructions are used to trigger break points and are added for
every source line.

We also need to insert Debug instructions before Ret, so that we can
step out. We also need to assign line numbers to the entry and return
points of "abbreviated" QML functions (by simulating lbrace and
rbrace) so that we can set break points on them. The line numbers on Ret
need to be negative, so that you cannot (accidentally) set break points
on them. A typical signal handler or binding in QML consists of only one
line and if you set a break point on that line, you want it to hit only
once, when entering the function. If the line numbers on Ret were
positive, it would be hit again on exit. Some of the tests in
tst_qqmldebugjs implicitly check for that.

Also the new interpreter does something on the left brace, so a
function actually starts there, not on the first statement.

Change-Id: Id9dfb20e35696b420d0950deab988f7cc5197bfc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-11-06 11:57:36 +00:00
Lars Knoll aceb0d0cd2 Merge remote-tracking branch 'origin/dev' into HEAD
Conflicts:
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4compileddata.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/compiler/qv4isel_moth_p.h
	src/qml/compiler/qv4ssa.cpp
	src/qml/jit/qv4assembler_p.h
	src/qml/jit/qv4isel_masm_p.h
	src/qml/jit/qv4regalloc.cpp
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4qmlcontext_p.h
	src/qml/jsruntime/qv4regexp.cpp
	src/qml/jsruntime/qv4regexp_p.h
	src/qml/jsruntime/qv4regexpobject.cpp
	src/qml/jsruntime/qv4runtime.cpp
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/qml/v8/qqmlbuiltinfunctions.cpp
	tests/auto/qml/qml.pro
	tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
	tools/qmlcachegen/qmlcachegen.cpp

Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
2017-10-22 12:26:28 +02:00
Liang Qi 96b2323355 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	.qmake.conf
	src/qml/jsruntime/qv4engine.cpp

Change-Id: I5f7b63a937a214267e15ad5757844d662a4f981b
2017-10-15 21:37:14 +02:00
Simon Hausmann 55ecfd409c Simplify compilation unit tracking in the execution engine
Instead of collecting all compilation units in a hash, let's collect
linked units in a doubly-linked lists that makes the removal at
destruction time dramatically cheaper.

Change-Id: I9fd59600d082be3566f605d90f14a86a58ac9296
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2017-10-06 12:56:11 +00:00
Ulf Hermann 080a5c705a QV4Engine: Don't cache compilation units to be unlinked
A compilation unit that is unlinked may recursively unlink and delete
further compilation units belonging to the same engine via its
resolvedTypes property. Those units won't be able to remove themselves
from the cached set, and will therefore get their unlink() method
called again, this time on a dangling pointer, when the engine gets
around to them.

Change-Id: Icaa941ca2117c8303c49623b2be0f9014502d849
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-10-05 08:12:00 +00:00
Lars Knoll 55a671ea73 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/qml/compiler/qv4compileddata.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4qmlcontext.cpp
	src/qml/jsruntime/qv4qmlcontext_p.h
	src/qml/jsruntime/qv4regexpobject.cpp
	src/qml/jsruntime/qv4regexpobject_p.h
	src/qml/types/qqmllistmodel.cpp
	src/quick/items/qquickanimatedimage_p.h
	src/quick/scenegraph/qsgrenderloop.cpp
	tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp

Change-Id: If20ef62b2c98bdf656cb2f5d27b1897b754d3dc0
2017-09-20 14:27:41 +02:00
Simon Hausmann 78d574a909 Fix Integrity build
Disambiguate the QV4::Value parameter.

Task-number: QTBUG-63135
Change-Id: Iae6bd209876336d58256aa94f89d146cadc62f08
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-09-12 11:10:13 +00:00
Simon Hausmann 29316abe1a Merge remote-tracking branch 'origin/5.10' into wip/new-backend
Change-Id: Iccb35fab856c7d8ec4aaaf021b70a65cfaa564b3
2017-09-12 09:56:04 +02:00
Lars Knoll 38ef59b386 Drain the mark stack while collecting roots
This avoids overflows in the markStack for test cases where
we have a huge amount of compilation units with many runtime
strings that all want to get marked.

Task-number: QTBUG-63063
Change-Id: I150c1f1a4065350cec59dd80c5c628920f70e3d0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-10 19:45:49 +00:00
Allan Sandfeld Jensen c1fed764a2 Fix reuse of regexp objects by regexp literals
Accoding to the standard the regexp objects created by literals should
be separate objects as if calling new. We were violating that by caching
the same object for every instance of a literal.

This also fixes a problem with leaking values of lastIndex between
separate instances of the same global regexp literal.

Task-number: QTBUG-62175
Change-Id: Ib22e9ee68de1d1209fbd4212e72f576bc059d245
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-08 17:45:06 +00:00
Lars Knoll 0167f5fc61 Drain the markStack while collecting roots
This avoids overflows in the markStack for test cases where
we have a huge amount of compilation units with many runtime
strings that all want to get marked.

Task-number: QTBUG-63063
Change-Id: I7c1df0fdb9afada1830f8c218a0e52ebcd093850
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
2017-09-08 13:24:25 +00:00
Ulf Hermann a88ca87497 Qml Tooling: Replace bare pointers with QScopedPointer
This way we don't have to manually initialize and delete them.

Change-Id: I0104c744dba380e957271d0924498e3643856e9e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-06 11:38:05 +00:00
Lars Knoll cc7a858698 Unify JSStackFrame and CallData
Change-Id: I4494dae8166026074c9efc74bac62de9d3fa2342
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-01 12:30:43 +00:00
Lars Knoll 77e0602021 Fix line number mapping to work with non increasing line numbers
The old map assumed that line numbers are always increasing, something
that isn't always true. So move to a format where we map blocks of
bytecode to a line number instead.

Change-Id: I1cd9dd1329d415122cd3d560294ef53007f879f8
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-08-29 10:42:35 +00:00
Lars Knoll 4e0174a88e Move line number information into a side table
Don't emit any Line instructions anymore, and instead store
the info in a side table in the compiled data, where it can
be looked up on demand.

Change-Id: Idcaf3bf4ee4129fd62f9e717bf1277dc6a34fe19
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-08-25 12:05:59 +00:00
Lars Knoll f1aff1f2d4 Merge remote-tracking branch 'origin/dev' into wip/new-backend
Change-Id: Iff06429f948ac6cdec77a9e5bb8c5375c56fe705
2017-08-22 17:17:57 +02:00
Lars Knoll 8437954c1c Get rid of CallData in the ExecutionContext
Part 1, where the callData member is moved to CallContext. We'll
get rid of it there in a subsequent commit.

Change-Id: I6218992802133913f7766ebb3d2f47bd29f33907
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-08-18 10:02:28 +00:00
Simon Hausmann 43a615e309 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/jsruntime/qv4qmlcontext.cpp
	src/qml/jsruntime/qv4qobjectwrapper.cpp
	src/qml/qml/qqmlcustomparser.cpp
	src/qml/qml/qqmlimport.cpp
	src/qml/qml/qqmlimport_p.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmlmetatype_p.h
	src/qml/qml/qqmltypenamecache.cpp
	src/qml/qml/qqmltypenamecache_p.h
	src/qml/qml/qqmltypewrapper.cpp
	src/qml/qml/qqmltypewrapper_p.h
	src/qml/qml/qqmlvmemetaobject.cpp
	src/qml/util/qqmladaptormodel.cpp

Change-Id: Ic959d03e6f9c328fb02710d9abbb0f27cddde131
2017-08-18 11:46:11 +02:00
Lars Knoll 4acb72bf35 Cleanup naming of Stack frame structures
Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-10 08:20:15 +00:00
Lars Knoll 5bc4f4d958 Refactor context handling
Fix the push/pop context instructions to not modify the JS
stack anymore, as that can cause conflicts with the VME
(and was an ugly hack in any case). Instead, these instructions
not return the old context, that is then stored in a temporary.

Get rid of Engine::current and Engine::currentContext. The
StackFrame structures do now contain the only and authoritive
data. This finally gives us a nice setup where we create and
destroy frames on the stack when entering/leaving functions.

Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-10 08:19:18 +00:00
Lars Knoll 30e3664bf3 Avoid creating a CallContext for simple functions
This cuts out quite a bit of overhead when entering
and leaving functions.

Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-10 08:18:56 +00:00
Lars Knoll 50e7badd5f Remove Scope::result and convert calling convention for builtins
Allow for faster calling of builtins, and completely avoid
scope creation in many cases.

Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-08 18:58:14 +00:00
Lars Knoll 7835060518 Fix frame handling
Fix some regressions introduced by change
1ae1eaf59e0475a2dc9c5e22e53e9be19d0f2feb.

Change-Id: I24c1db78634e3beb1ab090325b60e70f788f92a7
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-08-04 08:59:54 +00:00
Lars Knoll be70a025c1 Don't store the current line number in the ExecutionContext
Instead modify our StackFrame struct to hold the
QV4::Function and have a linked list of those for
the frames.

Change-Id: I8676e16bc51a5ba6cf25a5b3423576d44e8a926a
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-08-04 07:08:02 +00:00
Lars Knoll 49a11e8820 Use QQmlType by value
QQmlType is now refcounted, and we need to use it by
value, to control it's lifetime properly. This is
required, so we can clean up the QQmlMetaTypeData
cache on engine destruction and with trimComponentCache()

Task-number: QTBUG-61536
Change-Id: If86391c86ea20a646ded7c9925d8f743f628fb91
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-08-02 16:32:43 +00:00
Lars Knoll d3a1a9e4fe Unify SimpleCallContext and CallContext
Plan is to completely remove the need for the simple call context.

Change-Id: Ie5e4673a6746dc110adbf526e45188f218fd7bfc
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-07-05 09:07:50 +00:00
Lars Knoll 493edae038 Get rid of the GlobalContext and WithContext classes
They are just ExecutionContext's.

Change-Id: Id543934740b0e54172e469935513847224b19e79
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-07-05 09:06:46 +00:00
Lars Knoll cfb17c44cf Simplify and unite handling of activation objects in Contexts
All ExecutionContexts (except for CatchContext) have or can have
some sort of activation object. Unify them in one pointer in
the ExecutionContext class, and unify it's handling where it's
actually the same.

Change-Id: I6750999ddbd5d1d74235ef4b34dcd7546c432541
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-07-05 09:05:55 +00:00
Lars Knoll 29e41a9ee6 Remove now unused files
Remove all files from the old compiler pipeline that are now
unused. This includes the whole IR, JIT code generation,
and the old Moth Isel.

Change-Id: I50d06abfbcf0e9755a54ed94638f8bb74f9512b1
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-06-30 11:58:44 +00:00
Erik Verbruggen 2ac3eaee7f Lower the maximum call depth for debug builds
Also merge VME::exec and VME::run together, so there is one less frame
on the stack.

Change-Id: I7268e0b1f16fc75766c0c9b7b5e14b9885e6fe7c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-29 10:20:50 +00:00
Lars Knoll 40e8109cef Don't use the ISel's anymore
Move the code that generates the CompilationUnit over to Codegen,
and don't use the ISel's at all anymore when compiling JS/QML.

Change-Id: Iba89082c386c3d3fd58ac25a4651c5d39178cc5c
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2017-06-22 08:07:21 +00:00
Liang Qi c254cec22a Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	.qmake.conf
	src/qml/jsruntime/qv4argumentsobject.cpp
	src/qml/jsruntime/qv4arraydata.cpp
	src/qml/jsruntime/qv4context.cpp
	src/qml/jsruntime/qv4context_p.h
	src/qml/jsruntime/qv4errorobject.cpp
	src/qml/jsruntime/qv4functionobject.cpp
	src/qml/jsruntime/qv4internalclass.cpp
	src/qml/jsruntime/qv4lookup.cpp
	src/qml/jsruntime/qv4managed.cpp
	src/qml/jsruntime/qv4managed_p.h
	src/qml/jsruntime/qv4object.cpp
	src/qml/jsruntime/qv4object_p.h
	src/qml/jsruntime/qv4qmlcontext.cpp
	src/qml/jsruntime/qv4runtime.cpp
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/memory/qv4heap_p.h
	src/qml/memory/qv4mm.cpp
	src/qml/memory/qv4mm_p.h
	src/qml/memory/qv4mmdefs_p.h
	src/quick/scenegraph/util/qsgdistancefieldutil.cpp
	src/quick/scenegraph/util/qsgdistancefieldutil_p.h
	tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp

Change-Id: I7ed925d4f5d308f872a58ddf51fdce0c8494ec9c
2017-06-06 15:59:38 +02:00
Lars Knoll 8bc243f569 Move the engine() accessor from Object to Managed
We can easily do this now that Managed has a pointer to an
internal class (which always has a back pointer to the
ExecutionEngine).

Remove the extra engine pointer from ExecutionContext, and clean
up tow methods in String.

Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2017-05-19 18:54:54 +00:00
Lars Knoll 5bc38a5030 Get rid of the old way of defining builtin functions
The old calling convention used for builtin functions is very
inefficient. It was still being used in a few places. Clean
those up and convert them to the new and much more effiecient
calling convention.

Change-Id: I6b769c6185df7e9be1e80709330fc1ca868576c1
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2017-05-19 18:54:50 +00:00
Lars Knoll afbb57ae84 Move the prototype into the internal class
This saves another pointer on all Objects.

Currently introduces a slight performance regression
on some of the v8 benchmarks, that needs addressing.

Change-Id: I87de8e1d198d2683f4e903c467ce2a60ba542243
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:29 +00:00
Lars Knoll cae7975a03 Move the internalClass field from Heap::Object to Heap::Base
And do not store the vtable in Heap::Base anymore. This change
makes the internal class the main distinguishing feature
of all garbage collected objects.

It also saves one pointer on all Objects. No measurable
impact on runtime performance.

Change-Id: I040a28b7581b993f1886b5219e279173dfa567e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:26 +00:00
Lars Knoll 70a49fe042 Add ICs for String, MemberData and ArrayData
Change-Id: I43ddcb4842e501cbea8a950ab6ffa2d906014efd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:16 +00:00
Lars Knoll 931239579d Move the list of default internal classes into EngineBase
And store them in an enumerated array. This will simplify
upcoming changes.

Change-Id: I82eac03b9f6264843ae625e36e150464fe08be9d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:13 +00:00
Lars Knoll fa4f49169a Move a few more members from ExecutionEngine to EngineBase
Change-Id: I5d1e0d2251e04cc871f9c298849aafac17f23fbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:07 +00:00
Robin Burchell d27047bd90 QmlContextWrapper -> QQmlContextWrapper
That poor Q looked so lonely.

Change-Id: I29a0aa0574fefa5be8ffaa9857e03500c914c830
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-04 09:31:42 +00:00
Robin Burchell 161d0854ba QmlTypeWrapper: -> QQmlTypeWrapper
That poor Q looked so lonely.

Change-Id: Ie4cef3fa8f2ecb8ba106654e8a9d6611a9407aa2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-04 09:31:37 +00:00
Lars Knoll 7d1b3b2389 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I95266fdaf5c6dc65969bd2e28403da7969367d32
2017-04-22 12:28:37 +02:00
Tasuku Suzuki 85eaae8b4c Fix build without features.qml-interpreter
Change-Id: I5f9c00541c27377e8310d32bf045c2860eeffcb4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-04-21 09:24:17 +00:00
Simon Hausmann 017350a8a9 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/qml/jit/qv4assembler.cpp
	src/qml/jit/qv4assembler_p.h
	src/qml/jit/qv4isel_masm.cpp
	src/qml/jsruntime/qv4vme_moth.cpp

Change-Id: I865d794e550a263387a39ca8d051ebf48b70cbc0
2017-04-07 12:53:23 +00:00
Lars Knoll 589f8a90fa Separate the stack used for GC from the regular JS stack
This is required to be able to implement concurrent or
incremental garbage collection.

Change-Id: Ib3c5eee3779ca2ee08a57cd3961dbcb0537bbb54
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:17 +00:00
Lars Knoll 1e63f7c483 Cleanups
* Only call ExecutionEngine::markObjects() on a full GC, it doesn't do
anything in the incrementall case anyway.
* Move the marking of child objects into it's own method for clarity
* Move collection of gray items down to happen directly before we drain
the mark stack

Change-Id: I41067e17d483067bd1c4d60da22c5628482dae78
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:14 +00:00
Lars Knoll a410cb6901 Remove assertObjectBelongsToEngine method
It's only used during mark() calls, where we can be reasonably
safe that the assertion holds. But mark() needs to change and
become independent of the execution engine for concurrent collection,
so remove the assert as a preparation.

Change-Id: I52266af719afd76048d73efdcfcf96c0abc8843f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:10 +00:00
Simon Hausmann a295dae1bc Fix value type encoding constant usage when cross-compiling
Our two value encodings use different masks for the upper 4 bytes.
Depending on the target architecture we must use different values when
generating code that uses these masks.

This patch replaces the #ifdef'ed ValueTypeInternal_* enum values with
two C++11 scoped enums that allows for the co-existence of both
throughout the code base as well as selective use in the code
generators.

Change-Id: I380c8c28b84df2874cca521b78bfe7f9388ed228
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-30 08:40:39 +00:00
Simon Hausmann 24d0266ee4 Merge remote-tracking branch 'origin/5.9' into HEAD
Conflicts:
	src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
	src/qml/jit/qv4assembler.cpp
	src/qml/jit/qv4assembler_p.h
	src/qml/jit/qv4isel_masm.cpp
	src/qml/jsruntime/qv4context.cpp
	src/qml/jsruntime/qv4context_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/memory/qv4mmdefs_p.h

Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
2017-03-23 14:43:46 +01:00
Simon Hausmann 4db21fe60e Complete transition to standard layout classes for JIT access
Move the Runtime function pointer array into EngineBase so that
we can eliminate the last use of qOffsetOf.

For improved cache locality the memory manager point is now also
located in the EngineBase.

Change-Id: I0b3cf44c726aa4fb8db1206cc414a56c2f522a84
Task-number: QTBUG-58666
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-21 10:38:02 +00:00
Simon Hausmann 7efa1e60d2 Fix running of 32-bit JIT code generated on 64-bit hosts
The offsets of members encoded in JIT generated code differ between
32-bit and 64-bit architectures. This patch moves some of the
ExecutionEngine members into a separate standard-layout EngineBase class
(in line with the same class in commit
2a554434a5 and subject to merging). By
ensuring that the members are stored at pointer intervals, we can
translate from host pointer size to target when generating the code.

Task-number: QTBUG-58666
Change-Id: I1c38a7da059826848b80fd9972ed073214501386
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-17 08:34:57 +00:00
Lars Knoll e772081db1 Incremental garbage collection
Add an incremental mode to the garbage collector, that will
get used for many collections. This should significantly
reduce average stop times for GC.

Make sure that manual calls to gc() still do a full collection,
to ensure consistency and keep tests that rely on gc() working.

Change-Id: I87b13529377b7639ce993dbd99e85ff0a555acd8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:59:23 +00:00
Lars Knoll 2a554434a5 Implement a real write barrier
Implement a Steel write barrier for our objects. The barrier is
interesting as it can also be used for incremental GC runs by
simply turning the barrier on and leaving old objects marked as
black.

Change-Id: I0b273974d94a990dee3cd9298089b8b202c75bf2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:59:20 +00:00
Lars Knoll d7aa952e14 Make writes to ArrayData write-barrier safe
Change-Id: I2e46100fe72fd83b36b3195130eefce5289d1627
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:49 +00:00
Lars Knoll 91714e004e Make all write operations to Pointer<> types go through a set() method
The new set() method also taked an ExecutionEngine pointer. This makes
it trivial to now add a write barrier for those operations.

Change-Id: I321eccfe6fb279cc240b5c84910e6854f71759f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:34 +00:00
Lars Knoll 3a0bb11d73 Separate SimpleCallData and CallData
SimpleCallData doesn't need any loca variables, so
move it into a separate CallData Heap object. This
also allows getting rid of the manual markObjects()
implementation for CallContext.

Change-Id: I9014eb2f815d3e2fe63a951a9d126c38e8aaa0a3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:17 +00:00
Lars Knoll 10c1e40533 Unify mark handling for MemberData and ArrayData
Introduce a ValueArray class, that defines an array of
Values at the end of a Heap Object.

Change-Id: I00efbf6f5839a6687dd5bc5fc037ec8f06e0936e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:15 +00:00
Liang Qi afec9016d0 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I92b13a9c1727644d63e125c1e6f1fdac72720ad7
2017-02-28 13:04:17 +01:00
Ionut Alexandrescu bf1bd3abc9 Add a javascript push method binding to QQmlListProperty
Create a PropertyList prototype, and add the push method to
QQmlListProperty that call the append function if it has been defined.

Added a unit test and updated the documentation.

Change-Id: I2647766e98b60bf0546f6d6ed1422a616e0d3a07
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-21 12:30:30 +00:00
Robin Burchell dd31156c6c NumberObject: Copy parseInt and parseFloat from the global object
Per the spec, these use the same FunctionObject as the global object.

Implements:
    20.1.2.12
    20.1.2.13

For es6 test/built-ins/Number, we go from:
    === Summary ===
     - Ran 490 tests
     - Passed 412 tests (84.1%)
     - Failed 78 tests (15.9%)

to:
    === Summary ===
     - Ran 490 tests
     - Passed 416 tests (84.9%)
     - Failed 74 tests (15.1%)

Change-Id: I7e6f84ef81a429a4bce4895663ad6dc10f389f86
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-03 15:10:29 +00:00
Simon Hausmann 8b7d48d99c Make the JIT ISelFactory a template
That way qmldevtools can - in the future - instantiate that also for the
cross-compilation targets.

Change-Id: If15b195f24e54226dc4f2fd9f0ad6874f44cb5af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-31 18:30:10 +00:00