aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement Symbol.species getter functionsLars Knoll2018-05-151-0/+4
| | | | | Change-Id: I18b3e382e679f95d7cb53b4ed03be2513ea0204b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Call iterator.return when required in destructuring assignmentsLars Knoll2018-05-141-0/+2
| | | | | | | | 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>
* Add instructions to simplify for-of loopsLars Knoll2018-05-131-0/+5
| | | | | | | | | | | 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>
* Ensure we have a lexical scope for global codeLars Knoll2018-05-111-0/+3
| | | | | | | | | | | | | | | 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>
* Rename ForeachIterator to ForInIteratorLars Knoll2018-05-041-1/+3
| | | | | | | | | 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>
* Add Generator supportLars Knoll2018-05-031-1/+7
| | | | | | | | | | | | | 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>
* Implement StringIteratorLars Knoll2018-05-021-0/+2
| | | | | | | | Add support for String.prototype[Symbol.iterator] and the StringIterator object. Change-Id: I72c4f988e4f363be1af51f9cc5f8e83af43cd151 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for arguments[Symbol.iterator]Lars Knoll2018-05-021-0/+2
| | | | | Change-Id: Ieb60e2d8f41c38146b588bc8cd225a2a567e0956 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Array Iterator objects from ES6 (22.1.5)Robin Burchell2018-05-021-0/+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>
* Remove static localTZA variableLars Knoll2018-05-021-0/+1
| | | | | | | | | This one leads to lots of complaints from thread sanitizers as we're writing to it from multiple threads. Move it into the engine to avoid the noise. Change-Id: I081eeb1de80e623c68fcbd17df1875943c6c019c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add SymbolObject, well known symbols and fix most remaining issuesLars Knoll2018-05-021-0/+29
| | | | | | | | | 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>
* Implement Symbol.for and Symbol.keyForLars Knoll2018-05-021-0/+2
| | | | | Change-Id: I5fde731b3a1a6d7c15154881ed82549b2800d104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Partial Symbol supportLars Knoll2018-05-021-0/+4
| | | | | | | | | 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>
* Garbage collect identifiersLars Knoll2018-05-021-5/+0
| | | | | | | | | | | | | | | | | | | | | 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>
* Use Identifier by value and don't new them anymoreLars Knoll2018-05-021-2/+2
| | | | | Change-Id: Ib25c08027013217657beb2675dafa9a8c85cbaf9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Turn Identifier into a simple integerLars Knoll2018-05-021-0/+5
| | | | | | | | | | Add a reverse mapping table to the IdentifierHash to avoid having to store a hash value inside the identifier. This makes it possible to then use the identifiers value based and not new them on the heap anymore. Change-Id: If1f177588ea104565c6e3add49c70534a6c7dcb8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Reorganize Lookup data structure to make marking fasterLars Knoll2018-04-121-2/+3
| | | | | | | | | | Do this by always using odd numbers for protoId's, and putting those into the same place as the InternalClass pointers. That makes it possible to quickly check whether the lookup contains a pointer to a valid heap object. Change-Id: I330017b26c090b4dcbbcce1a127dca7ba7e148d1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* garbage collect InternalClassLars Knoll2018-04-121-4/+4
| | | | | | | | | | | | | | | | 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>
* Clean up Engine::newObject/newArrayObjectLars Knoll2018-04-121-2/+2
| | | | | | | They don't need a prototype argument neither anymore. Change-Id: I80fa99cb382e8dca4cfa51fdd87b4c9b0f59573a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove the pool allocator from InternalClassLars Knoll2018-04-121-2/+0
| | | | | | | | Makes it easier to transition it over to be controlled by the GC. Change-Id: I6bea738b3852abfc7870b71e639efc595eeb28fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-171-1/+0
|\ | | | | | | Change-Id: I2e3ba907a6afcaa69354a894259c7b7accf3e3ac
| * Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-02-271-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | 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
| * use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-221-4/+4
|\| | | | | | | Change-Id: I8cca650fbb1904ecba59da909a08dba3cc574add
| * WinRT: Do not call canAllocateExecutableMemory from static initializerOliver Wolff2018-02-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-131-2/+9
|\| | | | | | | Change-Id: Ib297817e2fd9b6790d9bc8ee522c32f5b3422574
| * Fix crashes on WinRT when allocation of executable memory is disabledSimon Hausmann2018-02-091-2/+9
| | | | | | | | | | | | | | | | | | | | This regressed in commit b56f7d6f79b0de73c405b1503bfeb71ef5caf58f. 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>
* | QML: Make mapping of sequence object in JS optionalUlf Hermann2018-02-111-0/+4
| | | | | | | | | | | | | | | | | | 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>
* | Don't crash if v8Engine is a nullptrLars Knoll2018-02-101-1/+1
| | | | | | | | | | | | | | This at least happens in qmljs. Change-Id: Ie5617b7ef5790d178c06c7bf2329620d0c185b88 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Change creation of new internal classesLars Knoll2018-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Remove InternalClass forward declarationsLars Knoll2018-02-091-1/+0
| | | | | | | | | | | | | | qv4global_p.h has it already. Change-Id: I7c2526873d1176d62a03708d8159546c65344cd2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Further simplify relation between different enginesUlf Hermann2018-02-071-3/+4
|/ | | | | | | The only engine we ever ask for QJSEngine is QV4::ExecutionEngine. Change-Id: Ia1354e552bddac72177b7aa62de5a7a502089841 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove double indirection between QJSEngine and QV4::ExecutionEngineUlf Hermann2018-02-021-0/+2
| | | | | | | | 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>
* V4 JIT: Fix JIT thresholdErik Verbruggen2018-01-171-1/+1
| | | | | | | | | Because increments for the interpreter call counts are done after checking the threshold, the check has to be greater or equal. Otherwise this will be an off-by-one. Change-Id: Iebe6c5770512e58ff5af8170dd33ec850b054966 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Only start JITting after a minimum of 3 callsErik Verbruggen2017-12-141-1/+13
| | | | | | Change-Id: I748e06041f3085980ce48391ba2d829a9d86a727 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a unique id to InternalClass that describes it's total stateLars Knoll2017-11-271-0/+4
| | | | | | | | | | | | | | | So far the InternalClass only did describe the state of the class itself, but it wouldn't change if some of the underlying objects in the prototype chain changed. This now fixes that and introduces a unique ID that completely describes the state of the object including all it's prototypes. This opens up for optimizing lookups down to one branch and a load, independent of the depth of the value inside the prototype chain. Change-Id: I0787e0e4710f2f6703b1d5e35996124b3db2d2da Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/wip/new-backend' into devSimon Hausmann2017-11-211-79/+40
|\ | | | | | | | | | | | | | | | | | | | | 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
| * V4: Add a baseline JITErik Verbruggen2017-11-171-1/+3
| | | | | | | | | | | | | | | | 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>
| * Clean up ArgumentsObject handlingLars Knoll2017-11-141-0/+2
| | | | | | | | | | | | | | Introduce a proper strict arguments object. Change-Id: Ie4e7f904b3a0e03893b18b3c6709f4f25dbc1030 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Bring back markObjects(), this time generatedLars Knoll2017-11-141-29/+0
| | | | | | | | | | | | | | | | Doing the marking of objects in a function instead of using the table seems to be somewhat faster. Change-Id: I9ec00cc0264f9a15c69b285db493bee31d99bf96 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Merge remote-tracking branch 'origin/dev' into new-backendLars Knoll2017-11-081-1/+4
| |\ | | | | | | | | | Change-Id: I1a49b4a242ed0764101521d06ec612e96bff0e4c
| * | Move a couple of data members required for new JITLars Knoll2017-11-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Mark CompilationUnit final and get rid of it's vtable. Fix initializations with 0 instead of nullptr. Change-Id: Ieec260bd45d8f08cf5d8964becd312b221cbb2a9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * | Merge remote-tracking branch 'origin/dev' into HEADLars Knoll2017-10-221-5/+5
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | Unify JSStackFrame and CallDataLars Knoll2017-09-011-17/+1
| | | | | | | | | | | | | | | | | | | | Change-Id: I4494dae8166026074c9efc74bac62de9d3fa2342 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * | | Move line number information into a side tableLars Knoll2017-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | Cleanup naming of Stack frame structuresLars Knoll2017-08-101-14/+40
| | | | | | | | | | | | | | | | | | | | Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * | | Refactor context handlingLars Knoll2017-08-101-37/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | | Change function signatures for call/construct backLars Knoll2017-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>