Commit Graph

504 Commits

Author SHA1 Message Date
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