summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4isel_moth.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove now unused filesLars Knoll2017-06-301-1451/+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>
* Remove interpreter instructions we can't generate anymoreErik Verbruggen2017-06-301-41/+41
| | | | | | | This includes the backing runtime methods. Change-Id: Ib8fb6091974794b11f732fadeb047a7347a50d66 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix compilation failuresErik Verbruggen2017-06-291-5/+5
| | | | | Change-Id: I17e53bdc92ea56823b7868b443cccd276c812ff4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Switch over to new JS call setupLars Knoll2017-06-291-6/+6
| | | | | | | | | | | | | | | | Differences: - push parameters on the stack, including space for CallData members - call instructions calculate the argument start - use temp space above the calldata to evaluate arguments - fewer temporaries are needed when a call is done while generating the arguments of another call - when calling the function, the js stack space above the callData is not used, allowing for optimizations in the future - Array and ObjectLiteral use the same mechanism Change-Id: Id100fa06f12cc9d941b0f90b0b81b8270a8e4f5d Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename push instruction to InitStackFrameErik Verbruggen2017-06-291-3/+3
| | | | | Change-Id: I67f8397686a439cede37b52863d32dc194bee23f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove MoveConst and put constants in ParamErik Verbruggen2017-06-291-25/+32
| | | | | Change-Id: I7a289dff5cacc23c238e79e44eb96c690691da3b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Various compile fixesLars Knoll2017-06-221-0/+7
| | | | | | | | Make sure all libs and tests compile again after the latest changes. Change-Id: I749d3d2d0109cc97df2ecec93809ea8a1b3014a9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Move the Moth CompilationUnit into it's own fileLars Knoll2017-06-221-100/+0
| | | | | Change-Id: I8d2dc724d705360c413f9ac75535970e295d1b39 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add support for post increment/decrementErik Verbruggen2017-06-211-4/+4
| | | | | Change-Id: Ie3f03a548105fe49d29e3d60bf823435f21b0340 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Support object literalsErik Verbruggen2017-06-201-2/+5
| | | | | Change-Id: I7fc4565044caf23bec239561be4fbc020ccc2468 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add bytecode dumperLars Knoll2017-06-191-0/+3
| | | | | Change-Id: Ifd63cf604e66f46329472f82a46d37194a1b39eb Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Use the IR::Function::code memberLars Knoll2017-06-191-2/+5
| | | | | | | | | | if it's not empty, we assume the codegen filled it already, and leave it alone. Otherwise use the moth isel to fill it. And remove the hash of codeRefs in the Moth isel. Change-Id: Ib498e44b214228e6d03fef6f85c70b62ba1b89b2 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimizations to the generated byte codeLars Knoll2017-05-191-55/+0
| | | | | | | | | | | | | | | | | | | Cut the size of the generated byte code in half, by storing parameters in a more compact form and always storing the instruction type in the instruction. We can still used computed goto's for a fast interpreter, by looking up the jump point for the next instruction in the jump table. Another advantage is that the byte code is now platform independent (modulo endianness). The change comes with a 3% performance impact on x86_64, which is acceptable considering the size savings on the bytecode. Change-Id: I37de3e1f94611987a85e65ea86536583aa965d6d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize Runtime::method_get/setElementLars Knoll2017-05-101-2/+2
| | | | | | | | | | | | | This is now actually just as fast as the lookup code, so disable the generation of lookups for indexed accesses for now. This saves some runtime memory, as we don't need the data structures for the lookup. We can reintroduce lookups, once they offer a real performance benefit. Change-Id: Idc3fa7b248e2e25b4b2cd60d5053e2815634c8b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prepare run-time method calling mechanism for cross-compilationSimon Hausmann2017-03-171-37/+38
| | | | | | | | | | | | | | | | | | | The current way of encoding the offsetof() of the method_ members in QV4::Runtime is not portable when cross-compiling from a 64-bit host (where the offsetof would be calculated on) to a 32-bit target (where the offset would be different), or vice versa. In preparation for making this work, this patch first replaces the direct use of the run-time members with use through a void * and an enum for indexing. This gives us some type-safety in some places and will also allow for a translation of the pointer offset from host pointer indexing to target pointer indexes. As a bonus we can avoid going through the engine->runtime indirection in the interpreter altogether and call the static methods right away. Task-number: QTBUG-58666 Change-Id: I3cd6459523923a9719408317fa729bca19c2bf3c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtQml: Fix developer build with MinGW-W64 / gcc 5.3.0Friedemann Kleint2017-01-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assign QJsonPrivate::qle_bitfield<>.val directly to initialize it instead of using the assignment operator in classes aggregating it, fixing errors: qtbase/src/corelib/json/qjson_p.h: In member function 'uint QV4::Compiler::JSUnitGenerator::registerIndexedGetterLookup()': qtbase/src/corelib/json/qjson_p.h:187:35: error: 'l.QJsonPrivate::qle_bitfield<0, 4>::val' is used uninitialized in this function [-Werror=uninitialized] uint i = qFromLittleEndian(val); ^ compiler\qv4compiler.cpp:110:26: note: 'l' was declared here CompiledData::Lookup l; Disable -Wuninitialized in QV4::Moth::InstructionSelection::callBuiltinConvertThisToObject() and callBuiltinPopScope(), fixing errors: In member function 'virtual void QV4::Moth::InstructionSelection::callBuiltinPopScope()': compiler\qv4isel_moth.cpp:1188:38: error: '*((void*)& call +4)' is used uninitialized in this function [-Werror=uninitialized] Instruction::CallBuiltinPopScope call; ^ compiler\qv4isel_moth.cpp: In member function 'virtual void QV4::Moth::InstructionSelection::callBuiltinConvertThisToObject()': compiler\qv4isel_moth.cpp:1338:49: error: '*((void*)& call +4)' is used uninitialized in this function [-Werror=uninitialized] Instruction::CallBuiltinConvertThisToObject call; Task-number: QTBUG-58476 Change-Id: I3448cd8b75e9588ffb1bcc1526a56450731f1744 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Include the interpreter codegen and QML cache saving code in qmldevtoolsSimon Hausmann2017-01-281-30/+34
| | | | | Change-Id: Ic3f1476b87bfa7ab0c280c928e9ac97f92698336 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-251-0/+5
|\ | | | | | | | | | | | | Conflicts: tools/qmlimportscanner/main.cpp Change-Id: I01e17581f6691a03f83788773364d0cf96319514
| * V4 Interpreter: reset the exception handler for every catch blockErik Verbruggen2016-12-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If an exception handler consists of multiple basic-blocks, and is then followed by a finally block (for example: a catch block with a throw followed by a return, and then a subsequent finally block), then the finally block can be reached before the exception handler is reset by skipping the second block of the catch handler with a throw. As the finally block will then rethrow, and the old exception handler is still there, it will end in an endless loop. The fix is to reset the exception handler for every catch block. The problem occurred in ch12/12.14/S12.14_A13_T3 Change-Id: I968b62c6c2af30af32e2717a9ce85f852523dbe8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devJ-P Nurmi2016-11-031-2/+35
|\ \ | |/ | | | | | | | | | | Conflicts: tools/qmljs/qmljs.cpp Change-Id: Ifa9e74bdb780eaff22fbc9ba1c514d0078a3fb29
| * Add the ability to explicitly enable the code cache in qmljsSimon Hausmann2016-10-231-2/+35
| | | | | | | | | | | | | | | | | | | | | | This also requires mapping the label pointers in the byte code back to the instruction enum. Fortunately this reverse mapping is only needed in the qmljs case. Normally in the QML engine we persist the byte-code to disk before linking the compilation unit to the engine (where we map the enum to goto labels). Change-Id: If0b79288274bb1031161841b63a85f164502aaec Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-09-211-1/+3
|\ \ | |/ | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth_p.h Change-Id: I8e86a649d1ef8ad27dc66cc8c290093b2faabc69
| * Fix binding dependencies when used in together with functionsSimon Hausmann2016-08-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | When a function called from a binding would access a scope or context property, we would end up registering those dependencies as permanent dependencies in the expression and set m_permanentDependenciesRegistered to true. Then after the binding evaluation itself, we would not end up registering the real binding's permanent dependencies. Change-Id: I3b6c1c181aa064d535362c736b5b2bbc4f576ba9 Done-with: Erik Task-number: QTBUG-54394 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Qml compiler: replace 'foreach' with 'range for'Anton Kudryavtsev2016-09-091-1/+1
| | | | | | | | | | | | | | ... and with 'index-based for' in one place. Change-Id: I4df75bd5921f9ee8b5744067adbaafbc46452f87 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | V4: Replace a QSet with a QVector in calculateOptionalJumpsErik Verbruggen2016-08-231-2/+2
|/ | | | | | | | | | | | | | Instead of storing a bunch of statement IDs in a QSet, the parent basic block of the terminator statement (specifically: the jump) is used as an index into a bit vector. If the bit is set, this indicates that the jump can be omitted. This reduces the number of allocations from 1 hash node per optional jump, to 1 per function. The allocation will also be smaller then a hash node. Change-Id: Ia34468534b96dd9cefa837523bf89ad233de92e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-171-162/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4ssa_p.h src/qml/qml/qqmlobjectcreator.cpp Change-Id: I8bb7fe773d657f908f20ee5e72c2b9bd643f6260
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-131-162/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4ssa_p.h tests/benchmarks/qml/qqmlimage/qqmlimage.pro tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp Change-Id: Iad11ce7fdf0c6d200fdebc16a94081bd8069a87a
| | * Move the moth stack slot allocator into qmldevtoolsSimon Hausmann2016-08-121-162/+1
| | | | | | | | | | | | | | | | | | | | | This way it's accessible to the QML compiler. Change-Id: I3918a796c698fc75e134b29a61eed2ec028bc851 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Use on-disk compilation unit if availableSimon Hausmann2016-08-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we succeeded in saving the compilation unit to disk, then attempt to use it right away. This replaces the C++ heap usage for the compilation unit data as well as the anonymous allocated executable memory with file-backed mmap'ed memory. That means the memory can be discarded when overall availability is low and paged in on-demand. Change-Id: Ide1b1e11752d861eb049a99a26ca12cec5e2502e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | V4: Leave out Debug and Line istructions on -no-qml-debugUlf Hermann2016-07-281-16/+17
| | | | | | | | | | | | | | | Change-Id: Ida861af5636a1605783f7af4bf88cb46b44f9022 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Improve robustness of qml disk cachingSimon Hausmann2016-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Perform various basic checks before proceeding to load an existing cache file, including the qt version, architecture, data structure version and others. Change-Id: Ie822b056e944ac120643aad260e97f62616688bf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add support for saving/loading the moth interpreter byte codeSimon Hausmann2016-07-211-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | With the JIT and moth supporting persistence, we can enable the disk cache tests unconditionally. Change-Id: I6d6652411237001433a32a2de21d1f78f51b43ef Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Prepare moth bytecode for serializationSimon Hausmann2016-07-211-5/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | When using the threaded interpreter, don't produce the instruction handler addresses right away but perform that as a separate step when linking against the engine. Change-Id: I216100f8b99f45eb8d954c733ac128e83aa6da38 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Added basic loading of compilation units from diskSimon Hausmann2016-07-191-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This remains hidden behind the QML_DISK_CACHE flag until all backends support it and the verification code is in place. Change-Id: Ic77c64e20a2dc4c43473c47640e09f8070237e85 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Revert "QML: When available, use QQmlAccessors to read properties."Simon Hausmann2016-07-141-100/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f6fee09942de7901a708c4e16db0c7c82550e8c5. The accessor pointers were embedded in the generated machine/byte code, which makes it non-relocatable. As discussed, for the moment the ability to have relocatable code is prioritized. But the goal is to re-enable accessor accelerated property access through lookups. Change-Id: I18ec9ce31901c1fae3e58ac0c41bc87791e8c380 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | V4: Change uses of StmtVisitor/ExprVisitor to use new style visitors.Erik Verbruggen2016-06-081-3/+3
| | | | | | | | | | | | | | | Change-Id: I668c829bf04e0e16ed94db169507cc5290deec50 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | QML: When available, use QQmlAccessors to read properties.Erik Verbruggen2016-04-121-4/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a property is read from a QObject or the QML scope object, and we can statically resolve the type to qreal/QObject/int/bool/QString, and the property has an accessor declared for it, then use that accessor to do the read. This collapses the path of e.g.: Runtime::getQmlScopeObjectProperty -> QObjectWrapper::getProperty -> QObjectWrapper::getProperty -> LoadProperty -> QQmlAccessor::read (all of which do various checks for all the stuff mentioned above) to: Runtime::accessQmlScopeObjectQRealProperty -> QQmlAccessor::read which is a simple 4-line function, and doesn't need to do any check. According to valgrind, this saves 170 instructions on x86 for the simple binding: Item { width: height } Change-Id: I0761d01e8f1a3c13ecbffe2d8e0317ce9c0a4db0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Make the moth representation relocatableLars Knoll2016-04-111-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove direct use of function pointers in the instructions, and instead index into the array of runtime methods. This requires some rather ugly casting to retrieve the method. Change-Id: I5dee8b49dbd7adbfb89a9cc33cbbda8fa53325ce Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Convert the remaining runtime methods to new calling conventionLars Knoll2016-04-111-21/+21
|/ / | | | | | | | | Change-Id: I88ad3ca430508617d527715aa85ae8474ab7c621 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | V4 IR: Store the phi-node parameters directly in the class.Erik Verbruggen2016-03-061-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Every time one of the paramets was accessed, the chain of loads was: phi->d->incoming->heapdata[i] Now it is: phi[i + offsetof(incoming)] This also removes at least one malloc (for the Data), and usually two (when the number of parameters is <= 4, which is most of the cases). Change-Id: I953e784647148266ae5a49a93a203d0d22cdcb63 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | V4: Replace foreach with range based for loops for statements.Erik Verbruggen2016-03-051-1/+1
| | | | | | | | | | | | | | | | Function::basicBlocks() returns a const reference to a QVector, so it can safely be iterated over without qAsConst. Change-Id: Ie9a17edfff7c1fbdc3601121935aef4b41338a35 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | V4: Replace foreach with range based for loops for statements.Erik Verbruggen2016-03-051-2/+2
| | | | | | | | | | | | | | | | BasicBlock::statements() returns a const reference to a QVector, so it can safely be iterated over without qAsConst. Change-Id: If4e47e0e113adbc87253bb3478208a3a38fed9e2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QML: Fix typeof context property.Erik Verbruggen2015-10-271-0/+19
| | | | | | | | This was missing from f21e8c641af6b2d10f0d7e7e0fc6a755dab3673c. Task-number: QTBUG-48524 Change-Id: I5cc6a979d965a1ef6b7fbc916a7ca9df868b459a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QML: Sanitize reading environment variables.Friedemann Kleint2015-10-221-1/+1
| | | | | | | | | | | Where possible, use qEnvironmentVariableIsSet()/ qEnvironmentVariableIsEmpty() instead of checking on the return value of qgetenv(). Where the value is required, add a check using one of qEnvironmentVariableIsSet()/Empty(). Change-Id: Ia8b7534e6f5165bd8a6b4e63ccc139c42dd03056 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Access the id objects through a specialized runtime methodLars Knoll2015-08-121-7/+6
| | | | | | | | This brings us one step closer to getting rid of the QQmlContextWrapper. Change-Id: Ied57f4c174c2ebd95096310a4ad4c0c28787e7a4 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Access context properties through the qml contextLars Knoll2015-08-101-7/+20
| | | | | | | And get rid of another temp in the IR. Change-Id: I039393e020e5141f1986aee276246c30fd8057f3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Use the QmlContext to access properties of the scope objectLars Knoll2015-08-101-7/+41
| | | | | | | | | Add some runtime methods to access properties of the scope object directly (using the QmlContext), and generate proper code to call those. Change-Id: I0b29357c9a3b9ad53ba568ec6cb763e8ecb10f21 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Add ability to retrieve and use the QmlContext from our generated codeLars Knoll2015-08-101-0/+7
| | | | | | | | | | | | | | Our generated code (JIT and interpreter) should operate on the QML context to retrieve QML related things. That's better than operating on 4 different temps. So this commit introduces the QML context as a temp in the code we generate for QML. The next commits will move things over to use that context with specialized runtime methods instead of using generic subscript/get calls on the different subobjects. Change-Id: Ia05cf339de9cdd23003f35cf78ede17d2590f8de Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Some cleanups to QQmlRefCountLars Knoll2015-06-051-1/+1
| | | | | | | | | Rename QQmlRefPointer::take to adopt, as it's a better fit with the semantics. Get rid of the assignment operator from a raw pointer and add a Adopt argument to the constructor. Change-Id: Ia1ebe42b24570f32543e783f91eb3206602772a2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>