aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit
Commit message (Collapse)AuthorAgeFilesLines
* V4: Move relative-to-absolute offset calculation to base classErik Verbruggen2019-01-312-11/+26
| | | | | | | Now other subclasses of the BytecodeHandler can also use the method. Change-Id: Ib1a19e5ef6beb6c62b6a0214a6658f57b7e74a1a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Generate labels for backward jumpsErik Verbruggen2019-01-315-28/+35
| | | | | | | | | | | | | | | | | | | | | | | When analyzing the bytecode from top-to-bottom in a single pass, we don't know when a jump back to previously seen code occurs. For example, in the baseline JIT we would already have generated code for some bytecode when we see a jump back (like at the end of a loop body), and we can't go back and insert a label to jump to. As JavaScript has no goto's, the only backward jumps are at the end of loops, so there are very few cases where we need to actually generate labels. This was previously handled by analyzing the bytecode twice: once to collect all jump targets, and then second pass over the bytecode to do the actual JITting (which would use the jump targets to insert labels). We can now do that with one single pass. So the trade-off is to store 4 bytes more per function plus 4 bytes for each loop, instead of having to analyze all functions only to find where all jumps are each time that function is JITted. Change-Id: I3abfcb69f65851a397dbd4a9762ea5e9e57495f6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Collect trace information in the interpreterErik Verbruggen2019-01-256-57/+77
| | | | | | | | | | | | | | | Collect type information about values used in a function. These include all parameters, and the results of many bytecode instructions. For array loads/stores, it also tracks if the access is in-bounds of a SimpleArrayData. Collection is only enabled when the qml-tracing feature is turned on while configuring. In subsequent patches this is used to generated optimized JITted code. Change-Id: I63985c334c3fdc55fca7fb4addfe3e535989aac5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Change assembler dumping to use a logging categoryErik Verbruggen2019-01-111-2/+7
| | | | | | | | This includes removal of the QV4_SHOW_ASM environment variable. Change-Id: Ibbaf7f6eabd1b66e8539bcbcc3febdd79742e003 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2019-01-102-13/+33
|\ | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I6b2539bf17d3e9bc66d96b53c1bce95680113ed8
| * V4: Fix stack alignment in JITted codeErik Verbruggen2019-01-102-13/+33
| | | | | | | | | | | | | | | | | | | | | | Helper calls done for to-integer and to-number conversions did not align the stack on 16byte boundaries, which could lead to crashes if somewhere in that call a vector instruction is used that expects such alignment. Task-number: QTBUG-71325 Change-Id: Ieec05a93a1f69b538e6c8930b8eb64cbe85c35d4 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | V4: Generate function tables on 64bit windowsUlf Hermann2018-12-031-37/+7
|/ | | | | | | | | | | | | | In order for global exception handlers to be called reliably, the runtime needs to unwind through JIT-generated code. This can be facilitated by installing a "function table" for each JITed function that specifies "use the frame pointer". Also make sure to generate a function table for JIT'ed regular expressions. Those were forgotten also in the linux case. Fixes: QTBUG-50061 Change-Id: Ib0b8ae9356ed80afe1cab017e36efa4ccbe73f90 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-11-161-4/+4
|\ | | | | | | Change-Id: I7623438dde316ae1e97802f91991f2e7ccc205a5
| * V4: Fix 32bit moveReg to not use the return value registersErik Verbruggen2018-11-061-4/+4
| | | | | | | | | | | | | | | | | | | | | | As with the 64bit implementation: use the scratch register. The return value register is used to hold the newly allocated space on the JS stack. Fixes: QTBUG-71319 Change-Id: Ia924ad24ff7f4fbf5ec21b6e6237cce7d907bf3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Create proper template objects for tagged templatesLars Knoll2018-11-052-0/+10
|/ | | | | | | | If a tagged template gets evaluated multiple times, the underlying template object is shared. Change-Id: Ie2f476fbc93d5991322ce1087c42719a8d8333ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make sure not to clobber tail call arguments when unrolling stackErik Verbruggen2018-11-011-3/+6
| | | | | | | | | | | | | When the accumulator doesn't overlap the return value registers, we move the accumulator value there when doing a function exit. This happens for arm32 and arm64. This is a problem when doing a tail call: these registers are also used to store the first two arguments for the call, so restorating will wipe them. Task-number: QTBUG-71212 Change-Id: Ifd82729e8741418c1b54e804724893e02bd180c7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Revert "BaselineJIT: slightly improve arm codegen for shifts"Lars Knoll2018-10-151-3/+6
| | | | | | | | | This reverts commit 41e15cb21c2f8924eee56aacc4ba8aace950cae5. The patch causes us to hit assertions in the x86/x64 JIT. Somehow this slipped through CI. Change-Id: Ia77ecb956472172bf5543c01fdccd6dddedba168 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* BaselineJIT: slightly improve arm codegen for shiftsv5.12.0-beta2Erik Verbruggen2018-10-121-6/+3
| | | | | Change-Id: I7327f982d11a0d2942750ebfbc9f0d379093b87e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make the function name printing the same when dumping bytecodeErik Verbruggen2018-10-121-1/+1
| | | | | | | | So searching for "function blah" will find both the dumped bytecode and the generated assembler from the baseline JIT. Change-Id: Ia1e2debfb73068a1692653f304146f7b0f88aa16 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* 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>