aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit
Commit message (Collapse)AuthorAgeFilesLines
* V4: Conform method_objectLiteral arguments to equal other methodsErik Verbruggen2018-10-121-2/+2
| | | | | | | This runtime function was the only one taking argc before arguments. Change-Id: If0b049697f7fcc2746e8d287193a5b1230a6ea56 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* ES7: Implement Tail Position Calls in the runtimeErik Verbruggen2018-10-055-22/+124
| | | | | Change-Id: If1629109722496b3fd10b36b2376548440f2fee9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ES7: Detect Tail Position Calls and pass that to the runtimeErik Verbruggen2018-10-042-0/+14
| | | | | | | Doing the tail call in the runtime will come in a follow-up patch Change-Id: I8224aac0edbdc765ee9b97703948edd52fd33f3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused variable 'EmptyTag'Liang Qi2018-09-271-1/+0
| | | | | Change-Id: I5970e3261a8a0891965c99d4d8c352ebf4cc6681 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-172-6/+6
| | | | | | | | | | | | 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>
* Optimize the JIT helpersLars Knoll2018-09-143-14/+24
| | | | | | | | | Match the argument order to the lookup functions being called to minimize register shuffling that needs to be done inside the function. Change-Id: I0c55234d0c86b524dad021a519c6416d62d34c52 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for yield*Lars Knoll2018-09-072-0/+20
| | | | | Change-Id: I5b054b59519ed825459a5b0b0a7cd2c6fc8a3797 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Throw a type error when trying to destructure null or undefinedLars Knoll2018-09-074-0/+19
| | | | | Change-Id: Id1bba1a729124bccb8a90dcf40252fe5c69d27a3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix exception handling while destructuringLars Knoll2018-09-072-2/+3
| | | | | | | | | | | | | | | When an exception happens during destructuring, IteratorClose needs to be called, unless the exception happened inside the IteratorNext call (in that case the iterator is assumed to be invalid and we shouldn't call close on it). Implement this, by ensuring that we set the done return variable of IteratorNext to true whenever IteratorNext throws an exception. IteratorClose will check the done state and not do anything in that case. Change-Id: I73a27f855f2c4d3134b8cc8980e64bf797d03886 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix thisObject when calling super propertiesLars Knoll2018-08-312-0/+14
| | | | | Change-Id: Ia520d43ea2c29c16cfc8ffc86a32187a78848502 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Add JIT kind to disassemblyErik Verbruggen2018-08-303-4/+4
| | | | | Change-Id: I6dd1cd6f795a93a186e84f5ab1c606f7e23fb85d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Initialize this to empty for derived constructorsLars Knoll2018-08-293-12/+1
| | | | | | | | | As per spec, this should be uninitialized in derived constructors, and the base constructor needs to get called exactly once. Change-Id: If31804e58d7ba62efde8fbf6cd852674f8da4495 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement the dead temporal zoneSimon Hausmann2018-08-284-0/+38
| | | | | | | | | | | | | | With const and let it is possible to access the declared member before initialization. This is expected to throw a type reference error at run-time. We initialize such variables with the empty value when entering their scope and check upon access for that. For locals we place the lexically scoped variables at the end. For register allocated lexical variables we group them into one batch and remember the index/size. Change-Id: Icb493ee0de0525bb682e1bc58981a4dfd33f750e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Split PlatformAssemblerCommon (and base classes) in its own fileErik Verbruggen2018-08-277-1087/+1396
| | | | | | | | This makes it easier to re-use them later on, without inheriting all extra stuff that the baseline JIT needs. Change-Id: I9368b16017b8b9d99f8c005a5b47ec9f9ed09fb0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement IsConstructor for Function objectsLars Knoll2018-08-231-1/+3
| | | | | | | | Use the jsConstruct member in the function object for this and set it to a nullptr for methods that are not a constructor. Change-Id: I63d2971b23b2596a8e3b6d2781f0d9ed3208693b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: clarify current vs. next instruction offset in ByteCodeHandlerErik Verbruggen2018-08-202-10/+13
| | | | | | | | | | | | | | | When executing an interpreter instruction, the code pointer points to the next instruction. However, sometimes a pointer to the current instruction is needed. That was hacked-around by having startInstruction be called before updating the pointer. This is confusing and leads to unexpected off-by-one-instruction cases. So now during startInstruction calls and generate_instructionName calls, there is a currentInstructionOffset() and a nextInstructionOffset() that do what's on the tin in both places. Change-Id: Ie8dd35ff0a7d236f008030ef4c29ec3f31c07349 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add initial basic support for ES6 modulesSimon Hausmann2018-08-094-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The entry point from the parsing perspective into modules is not QV4::Script but QV4::ExecutionEngine::compileModule. For convenience, the ESModule AST node gets a body, which is the statement list connected between the ModuleItemList items that are not import/export declarations. The QV4::Module allocates a call context where the exported variables are stored as named locals. This will also become the module namespace object. The imports in turn is an array of value pointers that point into the locals array of the context of the imported modules. The default module loading in ExecutionEngine assumes the accessibility of module urls via QFile (so local file system or resource). This is what qmljs also uses and QJSEngine as well via public API in the future. The test runner compiles the modules manually and injects them, because they need to be compiled together with the test harness code. The QML type loader will the mechanism for injection in the future for module imports from .qml files. Change-Id: I93be9cfe54c651fdbd08c5e1d22d58f47284e54f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix crash of language/expressions/object/setter-super-prop.js with JITSimon Hausmann2018-08-031-1/+1
| | | | | | | | | | | Generally super.foo = bar calls the storeSuperProperty run-time method, which expects the engine as the first parameter, not the function pointer. Amends commit d31541fd9d7d52ef3eae29e7e5d36733d7f55375 Change-Id: Ic0c933e855066273a635fe62ad88316c75cb8f45 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix language/expressions/class/scope-name-lex-close.js crashing with the JITSimon Hausmann2018-08-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | With a reduced test case like this: var C = 'outside'; var cls = class C { method() { return C; } }; cls.prototype the class expression is expected to return the reference to the class in the accumulator, so that the cls = assignment can store it. Between that we have to deal with the {} block, a ControlFlowBlock instances in the code generator. That one will - among other things - issue a PopContext instruction after the class creation instruction. With the JIT that clobbers the accumulator unfortunately, causing a bogus value being stored in the global object under "cls". Consequently the lookup for "cls" crashes. Change-Id: I6056b352f9d8f42fa65afe4aefcd233c3ccf31ab Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add support for super propertiesLars Knoll2018-07-032-0/+26
| | | | | | | | Those are mostly working now, but when calling super properties the this object is not setup correctly. Change-Id: Ib42129ae6e729eeca00275f707f480371b7e42a5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of the duplication for the GetLookup instructionsLars Knoll2018-07-032-15/+2
| | | | | | | | | GetLookup and GetLookupA were doing exactly the same thing. Only keep the version that expects the base object in the accumulator and rename it to GetLookup. Change-Id: Ia14256880cef23f7b70d8c7e6bb74aba371b8d9a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for super callsLars Knoll2018-07-034-0/+20
| | | | | | | | Implement super call support for class constructor functions. Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the C++ and JS stack frame definitions into it's own fileLars Knoll2018-07-031-0/+1
| | | | | Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a newTarget parameter to the Construct runtime methodsLars Knoll2018-07-031-6/+10
| | | | | | | This is required to be able to support the super() call. Change-Id: I9998680341d701727ac1697187ad33481bdde422 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move JIT helper functions into a reusable namespaceErik Verbruggen2018-06-274-106/+258
| | | | | Change-Id: I61a87f56c3713fbab58ebe5b752e67180cd05a21 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify storeProperty runtime APISimon Hausmann2018-06-271-9/+2
| | | | | | | | We can do the isStrict() check and throwTypeError() call in the runtime function instead of doing it twice on the two call sites. Change-Id: I5689babe4873c0bc3e7c85ca2d15a33f8ccb8794 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify storeElement runtime APISimon Hausmann2018-06-271-9/+2
| | | | | | | | We can do the isStrict() check and throwTypeError() call in the runtime function instead of doing it twice on the two call sites. Change-Id: I70df3d7fe4333921a85c11b1573e234f7da2f47d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add basic support for EcmaScript classesYulong Bai2018-06-262-0/+12
| | | | | | | | | | | | | | | | Most of the class creation is done inside the runtime in the CreateClass method. Added a corresponding instruction to the interpreter and jit. The compiled data now contains an array of classes containing the compile time generated layout of the class. Currently, classes without an explicit constructor and classes with inheritance are not supported. Done-with: Yulong Bai <yulong.bai@qt.io> Change-Id: I0185dcc1e3b0b8f44deff74e44a8262fc646aa9e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix remaining failues with qjstest --jitSimon Hausmann2018-06-223-2/+24
| | | | | | | | | | | | | | The codegen generates code like this for the unwind handling: GetException MoveReg <somereg>, <return value reg> SetException In the interpreter, MoveReg doesn't clobber the accumulator, but in the JIT it did. Change-Id: I7a9c8200468115ca37403ec8a0d511210e2b25fd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Enable perf map writing on all platformsErik Verbruggen2018-06-211-3/+1
| | | | | | | | This is controlled by a environment variable, so the code won't be executed if not explicitly asked for. Change-Id: Iec7be17ae1f21f604064e12f35ffe24be0407760 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add support for function calls with spreadLars Knoll2018-06-212-13/+42
| | | | | | | | | | | 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-212-27/+4
| | | | | | | 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-212-31/+5
| | | | | | | | 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-214-22/+0
| | | | | Change-Id: I117687939e0f02d801dbad8de7761b4c799f2035 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework unwind handlingLars Knoll2018-06-214-74/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-044-8/+8
| | | | | | | | | 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-042-10/+6
| | | | | | | | | | | | | | | | 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/+3
| | | | | Change-Id: I98da5b552747d6d0b363d83ecb4c408c66a2667b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify with context runtime handlingSimon Hausmann2018-05-291-11/+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>
* Rename qv4jit* to qv4baselinejitErik Verbruggen2018-05-283-3/+3
| | | | | | | So it reflects its contents better. Change-Id: Ie9414117a28e681fbb6220c8cddb41be1481fd44 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move bytecode handler into a separate file, so it can be re-usedErik Verbruggen2018-05-282-527/+7
| | | | | Change-Id: I11721025fd3df5efbcc6f6c8cb31fa2f89ead03f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-05-261-2/+1
|\ | | | | | | Change-Id: I626068886d4440b569dbeb1789b1ebfa480000c5
| * Fix build for Android with android-clangLiang Qi2018-05-251-2/+1
| | | | | | | | | | | | | | | | | | | | jit/qv4assembler.cpp:65:11: error: unused variable 'IsIntegerConvertible_Shift' [-Werror,-Wunused-const-variable] const int IsIntegerConvertible_Shift = QV4::Value::IsIntegerConvertible_Shift; ^ Change-Id: I8fd7f03661e9bb7d80c92947cd43841189f148ce Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Simplify Push and PopContext instructionsLars Knoll2018-05-234-23/+22
| | | | | | | | | | | | | | | | | | 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-142-0/+15
| | | | | | | | | | | | | | | | 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-142-3/+3
| | | | | | | | | | | | | | | | | | | | 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-142-0/+15
| | | | | | | | | | | | | | "var [x, ...y] = array" now works as intended. Change-Id: I45238f27f468d0b0e14dc0e931c55c4f40043690 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix array destructuringLars Knoll2018-05-132-3/+4
| | | | | | | | | | | | | | | | 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-134-1/+42
| | | | | | | | | | | | | | | | | | | | | | 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>