Commit Graph

483 Commits

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