aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for super callsLars Knoll2018-07-031-31/+66
| | | | | | | | Implement super call support for class constructor functions. Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-1/+3
| | | | | | | | | Support the new.target meta property in the codegen, and add support for passing the newtarget into the constructor vtable methods and the execution context. Change-Id: I62ea58e5e92d894035a76e35776203e9837c383b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a newTarget parameter to the Construct runtime methodsLars Knoll2018-07-031-1/+4
| | | | | | | This is required to be able to support the super() call. Change-Id: I9998680341d701727ac1697187ad33481bdde422 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Various fixes for class supportLars Knoll2018-06-261-3/+3
| | | | | | | | | | | | | | | | Add support for a default constructor if none is given. Fix support for computed method names, by unifying the handling between static and non static methods. Fix our table generation, so that we write UINT_MAX as the string index for undefined strings and not a reference to the empty string, as that can actually be a valid method name. Add support for getter and setter methods in classes. Change-Id: If52c57d6a67424b0218b86339b95aed9d0351e47 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* throw a type error when trying to write to a const variableLars Knoll2018-06-261-27/+44
| | | | | | | | | This makes them really const. The codegen needs some smaller changes to ensure that writing to the variable when it's being defined is allowed. Change-Id: I781b4bc9c0e0397b9d00cad3daf758a062c17600 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Properly distinguish between class expressions and declarationsLars Knoll2018-06-261-1/+8
| | | | | | | | Introduce both types in the AST, and handle them properly in the code generator. Change-Id: I754ac0976de69009bdb8b203d890e4ec0ad03b30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* prototype can't be the name of a static class methodLars Knoll2018-06-261-13/+18
| | | | | | | | Throw a syntax error if a static class method is named prototype, as per ES7 spec. Change-Id: Idcaf5d6a0cf7a6b500038be7f0b1e6b8597ce583 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add basic support for EcmaScript classesYulong Bai2018-06-261-13/+114
| | | | | | | | | | | | | | | | 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 string memory leak in JavaScript ASTSimon Hausmann2018-06-251-2/+2
| | | | | | | | | | | | | Commit 02252ae08d introduced a QString member in a JS memory pool class, which leaks unfortunately as the pool is not designed to call destructors of allocated types. Typically strings in the AST are derived from input and therefore a QStringRef is fine. The bindingIdentifier in the PatterElement however is sometimes synthesized, so a separate storage for dynamically allocated strings in the memory pool allows for using QStringRef again. Change-Id: I94d090df653d784c554452722b3b759031e4735b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add support for function calls with spreadLars Knoll2018-06-211-13/+75
| | | | | | | | | | | 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-211-25/+24
| | | | | | | 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-211-3/+9
| | | | | | | | 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>
* Add support for spread expressions in Array literalsLars Knoll2018-06-211-34/+136
| | | | | Change-Id: I613d853dbb34d86ebedd871e9676d3206f1e3349 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix array destructuring nested in a rest elementLars Knoll2018-06-211-6/+5
| | | | | Change-Id: I3a8c15fe221bff04a3b9b21ed8c0b06c04770a3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix more issues with destructuringLars Knoll2018-06-211-5/+26
| | | | | | | | | | Fix destructuring targets that are complex lhs expressions. There are still some failures remaining, but this fixes another larger chunk of test cases. Change-Id: Icf08f42d7c70d4e81be5d5d2e27ebe6249d25467 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of elisions in destructuring expressionsLars Knoll2018-06-211-6/+4
| | | | | | | | We need to iterator over elisions at the end, as those could trigger side effects by calling iterator.next() Change-Id: Ieb5fa3562b6e60fdf179fa228510b2eeaaf9da30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix some of the finer details with regards to CompletionsLars Knoll2018-06-211-9/+94
| | | | | | | | | | | JS completion records have some finer details that can only be seen when using eval(), where the value of the completion record becomes important. Fix most of those cases to be compliant with the spec. Change-Id: I0c8105a8e778de7be3aea151d1bd64243aea067c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework unwind handlingLars Knoll2018-06-211-67/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.11' into devSimon Hausmann2018-06-191-0/+2
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/qml/compiler/qv4codegen.cpp tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp Change-Id: I010505326d76ee728ffe5fbd4c7879f28adadb12
| * V4: Set argumentsCanEscape when debuggingUlf Hermann2018-05-301-0/+2
| | | | | | | | | | | | | | | | | | This causes the updated arguments to be reported to the debugger when they are overwritten in the function body. Task-number: QTBUG-68534 Change-Id: I30c22d31aa97da0d58a4bbaaa032180a919669a8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Only create CallContext objects for bindings that might be signal handlersLars Knoll2018-04-261-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating the callcontext for all bindings causes a 15% performance regression in both of the moving images benchmarks of qmlbench. But in most cases, we know that a binding can't be a signal handler, as those always have to start with 'on'. Take this into account and avoid creating the context for most binding expressions. Task-number: QTBUG-67782 Task-number: QTBUG-67783 Change-Id: I9a25cb916e374c7d03693e49646ca28853c6ba54 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix creation of object literalsLars Knoll2018-06-041-111/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Cleanup handling of direct evalsLars Knoll2018-05-231-2/+0
| | | | | | | | | | | | | | | | | | | | There's no need to force lookups by name in an outer function just because an inner function uses eval(). The lookup by name is only required on the call context level, where eval() could add new variables. Change-Id: I8cad6d27524f496304342dfe1449ea913ef99fca Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Simplify Push and PopContext instructionsLars Knoll2018-05-231-1/+1
| | | | | | | | | | | | | | | | | | 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>
* | Partial support for calling iterator.return when break a for-of loopLars Knoll2018-05-141-3/+13
| | | | | | | | | | | | | | | | | | This will only work for non labelled break statements that don't break an outer loop as well. It also still doesn't work when an exception is thrown within the loop. Change-Id: Ie7cee7094ce2c51cdaa52270bbb16bc83b1e208f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Call iterator.return when required in destructuring assignmentsLars Knoll2018-05-141-4/+30
| | | | | | | | | | | | | | | | 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-141-7/+6
| | | | | | | | | | | | | | | | | | | | 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-141-12/+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-131-8/+26
| | | | | | | | | | | | | | | | 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-131-13/+10
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Give for loops a per-iteration context as wellLars Knoll2018-05-111-0/+4
| | | | | | | | | | | | | | | | Regular for loops also have a per iteration context for lexically declared variables as well. Change-Id: I35cb58bfb198c7dc32d70f41ea0ced7ddefcc37e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Give case blocks a proper scopeLars Knoll2018-05-111-0/+2
| | | | | | | | | | Change-Id: Id307c0426e1c9326ac085cebda71934cb5e612e0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Give for loops a proper block scope for it's lexically declared varsLars Knoll2018-05-111-0/+2
| | | | | | | | | | Change-Id: I71c40d1d061ac3c1c623dbbf8f7967c9ec35c082 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Unify AST for the different 'for' statementsLars Knoll2018-05-111-34/+5
| | | | | | | | | | Change-Id: I70ca83b0ce933d64dad4984a236e48592e989742 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Improve for-in and for-of supportLars Knoll2018-05-111-56/+69
| | | | | | | | | | | | | | | | | | | | | | | | Create a Block scope per iteration as defined in the ES spec. So closures created inside the loop will remember the iteration variable at that loop iteration. Add support for destructuring of the left hand side expression or declaration. Change-Id: Id06ef94e2a4b93646827da4f6ce922eb436e5a31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Unify ForeachStatement and LocalForeachStatement in the ASTLars Knoll2018-05-111-30/+11
| | | | | | | | | | | | | | | | This saves quite some duplicated code, but requires a bit of care when iterating over the AST. Change-Id: Ic530de4be8b36b4079c9d544b4b77982c3b8be60 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Support destructuring inside catch()Lars Knoll2018-05-111-6/+0
| | | | | | | | | | Change-Id: Ib60b56ac6a7111446e01235564a4cf92ad8ad025 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Ensure we have a lexical scope for global codeLars Knoll2018-05-111-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires a bit more work than simply pushing a new BlockContext for the lexically declared variables, as eval() and the Function constructor operate on the global scope (including the lexically declared names). To fix this introduce Push/PopScriptContext instructions, that create a BlockContext for the lexically declared vars and pushes that one as a global script context that eval and friends use. Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Don't cast an ExpressionNode to a StatementLars Knoll2018-05-091-3/+3
| | | | | | | | | | Change-Id: Ieb30d5345e56d6a2bb70320bf76eabcb9457e0f3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add some basic support for for-of loopsLars Knoll2018-05-091-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | The support is basically at the same level as for for-in at the moment. Currently unimplemented: * Destructuring * Proper lexical scoping * calling iterator.throw()/return() when required Change-Id: If193ce0b054c4315fc16b7e174334a31b2730dcf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Unify code paths for the two Foreach variantsLars Knoll2018-05-041-59/+39
| | | | | | | | | | | | | | They are mostly the same except for initialization. Change-Id: Idd1c0af1fc4fa3e478aeba7a7d45617949a2f239 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Reformulate for-in in terms of iteratorsLars Knoll2018-05-041-7/+9
| | | | | | | | | | | | | | | | | | Currently implemented for one of the two for-in variants, the follow-up patch will unify the code paths for the other variant with it. Change-Id: Ib0d1a0805018787530880b0e36d7ffc91e76a719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add Generator supportLars Knoll2018-05-031-16/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | Add support for ES6 generators. Those are currently always executed in the interpreter (we never JIT them), to simplify the initial implementation. Most functionality, except for 'yield *' expressions are supported. 'yield *' will have to wait until we support for(... of ...) Change-Id: I7c059d1e3b301cbcb79e3746b4bec346738fd426 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Check for errors after evaluating an expressionLars Knoll2018-05-021-1/+4
| | | | | | | | | | Change-Id: I271dfbaca99587019b1e37a031a345dd46b00ec4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add more checks for parse errorsLars Knoll2018-05-021-5/+20
| | | | | | | | | | Change-Id: Ie341340dfad1c8ef59a59e419465521f7d777990 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix failing assertion with getter and computed property namesLars Knoll2018-05-021-2/+7
| | | | | | | | | | Change-Id: Ie2929f0c20d8a6a2284238c15178dbcd5312e3b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix failing assertions when destructuringLars Knoll2018-05-021-2/+6
| | | | | | | | | | Change-Id: I1ee33969486c1c522b18e54410265716f222f6eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Cleanup handling of with() statementsLars Knoll2018-05-021-5/+6
| | | | | | | | | | | | | | | | | | | | | | Add a CompilerContext for with, whose only purpose it is to trigger variable lookup by name. This avoids looking up variables declared inside the with() {} block by name and we do not lookup variables outside the with block by name neither anymore. Change-Id: I52e9fb2daa9601f9e5102714c002dc506ad5ed23 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Rework catch context handlingLars Knoll2018-05-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Add support for proper lexical scopingLars Knoll2018-05-021-43/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | This is still to some extend work in progress as lexically scoped for loops won't yet do the right thing. let and const variables are still accessible before they are declared, and the global scope doesn't yet have a proper context for lexically declared variables. Change-Id: Ie39f74a8fccdaead437fbf07f9fc228a444c26ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>