aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilercontrolflow_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-1/+0
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disentangle includes and namespacesUlf Hermann2019-07-111-5/+5
| | | | | | | | Avoid using namespace in headers and include only the headers we actually need. Change-Id: I526a0f874dc09b07693fd87070665be396d3b637 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of unused variableLars Knoll2018-09-071-1/+0
| | | | | Change-Id: I71bcf32d513c9c06e43816ba0797865e3e3a1ac5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix exception handling while destructuringLars Knoll2018-09-071-12/+21
| | | | | | | | | | | | | | | When an exception happens during destructuring, IteratorClose needs to be called, unless the exception happened inside the IteratorNext call (in that case the iterator is assumed to be invalid and we shouldn't call close on it). Implement this, by ensuring that we set the done return variable of IteratorNext to true whenever IteratorNext throws an exception. IteratorClose will check the done state and not do anything in that case. Change-Id: I73a27f855f2c4d3134b8cc8980e64bf797d03886 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Some fixes when unwinding inside for-of loopsLars Knoll2018-09-071-6/+7
| | | | | | | | This is not perfect yet, as the two regressions in TestExpectations show, but it's an improvement over the current situation. Change-Id: I82c0ef0f69619562037c573bea1026abc53c1ab3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up finally code genSimon Hausmann2018-06-231-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of emitting GetException MoveReg <returnvaluetemp>, <returnaddress> StoreReg <exceptiontemp> ... LoadReg <exceptionTemp> MoveReg <returnvaluetemp>, <returnaddress> SetException and implicitly relying on MoveReg to not clobber the accumulator, it's cleaner to produce MoveReg <returnvaluetemp>, <returnaddress> GetException StoreReg <exceptiontemp> ... MoveReg <returnvaluetemp>, <returnaddress> LoadReg <exceptionTemp> SetException Change-Id: I3c392ba5fb75aa2ad3ef32aa776fa7acbc25317c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some of the finer details with regards to CompletionsLars Knoll2018-06-211-2/+25
| | | | | | | | | | | 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-218/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+9
| | | | | | | | | 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>
* Simplify Push and PopContext instructionsLars Knoll2018-05-231-13/+8
| | | | | | | | | 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>
* Improve for-in and for-of supportLars Knoll2018-05-111-8/+6
| | | | | | | | | | | | 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>
* Support destructuring inside catch()Lars Knoll2018-05-111-0/+4
| | | | | Change-Id: Ib60b56ac6a7111446e01235564a4cf92ad8ad025 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup handling of with() statementsLars Knoll2018-05-021-5/+0
| | | | | | | | | | | 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-11/+12
| | | | | | | | | | | | 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-9/+56
| | | | | | | | | | | | | 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>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-6/+6
| | | | | | | | | | | | | 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>
* Store the actual string for name in ReferenceLars Knoll2017-08-211-2/+1
| | | | | | | | | Delay desolving the name to an index until we actually need it. This avoids storing strings that are never used in the string table. Change-Id: I935a2d07c03234097b4cf6cfe98231528ac3b15c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't use a return value register for regular functionsErik Verbruggen2017-08-181-19/+55
| | | | | | | | | | | | | | | | | | don't use the return value register for normal functions anymore. It's still needed for eval code and qml bindings that have an implicit return value, as the accumulator gets clobbered too easily in those cases. Also get rid of the exit block we used to generate. Adjust the control flow handlers to correctly unwind. This required adding some jump instructions that left the accumulator untouched (as it now holds the return value) and using those in handlers. Change-Id: I2ca1afaf7234cb632e5d26ba5b10ec3f11f50c93 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* More consistent naming of instructions and runtime methodsLars Knoll2017-08-101-5/+5
| | | | | Change-Id: Ib8af10a48749b16c48d75c91ad215396b201a9d5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor context handlingLars Knoll2017-08-101-5/+19
| | | | | | | | | | | | | | | Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Where applicable, rename Temp* to Register*Erik Verbruggen2017-08-031-4/+4
| | | | | Change-Id: Ib7839ac09f520aaff3fadfdb37ea63d85a257bfd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename a number of types from Temp(orary) to StackSlotErik Verbruggen2017-08-031-11/+11
| | | | | | | | As a preparation to also store arguments on the stack, just like the temporaries. Change-Id: If3a6ed56930e29ad77c992811065bb32ee2d030c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Introduce an accumulator in the interpreter, and change instructionsErik Verbruggen2017-08-021-22/+16
| | | | | | | | | | | | This reduces the number of stores to the stack (for which we need a write-barrier in the future) by keeping the last calculated value in the accumulator register (which is a local variable). In the future we might want to collapse certain common instruction patterns into a super-sized instruction. Change-Id: I02ebed2db957765e994c8f939bf7585894881deb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't create unwind handlers for things we can't unwind toLars Knoll2017-08-021-1/+4
| | | | | | | | | Check that the thing we want to unwind to is valid (e.g. and existing label), before attempting to create an unwind handler that is supposed to unwind towards this label. Change-Id: If5461d58f5db1590b14817a8c87c9eb5044c33b9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Split up qv4codegen into several filesLars Knoll2017-07-031-0/+421
And changed the namespace of those classes to QV4::Compiler. ScanFunctions should over time also move into its own file. Change-Id: If084acea4a9a20b9c79ad47dac19e02dc720e098 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>