aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit/qv4assembler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add initial basic support for ES6 modulesSimon Hausmann2018-08-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 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>
* 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>
* Fix remaining failues with qjstest --jitSimon Hausmann2018-06-221-0/+21
| | | | | | | | | | | | | | 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>
* Get rid of the unused JumpEmpty instructionLars Knoll2018-06-211-19/+0
| | | | | Change-Id: I117687939e0f02d801dbad8de7761b4c799f2035 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework unwind handlingLars Knoll2018-06-211-58/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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-231-4/+7
| | | | | | | | | | | | | | | | | | 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>
* | Add instructions to simplify for-of loopsLars Knoll2018-05-131-0/+19
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Rework catch context handlingLars Knoll2018-05-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ES6: add support for default arguments for function parametersLars Knoll2018-04-251-0/+19
|/ | | | | | | | | 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>
* Fix crash with JIT on x86Simon Hausmann2018-04-111-0/+4
| | | | | | | | | | | | The stack must be 16-byte aligned in order for compiler generated alignment requiring SSE instructions to work on the stack. For x86 the stack upon entry is 4 bytes off due to the saved eip. Then another 20 bytes for the saved registers (ebp, eax, ebx, etc.). That means we have to add another 8 bytes to reach the next 16-byte alignment. Change-Id: Ifde49a89224a129f8307fff3713563b80772cff1 Task-number: QTBUG-66773 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Restore the QV4_WRITE_PERF_MAP featureUlf Hermann2018-03-191-6/+41
| | | | | | | | We want to be able to generate perf map files for JITed code. Task-number: QTBUG-67056 Change-Id: I56899e1dbf184083d94efe926d21fca4f9ea1e18 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-2/+2
| | | | | | | | | | | | | 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>
* Optimize inc/dec operationsLars Knoll2018-01-091-24/+63
| | | | | | Change-Id: I3e1fa464e380a40b610bbc339bdbc272ebc863d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-061-11/+2
| | | | | | | | | | | | Remove code for older versions and streamline #ifdefs. Remove the helpers macros Q_STATIC_ASSERT_FOR_SANE_COMPILERS and V4_ASSERT_IS_TRIVIAL. Task-number: QTBUG-40658 Task-number: QTBUG-51673 Change-Id: Ifa4fab653b10ce7858739adef08364cddc6507cf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize cmpEq/NeIntLars Knoll2018-01-031-0/+28
| | | | | Change-Id: I67d3ba6b8bb9c44ba8477c959d389c8a8099aeb2 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize ushr with constant argumentLars Knoll2018-01-021-14/+19
| | | | | Change-Id: I891509269fc8e35c4ad45a2cdce03fc2ace574cd Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize shift operationsLars Knoll2018-01-021-21/+12
| | | | | Change-Id: I32a4382e915217ad36fb4e2a545769586c38b203 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize bitAnd, bitOr and bitXorLars Knoll2018-01-021-14/+83
| | | | | Change-Id: I8e9ea1c26a1bd9c4320d61c2a8d89175a65fe945 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Don't load the JS stack frame pointer twiceLars Knoll2018-01-021-3/+0
| | | | | Change-Id: Ib2eccb825b2acfdc3f850fd15815c1ac894c685f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize generated code for toInt32 and toNumberLars Knoll2018-01-021-1/+27
| | | | | | | Gives some significant speedup for crypto.js Change-Id: Ie5e4922ceae43cc62e1d7fc98de4322d637bddc8 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize JIT generated for for CreateCallContextLars Knoll2018-01-021-0/+21
| | | | | | | | | Added a storeHeapObject() call to the assembler, to ensure we store the pointer returned by newCallContext() correctly on 32 and 64 bit platforms. Change-Id: I2141d5dd3cdd39a9b8886236100e0437159c6fb9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JIT: Inline load(Scoped)Local and store(Scoped)Local instructionsLars Knoll2017-11-301-7/+29
| | | | | | | | Generate inline code for loading and storing (scoped) locals in the JIT. Change-Id: I6eb72126a0a2c6012bf6e73df245c9301bd4c48d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4 JIT: Try not to overdo alignmentErik Verbruggen2017-11-281-8/+2
| | | | | | | | | | | | | The x86_64 assembler will not push a register aligned. The arm64 assembler will. The correct use for pushing constants is not to "prepare" the stack pointer and then push (because that would result in an unaligned value on arm64), but to load the value and do an aligned register push. This fixes a Bus Error on ARM64. Change-Id: I9c9ed643372025f5f7097e7f44ab17adfd0815a9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Add fastpath for integer-to-integer comparissonsErik Verbruggen2017-11-231-15/+14
| | | | | Change-Id: I4831d0b4dda160e43ddbca08b9001611e9cc921d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Add int32 fastpath for inc/decErik Verbruggen2017-11-221-4/+51
| | | | | Change-Id: I276793a2fc4a253e5ec35e7f04a1032f23a03bad Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Add int32 fastpath for add/sub/mul in the JITwip/new-backendErik Verbruggen2017-11-211-34/+81
| | | | | Change-Id: I21b0e31c7c93ae51b4ab406948450e566546e246 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Shorten code by introducing an IntegerTag constantErik Verbruggen2017-11-181-13/+15
| | | | | Change-Id: If8f9bee79def412a16c163099705329a6860f752 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Add a baseline JITErik Verbruggen2017-11-171-0/+1914
| | | | | | | | 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>
* Remove now unused filesLars Knoll2017-06-301-726/+0
| | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-04-071-18/+9
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4assembler.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm.cpp src/qml/jsruntime/qv4vme_moth.cpp Change-Id: I865d794e550a263387a39ca8d051ebf48b70cbc0
| * Fix double conversion code generation when cross-compilingSimon Hausmann2017-04-061-7/+1
| | | | | | | | | | | | | | | | | | We can't use QV4_USE_64_BIT_VALUE_ENCODING for deciding how generate code for checking if the tag of a value contains the necessary mask to detect doubles. Change-Id: Id5a5c1b136313aa4dfd2c997898e97cd4ebaeb83 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Fix loading of strings when cross-compiling from 64-bit host to 32-bitSimon Hausmann2017-04-061-1/+1
| | | | | | | | | | | | | | | | The use of sizeof(Type*) is not allowed when calculating indices into pointer arrays. Change-Id: I5531efc80d0267eaceade76ad2b96d454eab9392 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Fix Clang warning about member in template class not definedThiago Macieira2017-04-031-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | qv4isel_masm.cpp:285:44: warning: instantiation of variable 'QV4::JIT::Assembler<QV4::JIT::AssemblerTargetConfiguration<JSC::MacroAssemblerX86_64, QV4::JIT::TargetOperatingSystemSpecialization::NoOperatingSystemSpecialization>>::Void' required here, but no definition is available [-Wundefined-var-template] Depending on qv4assembler.cpp instantiating the same template that q4isel_masm.pp required is fragile. So move the definition to the header, next to the class. Change-Id: I27b55fdf514247549455fffd14b178ec9d4b508d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Fix encoding of primitive constants when cross-compilingSimon Hausmann2017-03-311-6/+6
| | | | | | | | | | | | | | | | | | | | QV4::Primitive is using host value encoding, which can differ from the target. The source of QV4::Primitive in the code generator is usually IR::Const, transformed via convertToValue(). That function becomes a template that converts to a simple target primitive type. Change-Id: If028aea9551d77d81eec306f60fd995c25b76710 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Fix value type encoding constant usage when cross-compilingSimon Hausmann2017-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our two value encodings use different masks for the upper 4 bytes. Depending on the target architecture we must use different values when generating code that uses these masks. This patch replaces the #ifdef'ed ValueTypeInternal_* enum values with two C++11 scoped enums that allows for the co-existence of both throughout the code base as well as selective use in the code generators. Change-Id: I380c8c28b84df2874cca521b78bfe7f9388ed228 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-301-3/+7
|\| | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4assembler.cpp src/qml/jit/qv4assembler_p.h Change-Id: Ibfe69610ccd1f275f181b2bd87feece4ba221e50
| * Simplify function prologue code in the JITSimon Hausmann2017-03-291-3/+1
| | | | | | | | | | | | | | | | | | We don't have to do a engine->current->engine dance to get hold of the engine pointer, in order to update jsStackTop. We have a dedicated engine register :) Change-Id: I187ea67bf9f3e43b0048dca3cd6ee35f70d8737c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Add support for showing disassembly for cache mapped codeSimon Hausmann2017-03-291-0/+6
| | | | | | | | | | Change-Id: I6199d624a23e2e1b67bcbb841f0bc999880a3993 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into HEADSimon Hausmann2017-03-231-13/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp src/qml/jit/qv4assembler.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4mmdefs_p.h Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
| * Protect CallContext member usage against word size differencesSimon Hausmann2017-03-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | Ensure the offsets we're taking from ExecutionContext members in the JIT code generator can be translated from host architecture sizes to target architecture, using assertions and a memory layout that we already have in the dev branch with commit 4de7e48ab160dacc7a09360e80264eac4945a8f4. Change-Id: I1b26ef265234b05a6e5c8688a8aad2f33cd28783 Task-number: QTBUG-58666 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Protect ExecutionContext member usage against word size differencesSimon Hausmann2017-03-171-6/+10
| | | | | | | | | | | | | | | | | | | | | | Ensure the offsets we're taking from ExecutionContext members in the JIT code generator can be translated from host architecture sizes to target architecture, using assertions and a memory layout that we already have in the dev branch with commit 4de7e48ab160dacc7a09360e80264eac4945a8f4. Task-number: QTBUG-58666 Change-Id: I26cdbd1ddb995b116624fab16f7caba5d21c13b5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Protect CompilationUnit member usage against word size differencesSimon Hausmann2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | Currently we only use the runtimeStrings offset in JIT generated code, so move that into a standard layout base class and use that instead. Task-number: QTBUG-58666 Change-Id: Id933ba5df3a6990e89886c2b328e9e814ec5e413 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Fix running of 32-bit JIT code generated on 64-bit hostsSimon Hausmann2017-03-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The offsets of members encoded in JIT generated code differ between 32-bit and 64-bit architectures. This patch moves some of the ExecutionEngine members into a separate standard-layout EngineBase class (in line with the same class in commit 2a554434a571dcefd26cf10ef8c5ae8b3b7d66db and subject to merging). By ensuring that the members are stored at pointer intervals, we can translate from host pointer size to target when generating the code. Task-number: QTBUG-58666 Change-Id: I1c38a7da059826848b80fd9972ed073214501386 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Implement a real write barrierLars Knoll2017-03-091-9/+13
| | | | | | | | | | | | | | | | | | | | Implement a Steel write barrier for our objects. The barrier is interesting as it can also be used for incremental GC runs by simply turning the barrier on and leaving old objects marked as black. Change-Id: I0b273974d94a990dee3cd9298089b8b202c75bf2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Mark where we need a write barrier in the JITLars Knoll2017-03-091-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Separate the loadAddress calls into loadAddressForReading and loadAddressForWriting. In the second case, add an out argument that specifies whether the write will need a barrier. Pass the write barrier type that is required for a store down into the actual store methods. Change-Id: I3f7634ab82d82f1b20dab331e083d1a662cd314e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>