aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Fix a bug in the implementation of the if statementLars Knoll2017-06-201-4/+8
| | | | | | | | | | | | | | | | | | Change-Id: Ie67d7e291d503d83b58087e733550de6bc44461f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Add support for break and continueLars Knoll2017-06-201-8/+7
| | | | | | | | | | | | | | | | | | Change-Id: I7750955343276a83c83587b0f40eb87556501b35 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Initial loop supportLars Knoll2017-06-201-17/+29
| | | | | | | | | | | | | | | | | | | | | | | | Currently just while() {} loops. Change-Id: I8ad202d26540cb670d4ef4753fb461d00c4dd70c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Move Loop and ScopeAndFinally from Codegen into the .cpp fileLars Knoll2017-06-201-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | This is in preparation for the new loop handling Change-Id: I06b8dd6190e2bc6c40fde33e9ff529a9c6feab91 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Smaller fixesLars Knoll2017-06-201-7/+17
| | | | | | | | | | | | | | | | | | Change-Id: I65f8307b717f365bff6d3d99b67601f000631b58 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Implement support for IfStatementLars Knoll2017-06-201-14/+7
| | | | | | | | | | | | | | | | | | Change-Id: I5269c0957f9da02f31ab5940a66923522f93a30b Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Implement support for conditional expressionsLars Knoll2017-06-201-29/+15
| | | | | | | | | | | | | | | | | | Change-Id: Ifcd57713e1cfa9514d3955e26f739a359cdaa8e5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix unopsErik Verbruggen2017-06-201-44/+87
| | | | | | | | | | | | | | | Change-Id: I0a952cf5c834c1a8c3ee5c327af1913aff56d3b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | add closure supportErik Verbruggen2017-06-201-3/+10
| | | | | | | | | | | | | | | Change-Id: Ib1e752119a5330d44f420035820680a476f6a530 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix FieldMemberExpressionsLars Knoll2017-06-201-1/+1
| | | | | | | | | | | | | | | | | | Change-Id: I84fa3fc687601cd2e5cfaf4b7745341d88c8d9fd Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Support CallExpressionsErik Verbruggen2017-06-201-17/+35
| | | | | | | | | | | | | | | Change-Id: I7d44c177e795f2392f6c9e582e4a28d593837a62 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Avoid moves between temps that are not requiredLars Knoll2017-06-201-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reference can have an associated temp to hold the loaded Name, Member or Subscript expression. In many cases, those can get passed on to the next reference that stores them to avoid internal temp->temp copies. Change-Id: I676715935009a54b6d978003b841ee9088a1ca39 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Optimize constant to temp assignmentErik Verbruggen2017-06-201-8/+14
| | | | | | | | | | | | | | | Change-Id: I20b7a4d6780522cb832f6110c8462834d3c5ed62 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix a bug in Reference::store()Lars Knoll2017-06-201-1/+1
| | | | | | | | | | | | | | | Change-Id: Ib06740999846ca3c3c68f95df71bdc7cf1ca443c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Properly implement Reference::fromMember/fromNameLars Knoll2017-06-201-3/+2
| | | | | | | | | | | | | | | Change-Id: I10374be9cf3e0c245bd71c3b32e9974fcf45c8ba Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Support for some more binary and unary operationsErik Verbruggen2017-06-201-47/+32
| | | | | | | | | | | | | | | | | | | | | | | | And some cleanups to the output of the bytecode dumper. Change-Id: I62fa5fbf87319118a4ba5f641652f8556cc16e07 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Add array member accessErik Verbruggen2017-06-201-49/+28
| | | | | | | | | | | | | | | Change-Id: I4ef87c78ad475e4d7006e36c0acff6314999ee6c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Refactor ReferenceLars Knoll2017-06-201-37/+110
| | | | | | | | | | | | | | | Change-Id: I30ab4ced1fcb8b9a7c7baed8faf7094a919c8603 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add Reference to codegen's result and start using itErik Verbruggen2017-06-201-417/+569
| | | | | | | | | | | | | | | | | | | | | Used in unary operations and assignments and variable initialization. Change-Id: I72babcead5ffba078ddf107d8325c9d9c4ef9ba3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Implement support for string and regexp literalsLars Knoll2017-06-191-2/+12
| | | | | | | | | | | | | | | Change-Id: I4475bb9cbfb8ac545c5bd7fcd0f93d0695b122c7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add support for true/false literalsLars Knoll2017-06-191-2/+2
| | | | | | | | | | | | | | | Change-Id: I87def95f5bb2524785a4c5a2a9c601ba6451dd2e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Also dump function name when dumping the byte codeLars Knoll2017-06-191-1/+4
| | | | | | | | | | | | | | | Change-Id: If3fb51d544d7a379f14d36ca5d7c843cbe8d2859 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add bytecode dumperLars Knoll2017-06-191-0/+3
| | | | | | | | | | | | | | | Change-Id: Ifd63cf604e66f46329472f82a46d37194a1b39eb Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add the push instruction required to set up the tempsLars Knoll2017-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | | And a commented out finalize() call to the bytecodegenerator Change-Id: Iaaf8981ee658e19b6816589d4340a8e5744764b7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add a BytecodeGenerator classLars Knoll2017-06-191-37/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use the generator to store the list of instructions, labels and patches. The finalize() method can then create the final bytecode out of that list. Change-Id: If2ea3118ed6e8744545bb918ecc4bbc87d6a3ff1 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add some meat to Codegen::Reference::load/storeLars Knoll2017-06-191-11/+77
| | | | | | | | | | | | | | | | | | | | | | | | Fill in code to emit proper Moth instructions for loading and storing References. Change-Id: I420ca0e805c98f9d8a304d178601ade41ae93b28 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add a new Reference type to CodegenLars Knoll2017-06-191-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | This should allow us to better keep track of References that are being used as L- or R-Values. Change-Id: I7d09fdd83c08ba5ece07f9b6aaa715a68098d0e9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Create Param's for constant expressions in the codegenLars Knoll2017-06-191-0/+27
| | | | | | | | | | | | | | | Change-Id: I47c003cb019089e8b679ca31cb5ef50020aba249 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Create Moth::Param for a name in the codegenLars Knoll2017-06-191-0/+47
| | | | | | | | | | | | | | | Change-Id: I434fed7e7a0b3026c7104f3a8260bf6a6cbc565c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Pass the JSUnitGenerator into the codegenLars Knoll2017-06-191-1/+2
|/ / | | | | | | | | | | | | | | Allow registering all the required data to generate the proper compilationunit already in the codegenerator. Change-Id: I36345cc01927b3f8dc3ba6d91da175bd6abe124a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-151-48/+124
|\| | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I3c41b9fc9ba7d41741e4dd400402ae80dd7726d9
| * Change temp allocation when generating IRLars Knoll2017-06-091-48/+124
| | | | | | | | | | | | | | | | | | For functions that won't get optimized, it's useful to limit the number of temporaries as much as possible. Change-Id: I6e9be3129c064fdc4c01e1ec6f1617e901c05935 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-04-071-8/+29
|\| | | | | | | | | | | | | | | | | | | 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
| * V4: Set correct source locations for jumps out of conditionalsv5.9.0-beta1Ulf Hermann2017-03-311-8/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We always want to place the jump on the last line of the conditionally executed statement, unless we might never execute the last line. In the latter case, that is if the inner statement is again a conditional, we use some token of the outer condition. This works fine with loops, as the loop condition is actually checked after each iteration, and it's plausible to the user that we jump there. With "if" statements, it's not so great. We cannot really explain why we jump back to the "if" token after executing the conditional statement. However, we have to add some source location to the jump instruction as otherwise it uses the source location of the last statement that had one, which is rather random. Task-number: QTBUG-59204 Task-number: QTBUG-59774 Change-Id: I48e331ce1c1830f236e16b75c9201a2f490d2092 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into HEADSimon Hausmann2017-03-231-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Codegen: do not assume QStringRef(const QString *) is implicitMarc Mutz2017-03-221-2/+2
| | | | | | | | | | | | | | It won't be for very much longer. Change-Id: I90fae21b621f104053b776296fc9f6525e8baf52 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-141-6/+6
|\| | | | | | | Change-Id: I0ec164ce6e8099e6e4d6b40a3c7340737473ef4b
| * Set source location for all loop body-to-front jumpsUlf Hermann2017-03-071-5/+5
| | | | | | | | | | | | | | Task-number: QTBUG-59204 Change-Id: Id1a73b228cd3386c7fcc7712c2485f387238b65e Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Add a source location to the final Jump in a for loopUlf Hermann2017-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | Otherwise it will assume the last statement as the location of the jump, and that might be a statement that is never hit. Task-number: QTBUG-59204 Change-Id: I66019a284b061358939b23e649ca0832b5442388 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-02-281-17/+22
|\| | | | | | | Change-Id: I92b13a9c1727644d63e125c1e6f1fdac72720ad7
| * Remove unnecessary assignment of binop results to temporariesErik Verbruggen2017-02-151-17/+22
| | | | | | | | | | | | | | | | | | | | | | In many cases, the result can be directly assigned to the left-hand side. So leave it to the place where the binop is used to decide when to assign it to a temporary. Change-Id: I9a88a71a77aa73afe88007eca744d3782fca34ac Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | parser: Add "let" keyword (& T_LET)Robin Burchell2017-02-031-6/+7
| | | | | | | | | | | | | | | | | | | | | | We also tie this up to the existing skeletal "const" support so that they are also checked for duplicate declarations. While we do that, change from using a boolean to an enum so we make the scope of a declaration a little more easily comprehensible. Change-Id: I6a6e08aed4e16a53690d6f6bafb55632807b6024 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | compiler: Rename _env to _variableEnvironmentRobin Burchell2017-02-031-68/+68
| | | | | | | | | | | | | | | | More in keeping with the spec's terminology, and allows us to introduce a LexicalEnvironment for ES6. Change-Id: I1d98387a0ad6372317cf1036f814ac0c6063c1bf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Codegen: Disallow duplicate declarations of const propertiesRobin Burchell2017-02-031-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Spec 13.3.1.1 (Static Semantics: Early Errors) says: It is a Syntax Error if the BoundNames of BindingList contains any duplicate entries. Only let/const are supposed to be treated in this way, so we ensure that one of them has been marked read-only (since we don't support "let" yet). There's still no runtime check on assigning to a constant-declared variable. [ChangeLog][QtQml] "const" variable declarations now throw a SyntaxError if multiple attempts to declare the same variable name are found. Note that "const" is still not fully spec-compliant (i.e. reassignment at runtime is not disallowed). Task-number: QTBUG-58493 Change-Id: I31fd5f2bf3e79d48734e8ecb714c4e7f47e31d2a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Codegen: Disallow const declaration without an initializer expressionRobin Burchell2017-02-021-0/+4
|/ | | | | | | | | | | | | | | | | | | | | This seems to match up with the spec behavior. 13.3.1.1 (Static Semantics: Early Errors) says: It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing this production is true. In addition, we also allow "const" to be used in JS mode too. We don't yet fully support the semantics, but as it's there, why not let it work. [ChangeLog][QtQml] "const" variable declarations are now available in JS as well as QML mode. [ChangeLog][QtQml] "const" variable declarations now require an initializer, bringing them closer to the required spec behavior. Task-number: QTBUG-58493 Change-Id: Ife5d5979b3e7a5d7340bf04f43605f847ee25ee2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Directly assign initializers to variables in variable declarationsErik Verbruggen2017-01-251-3/+10
| | | | | | | | .. instead of first assigning to a temporary and then assigning the temporary to the argument/local. Change-Id: I15a6c2073b78c5cfc829c7edef07c6bf48be7886 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow constants in IR as binop operandsErik Verbruggen2017-01-251-5/+5
| | | | | | | | There is no reason not to do this, plus it only takes up memory (for assignment to temporaries) and makes SSA transformation more costly. Change-Id: I09edbabe6ed50ab1a61b29ebd2ab541bccc95fad Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow more expressions as base/index in IR subscriptsErik Verbruggen2017-01-251-4/+4
| | | | | | | | | | | | | | Arguments and locals can be used directly as the base of a subscript, so they do not need to be assigned to a temporary first. For indices, arguments, locals, and constants, can be used just fine for subscripts. This reduces a whole lot of assignments to temporaries when generating the IR. Although they will be removed in an optimization pass, they do consume memory for no good reason, and make SSA transformation take more time. Change-Id: Ie2af65b66fecee3e140228a9532c9fab08474f5b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-191-0/+7
|\ | | | | | | Change-Id: I326616356ee26d4532c6d57558c43c919f0a900d
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-181-0/+7
| |\ | | | | | | | | | Change-Id: I20c622263f40c322954328e4d10a8071db3ca6d1