aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4vme_moth.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add run time assertion for local handlingSimon Hausmann2018-06-231-0/+2
| | | | | | | | | | | | Commit f44782d0cdbdb800d9c31d5aff712fbf29d52edc fixed the missing call context creation that would lead to language/statements/break/S12.8_A2.js failing. It wouldn't always fail as the invalid cast from the global context to a call context would access memory that happens to be available just for the test. An assertion however will not require us to rely on memory setup. Change-Id: I131a2242004cd5e4d518e58cc9f6a79037f962d2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix language/expressions/equals/coerce-symbol-to-prim-return-prim.js with JITSimon Hausmann2018-06-221-118/+2
| | | | | | | | | Use the same method for comparing values for the JIT as well as the interpreter, so that the test passes with interpreter as well as the JIT. Change-Id: I2e0249d8e915c816a64adc922839cb71f0e065db Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Improve GC safety of compare functionSimon Hausmann2018-06-221-5/+32
| | | | | | | | | When comparing values we may end up calling user-defined conversion functions, which in turn may accidentally end up triggering the GC. So any intermediate managed values we fetch, we must save on the JS stack. Change-Id: I810a46f740f22f8fd71a83ed362301cfc822190d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add support for function calls with spreadLars Knoll2018-06-211-6/+18
| | | | | | | | | | | Function calls with thread are modelled by pushing an empty value in front of every argument that requires spreading. The runtime methods callWithSpread and constructWithSpread then take care of spreading out the arguments. Change-Id: Ie877c59d3d9d08fc5f20d7befb7153c7b716bf30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of LoadElement and LoadProperty instruction overloadsLars Knoll2018-06-211-14/+2
| | | | | | | Always use the overload where the value is in the accumulator. Change-Id: I6a3d81fea7aae957e0cf6efd123d7739f8880c95 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify DeleteMember and DeleteSubscript instructionsLars Knoll2018-06-211-16/+3
| | | | | | | | The delete operator is rarely used, so it's simpler to unify these into one DeleteProperty instruction. Change-Id: I8c0d4455b35efb03db2ab0010df70030d774a6ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of the unused JumpEmpty instructionLars Knoll2018-06-211-5/+0
| | | | | Change-Id: I117687939e0f02d801dbad8de7761b4c799f2035 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework unwind handlingLars Knoll2018-06-211-26/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old code was rather convoluted and expanded to quite a bit of bytecode. It was also very hard to fix some of the remaining issues with unwinding in there. The new code handles unwinding a bit differently. Basically, we now have three instructions to do what the spec requires. SetUnwindHandler is the same as the old SetExceptionHandler instruction. It basically tells the runtime where to jump to to handle any abrupt completion (ie. throw/break/continue/return) that requires unwinding. UnwindToLabel is a new instruction that is used for unwinding break/continue/return statements. It takes two arguments, one telling the runtime how many levels to unwind and the second a target label to jump to when unwinding is done. UnwindDispatch is the third instruction and is invoked at the end of each unwind block to dispatch the the parent unwind handler if required and thus implement the support for the levelled unwinding. Change-Id: I079a39d0d897b3ecc2f0dc631ca29b25eae05250 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename SetExceptionHandler to SetUnwindHandlerLars Knoll2018-06-041-2/+2
| | | | | | | | | It's being used for more than just exception handling, unwinding for return or break/continue statements also goes through those handlers. Change-Id: I145c7909540a1adca431de6a98d9c115ddf23612 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix creation of object literalsLars Knoll2018-06-041-1/+1
| | | | | | | | | | | | | | | | Our method to create object literals wasn't compliant with the ES7 spec, as we would in some cases re-order the properties. This violated the spec which required properties to be created in order, so that for-of would also iterate over them in creation order. As a nice side effect, this simplifies the code and gets a couple of test cases using computed property names to pass. Task-number: QTBUG-62512 Change-Id: I6dfe004357c5d46a0890027f4fd9e2d1e1a2a17a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix remaining test failures with the ** operatorLars Knoll2018-06-041-1/+4
| | | | | Change-Id: I98da5b552747d6d0b363d83ecb4c408c66a2667b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify with context runtime handlingSimon Hausmann2018-05-291-3/+2
| | | | | | | | Instead of duplicating the accumulator-to-object conversion in moth as well as the JIT, let's do that in one place in the runtime. Change-Id: I6870567d3c4fe663e54fece024f1e5e9bde97c35 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Minor cleanup with bytecode pointer typesSimon Hausmann2018-05-281-1/+1
| | | | | | | | | | | | Even though we consider the bytecode to be a sequence of unsigned bytes, we store it as const char * (so unsigned except on arm) everywhere, because that makes it convenient to work with QByteArray's constData(). By using const char * consistently we can get rid of at least one more reinterpret_cast. Change-Id: I7a803e4201381c39eec2fdc6497d9bf36a1c2b6b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement toPrimitive() the way the ES7 spec wants itLars Knoll2018-05-281-5/+5
| | | | | | | | 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>
* Rename qv4jit* to qv4baselinejitErik Verbruggen2018-05-281-1/+1
| | | | | | | So it reflects its contents better. Change-Id: Ie9414117a28e681fbb6220c8cddb41be1481fd44 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify Push and PopContext instructionsLars Knoll2018-05-231-4/+2
| | | | | | | | | There's no need for a temp register to store the old context in, as PopContext can simply retrieve the old context from the current one. Change-Id: Ife9cfdff7fa8e47fc71e844a7798de88dbc79e26 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Call iterator.return when required in destructuring assignmentsLars Knoll2018-05-141-0/+6
| | | | | | | | 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>
* Refactor InteratorNext instructionLars Knoll2018-05-141-1/+1
| | | | | | | | | | The instruction now writes the value into a stack slot, and returns the done state in the accumulator. This should make it easier to implement the IteratorClose functionality required by the spec. Change-Id: I8cc497c54b0d044bd3c68a5a1b774eea8b2740ef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for destructuring of rest elementsLars Knoll2018-05-141-0/+6
| | | | | | | "var [x, ...y] = array" now works as intended. Change-Id: I45238f27f468d0b0e14dc0e931c55c4f40043690 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix array destructuringLars Knoll2018-05-131-1/+1
| | | | | | | | Array destructuring should use iterator objects, not integer indexes. Change-Id: I769bb1d63246da6bc45233f7a6e9a8e5ddc53a4d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add instructions to simplify for-of loopsLars Knoll2018-05-131-0/+11
| | | | | | | | | | | 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>
* Give for loops a per-iteration context as wellLars Knoll2018-05-111-0/+7
| | | | | | | | Regular for loops also have a per iteration context for lexically declared variables as well. Change-Id: I35cb58bfb198c7dc32d70f41ea0ced7ddefcc37e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Ensure we have a lexical scope for global codeLars Knoll2018-05-111-3/+11
| | | | | | | | | | | | | | | 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>
* Add some basic support for for-of loopsLars Knoll2018-05-091-9/+3
| | | | | | | | | | | | | The support is basically at the same level as for for-in at the moment. Currently unimplemented: * Destructuring * Proper lexical scoping * calling iterator.throw()/return() when required Change-Id: If193ce0b054c4315fc16b7e174334a31b2730dcf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Generator supportLars Knoll2018-05-031-5/+25
| | | | | | | | | | | | | 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>
* Move interpreter loop into it's own functionLars Knoll2018-05-021-19/+24
| | | | | | | This will be required to make Generators work properly Change-Id: I1262d8694674ea3436f496fae30668a939327ab7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make instanceOf compliant with the ES7 specLars Knoll2018-05-021-8/+2
| | | | | | | | Add implementation for Function.prototype[Symbol.hasInstance] and call it when defined. Change-Id: Iad6b0c075452b46ba710ffe7b94b74b71f715d22 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework catch context handlingLars Knoll2018-05-021-1/+1
| | | | | | | | | | | | 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>
* Add support for proper lexical scopingLars Knoll2018-05-021-0/+6
| | | | | | | | | | | | | This is still to some extend work in progress as lexically scoped for loops won't yet do the right thing. let and const variables are still accessible before they are declared, and the global scope doesn't yet have a proper context for lexically declared variables. Change-Id: Ie39f74a8fccdaead437fbf07f9fc228a444c26ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-04-271-37/+37
|\ | | | | | | Change-Id: I280d42b8926c0cada1f35d322b80aaf2b0ef0a73
| * Fix JIT build on INTEGRITY ARM64Kimmo Ollila2018-04-261-37/+37
| | | | | | | | | | | | | | | | | | | | | | -typedef "Jump" may not be used in an elaborated type specifier -explicit specialization of function must precede its first use -"Value" is ambiguous Change-Id: Ic15c196f1b33211cd3f2f25a54ba478747336fe4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Nikola Velinov <nvelinov@ghs.com>
* | Implement support for the ** and **= operatorsLars Knoll2018-04-261-0/+7
| | | | | | | | | | Change-Id: I58a21e70fdd040175b52465d6ba52e7fceaf6398 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix some bugs in binding destructuringLars Knoll2018-04-261-0/+5
| | | | | | | | | | Change-Id: I4b18a88e443f3b263cbb1e2b5ca1ebbd353afa98 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add support for ES6 rest parametersLars Knoll2018-04-251-0/+4
| | | | | | | | | | | | | | function foo(a, b, ...c) {...} now works correctly. Change-Id: Ie442a0e7cc5e9dc4156e56b348bba305cced8531 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | ES6: add support for default arguments for function parametersLars Knoll2018-04-251-0/+5
| | | | | | | | | | | | | | | | | | The parser can also handle rest parameters correctly, this will however require some additional work in the runtime to support it correctly. Change-Id: Ib6f4d27683774966b2d2aac075494d2f5066d2a2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove dependency from qv4heap_p.h onto qv4internalclass_p.hLars Knoll2018-04-121-5/+5
|/ | | | | | | | This is required to be able to turn the internal class into something that lives on the GC heap. Change-Id: Ie4318588d420743b1e1ab1cd596a1c9d153eb793 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-161-4/+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>
* 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>
* Correctly set this object when calling scope/context functionsErik Verbruggen2018-02-201-0/+12
| | | | | | | | | | | | | When a function is called that is in a QML scope or a QML context, set the 'this' object to the QML scope. This is done by introducing two new interpreter instructions, which get the context passed in. Note: this patch is 5.11 specific. 5.9 had a similair issue, but the implementation is quite different, so that was fixed separately. Task-number: QTBUG-66432 Change-Id: Ie43150cdd26360025895df28d31264985abf1c15 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a couple of places where we'd free used objectsLars Knoll2018-01-261-2/+3
| | | | | | | | Make sure all our JS objects are referenced from the JS stack before calling into the memory manager. Change-Id: I88d622d37b9d6cfc19db4045ebd3fadc5bb4cabe Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disentangle include dependencies around the write barrierLars Knoll2018-01-191-2/+2
| | | | | | | The write barrier header should have minimal dependencies. Change-Id: I071718c2fafe5020d1093ca3b363844f7a9b7b35 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix build without QML debuggingUlf Hermann2018-01-161-2/+2
| | | | | Change-Id: Ie1b18dd00705b1913572b87c6968a63438e7a90c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix ASAN stack-use-after-scope error in CmpInstanceOf instructionSimon Hausmann2018-01-071-3/+2
| | | | | | | | | | | | | This is triggered by tst_qqmlecmascript::sequenceConversionThreads(). The call to fromReturnedValue(acc) creates a temporary value and the as() cast call returns a pointer to the temp. That becomes a dangling pointer when the temp goes out of scope. Duplicating the fromReturnedValue() avoids this and at least gcc is clever enough to collapse the isObject() code for both uses. Change-Id: I741206b0c10d16fcc4ffdf68532a721f74c1b0dc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Only start JITting after a minimum of 3 callsErik Verbruggen2017-12-141-4/+4
| | | | | | Change-Id: I748e06041f3085980ce48391ba2d829a9d86a727 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Change CallValue to have the value on the stackErik Verbruggen2017-11-231-2/+1
| | | | | | | | | | | | | | | We used to store the value-to-be-called in the accumulator. So the generated bytecode looked like: LoadReg r1 CallValue() The first thing done in CallValue is to store the accumulator. So by not loading the accumulator, we can actually remove the subsequent store, which results in less interpreter instructions and one less store in CallValue. Change-Id: Icc7c8a5449bf369b9226d66bc6055cb705ef660e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Collapse LoadRegExp+StoreReg into MoveRegExpErik Verbruggen2017-11-231-3/+3
| | | | | | | | LoadRegExp is nearly always followed by a store of the accumulator, so change LoadRegExp to be MoveRegExp. This saves an instruction. Change-Id: I5d47c5bf6ffd7f28247c328410872c3b229ca23c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/wip/new-backend' into devSimon Hausmann2017-11-211-517/+919
|\ | | | | | | | | | | | | | | | | | | | | 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-7/+26
| | | | | | | | | | | | | | | | 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>
| * Don't copy unnamed arguments onto the JS stackLars Knoll2017-11-151-3/+4
| | | | | | | | | | | | | | | | | | These can only be referenced through the arguments objects, and have so far messed up initialization of local variables. Change-Id: I3100520ed55c93204dd7953da8cc3d2b7d200d11 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * V4: Tweak JumpTrue/JumpFalse interpreter instructionsErik Verbruggen2017-11-141-8/+14
| | | | | | | | | | | | | | | | | | For JumpTrue, when the accumulator held false/0, the Value::toBoolean method would be called even though the value was already a boolean. The same for JumpFalse and a true value. Change-Id: I0d0e8b9d090dcd4fb69ec9df4f60ed37cfce32ba Reviewed-by: Lars Knoll <lars.knoll@qt.io>