aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.12' into 5.13v5.13.0-alpha1Qt Forward Merge Bot2019-02-073-1/+14
|\ | | | | | | Change-Id: I5209d833e171c795556c075e2a5f964b59b6df2e
| * QMLJS: Have ScanFunctions iterate over ArrayPattern nodesErik Verbruggen2019-02-052-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Like Codegen, have ScanFunctions iterate over the elements in an ArrayPattern, instead of recursing over the tail of the element list. This prevents running out of (native) stack, or hitting the recursion check limiter. Change-Id: I8203af3119ad50f19000a215af42649d9bcb3784 Fixes: QTBUG-73425 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Improve error messageRainer Keller2019-02-041-1/+5
| | | | | | | | | | | | | | Show more datails about what actually went wrong. Change-Id: I418a4d1f433bd4d440fc34e9a4932a9ea010b174 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-02-011-8/+3
|\| | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Done-With: Erik Verbruggen <erik.verbruggen@qt.io> Change-Id: I3ae3d64317e4f3fccba6605f4c6da15479ca75e0
| * V4: Fix unwind handler reset after for-in loopErik Verbruggen2019-01-311-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this JavaScript snippet: function f() { for (var i in []) {} } This generates the following bytecode sequence: 2 0: 14 00 09 MoveConst r3, C0 3: ec 00 00 DefineArray (function), 0 6: da 00 GetIterator 0 8: 18 08 StoreReg r2 10: c0 0f SetUnwindHandler 27 12: 50 04 Jump 18 14: 16 0a LoadReg r4 16: 18 07 StoreReg r1 3 18: 16 08 LoadReg r2 20: dc 0a 09 IteratorNext r4, r3 23: 54 f5 JumpFalse 14 25: 50 03 Jump 30 27: c0 00 SetUnwindHandler <null> 29: c2 UnwindDispatch 4 30: 0e LoadUndefined 31: 02 Ret The problem is a normal loop exit: instruction 23 will not jump back, but fall through, and then instruction 25 will jump over the instructions resetting the unwind handler (27 + 29). Removing this jump fixes the issue. Change-Id: Ic9f03555ebebc27144490bce04e9a4166ed7c97c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Correctly scope unwind handlers for try blocksLars Knoll2019-01-301-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Make sure the unwind handler is always reset when leaving the try block. This exposes a couple of failures in the ECMAScript test suite that were before passing by pure luck. Task-number: QTBUG-72858 Change-Id: I014b1e37c2beff136ecd53a665a2f10933f7e12c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | V4: Move relative-to-absolute offset calculation to base classErik Verbruggen2019-01-311-0/+2
| | | | | | | | | | | | | | 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-318-516/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-291-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/3rdparty/masm/yarr/YarrJIT.cpp src/qml/compiler/qv4instr_moth.cpp src/quick/handlers/qquicksinglepointhandler_p.h src/quick/handlers/qquicktaphandler.cpp src/quick/items/context2d/qquickcontext2d.cpp Done-With: Ulf Hermann <ulf.hermann@qt.io> Change-Id: I109453131f9f0a05316ae37c7d6ed1edc8c0f9d4
| * Fix byte code register dump outputSimon Hausmann2019-01-291-1/+1
| | | | | | | | | | | | | | | | The first register allocated in bindings is typically the return address register, which was erroneously shown as argument 0 instead of register 0. Change-Id: I00add0b5b1cd08a4c9b1d42ffe79d2ea7e5a73cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4: Collect trace information in the interpreterErik Verbruggen2019-01-2511-116/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Move the FixedPoolArray into the MemoryPool headerErik Verbruggen2019-01-253-69/+6
| | | | | | | | | | | | | | So now the FixedPoolArray can be re-used in other places. Change-Id: I0e0504892944722a0c18f207dc6400d5b314f6ae Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QML: Don't accept assignment of Component to properties of other typesUlf Hermann2019-01-221-2/+0
| | | | | | | | | | | | | | | | This is dangerous and I don't see a reason why we should allow it. Fixes: QTBUG-72930 Change-Id: I01b9e624b4b80d52c1a847fa6ecd7a6d44614010 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-221-1/+1
|\| | | | | | | | | | | | | | | Conflicts: .qmake.conf tests/auto/quick/qquickpathview/tst_qquickpathview.cpp Change-Id: Ic1f5e219a255d0613f7654368a5ce3eccb8f0ee9
| * Fix build error when building with -no-feature-translationUlf Hermann2019-01-111-1/+1
| | | | | | | | | | | | Change-Id: Ie97ae901283cf431fc38d238ddbc88a18bd630c8 Fixes: QTBUG-72352 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QML: Special case null as binding typeUlf Hermann2019-01-214-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | This gives us the opportunity to map the JavaScript null to QVariant's concept of isNull(). [ChangeLog][QML] Assigning JavaScript null to incompatibly typed properties generates a compile error now, rather than a runtime error. Fixes: QTBUG-72098 Change-Id: I72fd1c30d84128c774230eaaea10455b2a0e064c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-12-231-2/+2
|\| | | | | | | Change-Id: I9c3d282c11a556e616c5e1ba1b51e88b741327f6
| * Fix ICC warning about old-style scoping rulesThiago Macieira2018-12-121-2/+2
| | | | | | | | | | | | | | | | | | | | It's only been 20 years that the new style is the rule... qv4compileddata.cpp(206): error #823: reference is to variable "i" (declared at line 198) -- under old for-init scoping rules it would have been variable "i" (declared at line 204) Change-Id: I4ac1156702324f0fb814fffd156f80ecb6849ee8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-12-124-8/+79
|\| | | | | | | | | | | | | Conflicts: tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp Change-Id: Ic1dace832ad4b29023d24808b8617b5dcc915eb5
| * Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-12-074-8/+79
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4script.cpp src/qml/parser/qqmljslexer.cpp Change-Id: I82252a8c504a4b77c45f4f8efe849ff9acb949fd
| | * Generate lookups into the global object more aggressivelyLars Knoll2018-11-164-8/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since change 9333ea8649838d7e0400b0e94c8cbd4fa5d216b0, we lookup properties in the QML context object before the global object to have proper scoping rules for QML. Unfortunately this lead to a performance regression when using global properties such as Math in imported script files, as the lookup would always go through the qml context first. This can be fixed, as we know that the global object is frozen in qml mode, and the standard names of properties in the global object are illegal to use in QML. So simply check for those names in the code generator and create lookups into the global object for those. Change-Id: I4b2089178c9e5f9440abdfd834cf7d92c3c0e2c3 Fixes: QTBUG-71591 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Fix warnings about unused Qt containersSergio Martins2018-11-302-5/+0
|/ / | | | | | | | | | | | | | | | | | | | | Fixes -Wclazy-unused-non-trivial warnings, in preparation for using gcc/clang's warn_unused attribute in all containers. Maintainers please check if some unused variable isn't hidding an actual bug. Change-Id: I83c5a11aa2328db3dce4c6c402295d86ef297c83 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | JS: Limit expression and statement nesting levelErik Verbruggen2018-11-294-2/+55
| | | | | | | | | | | | | | | | | | This is to prevent extremely deeply nested expressions and statements make the code-generator run out of (native) stack space. Task-number: QTBUG-71087 Change-Id: I8e1a20a361bff3e49101e535754546475a63ca18 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | JS: Check pattern target to be an lvalueErik Verbruggen2018-11-191-0/+4
| | | | | | | | | | Change-Id: If9468b93b08ad355f07d1436ca88e8d36be22070 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | JS: Handle check for dangling jump gracefullyErik Verbruggen2018-11-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | The destructor for the Jump object will check if it is linked somewhere. So when doing an early-exit after generating a jump (and before linking it) and after an error occurred, make sure to call link anyway. At this point no code will be generated, so where the jump points to is kinda pointless. Change-Id: I09fa03d4224805a838088acd0c5c83d02b328045 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Properly mark variables as unresolved when accessed from evalLars Knoll2018-11-161-1/+1
| | | | | | | | | | | | | | | | | | If we can't resolve the variable and are executing eval code, we need to look it up by name, and not generate a lookup in the global object. Change-Id: I693b3b714651911f72620160bfc463d6dbb00820 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-11-164-51/+49
|\| | | | | | | Change-Id: I7623438dde316ae1e97802f91991f2e7ccc205a5
| * Stop codegen after errorErik Verbruggen2018-11-131-25/+27
| | | | | | | | | | | | | | | | | | | | We won't use the bytecode anyway, and it prevents consistency checks that come after the error from failing. Specifically: there might be jumps that have no label defined. Fixes: QTBUG-71738 Change-Id: I62a7e943b0156d42caccfa40507853de79e3b1ce Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Fix translation bindings when qtquickcompiler is usedFrederik Gladhorn2018-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that the context information is lost when using the compiler. The unit->unitData()->sourceFileIndex is wrong (always 0), which should probably be fixed. This change only works around that by using unit->fileName(); instead. Make sure that the test actually verifies translations happen and have a context. Done-with: Jan Arve Sæther Fixes: QTBUG-71553 Change-Id: Ib5926bd4b9a6267644f5c9328a84c23d61ca5466 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Expose let/const variables from imported JS scriptsJüri Valdmann2018-11-023-25/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows QML to access let/const variables defined in JS files. Detailed changes: - The recently added ContextType::ScriptImportedByQML is changed to avoid creating Push/PopScriptContext instructions, similar to ContextType::ESModule. - QV4::Module is changed to also work with CompilationUnits which are not ESModules. In this case QV4::Module will behave as if all lexically scoped variables were exported. - CompilationUnit is changed to support instantiating and evaluating QV4::Modules for non-ESModules as well. - QQmlTypeLoader is changed to always create QV4::Modules for evaluating scripts. For the non-ESModule case, the QV4::Module is evaluated inside a QV4::QmlContext, as before. - A pointer to the QV4::Module is added to QV4::QQmlContextWrapper, and used in virtualGet to access the let/const variables in the CallContext. Access is read-only. Fixes: QTBUG-69408 Change-Id: I6f299363fdf5e1c5a4a0f1d9e655b4dc5112dd00 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Create proper template objects for tagged templatesLars Knoll2018-11-0510-69/+160
| | | | | | | | | | | | | | | | 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>
* | Create proper template objectsLars Knoll2018-11-021-14/+40
|/ | | | | | | | | Create the proper template object for a tagged template. This fixes quite a few use cases (esp. String.raw), but is not yet 100% spec compliant. Change-Id: I69eaee22c384c0d1bd2c6c56ad711d29521b0b86 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clone ContextType::Global as ContextType::ScriptImportedByQMLJüri Valdmann2018-11-014-8/+10
| | | | | | | | | | Add new enum value QV4::Compiler::ContextType::ScriptImportedByQML, which behaves exactly the same as ContextType::Global. A follow-up patch will change the behavior slightly. Task-number: QTBUG-69408 Change-Id: I20d27804fd1433f2229704546bcd78a0ac108c01 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix lookup of methods in the scope objectSimon Hausmann2018-10-221-5/+9
| | | | | | | | | | | | | Commit 939014cb9cad2f3357f47b28a4580397c17b913c improved performance of property lookups beyond the scope object, with the unfortunate side-effect that the previously polymorphic lookup of methods broke. Fix this by moving the handling to the caller side and falling back to the string lookup for functions. Fixes: QTBUG-71204 Change-Id: I2d9924034a9c14e7d161fa49d51b1f876ab5bc0f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlScriptData: Extract qmlContextDataForContext from scriptValueForContextJüri Valdmann2018-10-171-0/+2
| | | | | | | | Refactoring only, no behavior changes. Task-number: QTBUG-69408 Change-Id: Ifd26957dca69bcd658ad5f989108a661b9996d6c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Check if the rhs of an assignment had errors before using itErik Verbruggen2018-10-151-1/+4
| | | | | Change-Id: I34d70759732433b6f0ecccc5ae175d33ec8e1577 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Check lhs of an 'in' expression to be an lvalueErik Verbruggen2018-10-151-0/+4
| | | | | | | | | For example: 'for (foo() in something) {}' is not valid: a call expression is not an lvalue. Task-number: QTBUG-71086 Change-Id: Ia1498cd38526b073afb8e4524ceaea14dca3d65f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove useless assertErik Verbruggen2018-10-151-2/+0
| | | | | | | | There is a {{Q_UNREACHABLE}} right after it. Change-Id: Id69fb1403a5f99912e6fbcb4a397a78a9d6948d7 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Abort parsing on errorLars Knoll2018-10-151-17/+14
| | | | | | | | | | The visit() methods need to return false on parse errors, so that we don't continue iterating into that subtree of the AST, but rather exit as quickly as possible. Task-number: QTBUG-71090 Change-Id: I1912d955a0ffc86389a4cbbb3b6ac0209c3c556a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Check expressions inside template literals for validityErik Verbruggen2018-10-121-0/+4
| | | | | | | | | And not use (a possibly invalid result) blindly, because this will cause assertion failures down the line. Task-number: QTBUG-71081 Change-Id: Id10149c55026094a355bd747f66014119c0e24f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix error reporting when imports or re-exports in modules failSimon Hausmann2018-10-115-4/+28
| | | | | | | | Collect the location of the import/export statement and include it in the exception thrown. Change-Id: I7966dfd53ed67d2d7087acde2dd8ff67c64cb044 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* JS: Check array subscripts for validity when generating codeErik Verbruggen2018-10-111-0/+2
| | | | | | Task-number: QTBUG-71079 Change-Id: I999130f3994f513bb9d2ca8ddaa94688451937fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix possibly uninitialized use of unionErik Verbruggen2018-10-091-2/+2
| | | | | | Task-number: QTBUG-71011 Change-Id: I42410364b45ecd38832a0e5abb82eb56f9828504 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-10-081-0/+4
|\ | | | | | | | | | | | | | | Conflicts: src/3rdparty/masm/yarr/YarrJIT.h src/quick/items/qquickwindow.cpp Change-Id: I551404e1558d56c0b0626346ad1c86406bff0ec7
| * Mark QML captured scope/context loads as having side effectsErik Verbruggen2018-10-041-0/+4
| | | | | | | | | | | | Task-number: QTBUG-69973 Change-Id: I8636d74c76db3859a6bd5134fd5e52f571340a71 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Make Codegen::Reference movableErik Verbruggen2018-10-072-67/+4
| | | | | | | | | | | | | | | | This removes the call to Reference::operator= and allows the constructor and assignment to be inlined. Change-Id: I173ae47127cc5c939300c1178c4c8637882f1c49 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Trim some #includesErik Verbruggen2018-10-073-14/+4
| | | | | | | | | | Change-Id: I5346fc36c89b7969c2bef3069f256f33bd4d9eb9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | ES7: Detect Tail Position Calls and pass that to the runtimeErik Verbruggen2018-10-046-32/+150
| | | | | | | | | | | | | | 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>
* | Make a method constErik Verbruggen2018-09-281-1/+1
| | | | | | | | | | Change-Id: I70043699d15daf858c47d30018060aef31810abb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Refactor InternalClass::find()Lars Knoll2018-09-271-2/+2
| | | | | | | | | | | | | | | | | | Specialize find() into several methods for different purposes. Prepares for further cleanups and being able to split up getter and setter for accessor properties. Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>