summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4instr_moth.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Ensure we have a lexical scope for global codeLars Knoll2018-05-111-0/+7
| | | | | | | | | | | | | | | 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>
* Add some basic support for for-of loopsLars Knoll2018-05-091-5/+3
| | | | | | | | | | | | | 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>
* Add Generator supportLars Knoll2018-05-031-0/+7
| | | | | | | | | | | | | 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>
* Rework catch context handlingLars Knoll2018-05-021-1/+1
| | | | | | | | | | | | 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-0/+4
| | | | | | | | | | | | | 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>
* Implement support for the ** and **= operatorsLars Knoll2018-04-261-0/+4
| | | | | Change-Id: I58a21e70fdd040175b52465d6ba52e7fceaf6398 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix some bugs in binding destructuringLars Knoll2018-04-261-0/+3
| | | | | Change-Id: I4b18a88e443f3b263cbb1e2b5ca1ebbd353afa98 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for ES6 rest parametersLars Knoll2018-04-251-0/+4
| | | | | | | function foo(a, b, ...c) {...} now works correctly. Change-Id: Ie442a0e7cc5e9dc4156e56b348bba305cced8531 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ES6: add support for default arguments for function parametersLars Knoll2018-04-251-0/+4
| | | | | | | | | The parser can also handle rest parameters correctly, this will however require some additional work in the runtime to support it correctly. Change-Id: Ib6f4d27683774966b2d2aac075494d2f5066d2a2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-161-4/+0
| | | | | | | | | | | | | | | | | | | | | Given the following expression var x = MySingleton.MyEnumValue where MySingleton is a QML (composite) singleton and MyEnumValue comes from a QML declared enum, we had code in place up to (and including) 5.10 to attempt to optimize that expression to a enum constant at compile time. In 5.10 that optimization does not exist anymore. In <= 5.10 we would also skip the optimization under certain circumstances (too many statementes, etc.). The fallback that is in place for handling this at run-time tried to be smart by avoiding the QQmlContextWrapper::get lookup and return straight a reference to the singleton as QObject. That works for regular property lookups, but it fails when trying to look up something like an enum, that isn't a meta-object property. Change-Id: I1819b9d8ae06a3f595e067bf5b018c4065be76bb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Correctly set this object when calling scope/context functionsErik Verbruggen2018-02-201-0/+8
| | | | | | | | | | | | | When a function is called that is in a QML scope or a QML context, set the 'this' object to the QML scope. This is done by introducing two new interpreter instructions, which get the context passed in. Note: this patch is 5.11 specific. 5.9 had a similair issue, but the implementation is quite different, so that was fixed separately. Task-number: QTBUG-66432 Change-Id: Ie43150cdd26360025895df28d31264985abf1c15 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix build without QML debuggingUlf Hermann2018-01-161-2/+0
| | | | | Change-Id: Ie1b18dd00705b1913572b87c6968a63438e7a90c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Change CallValue to have the value on the stackErik Verbruggen2017-11-231-1/+1
| | | | | | | | | | | | | | | We used to store the value-to-be-called in the accumulator. So the generated bytecode looked like: LoadReg r1 CallValue() The first thing done in CallValue is to store the accumulator. So by not loading the accumulator, we can actually remove the subsequent store, which results in less interpreter instructions and one less store in CallValue. Change-Id: Icc7c8a5449bf369b9226d66bc6055cb705ef660e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Collapse LoadRegExp+StoreReg into MoveRegExpErik Verbruggen2017-11-231-3/+3
| | | | | | | | LoadRegExp is nearly always followed by a store of the accumulator, so change LoadRegExp to be MoveRegExp. This saves an instruction. Change-Id: I5d47c5bf6ffd7f28247c328410872c3b229ca23c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Refactor Call/Construct instructionsLars Knoll2017-11-071-8/+15
| | | | | | | | | | | | | | | | Give them a pointer to argc and argv instead of a pointer to a full callData. Like this we can construct the callData at the end of the JS stack and avoid the need to create an additional copy in VME::exec(). This also opens up the option of completely avoiding all copies for calls into runtime methods. Also make sure that the calldata we pass into other functions is always at the top of the JS stack. Change-Id: I3d0eb49f7bfd7adb9ddabb213422087c66e5a520 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Remove Binop/BinopContext instructions and implement missing binopsErik Verbruggen2017-10-231-7/+23
| | | | | Change-Id: Ibefac50246045066c90c4c2dbc36d2776c5dab0e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix integral type conversion warningsErik Verbruggen2017-10-231-4/+5
| | | | | Change-Id: I2bd771e67bddad33b0c1c9bbb69f59e82460f35c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix building for QNX with buggy GCCErik Verbruggen2017-09-131-3/+3
| | | | | | | | The complaint from GCC was that a static array InstrInfo::argumentCount) cannot be in a union. Change-Id: Ibd8dad478dc95853004fb2a871d5883d4dc73dcc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix invalid condition inversion for conditional jumpsErik Verbruggen2017-09-011-44/+41
| | | | | | | | | We now have separate instructions for comparissons, which put the result in the accumulator. Then a JumpTrue/JumpFalse is generated to do the actual jump. Change-Id: I50a9d5899a6e071f4997931de6e8eb62596723cd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move CallContext construction into a interpreter instructionLars Knoll2017-09-011-0/+3
| | | | | | | | | | This will allow us to further cut down on function call overhead. To make this work, introduce a proper distinction between EvalCode and GlobalCode and use the correct compilation mode in all places. Change-Id: I070621142159b7416026347c9239200c5ed7a56b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify JSStackFrame and CallDataLars Knoll2017-09-011-53/+78
| | | | | Change-Id: I4494dae8166026074c9efc74bac62de9d3fa2342 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add dumping of the raw hex values to the bytecode dumperLars Knoll2017-09-011-4/+20
| | | | | Change-Id: I1ddc179fb19983d079872bd59a48e83de7af8494 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix line number mapping to work with non increasing line numbersLars Knoll2017-08-291-4/+9
| | | | | | | | | The old map assumed that line numbers are always increasing, something that isn't always true. So move to a format where we map blocks of bytecode to a line number instead. Change-Id: I1cd9dd1329d415122cd3d560294ef53007f879f8 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Fix compilation failures on Ubuntu 16.10 (gcc 6.2.0)Erik Verbruggen2017-08-291-4/+5
| | | | | Change-Id: Ia70727deb008021cbef6e546816b33ff0ce64afa Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove unused UnwindException instructionLars Knoll2017-08-281-3/+0
| | | | | Change-Id: I8b93270b5aebd39df8f88166e183814f6391c0f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a load/storeLocal instructionLars Knoll2017-08-281-0/+14
| | | | | Change-Id: I084979a6fef7cce9a825cae9ce57234583ceb3ce Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove the distinction between wide and xwide instructionsLars Knoll2017-08-281-79/+54
| | | | | | | | | | | | | | Only keep 1 byte and 4 byte wide instructions. As this gives less than 256 distinct instructions, those can now again be encoded in 1 byte, dropping the Wide and XWide prefix instructions. This gives us 95% of the size savings that we had before, by being able to encode the full instruction in one byte, while bringing back pretty much all of the speed lost through the compression. Change-Id: I9ec978d43314ed304ca0ee5546035d2b581b6dc3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Compress all non jump instructionsLars Knoll2017-08-281-0/+5
| | | | | Change-Id: I90daee5388f5aba5a5c1cd643379adc9a8e05039 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce the wide/xwide instruction prefixesLars Knoll2017-08-281-13/+26
| | | | | | | | | | | And add proper decoding for the prefixed instructions to the VME and bytecode dumper. We still only generate XWide instructions, that will get fixed in the next change. Change-Id: I6d2dc6a0a4f706044038274ca79e019a6c9bb7d9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use new approach of decoding instructions for the byte code dumperLars Knoll2017-08-281-111/+115
| | | | | | | | This should make it rather straightforward to switch the dumping as well when introducing compressed bytecode. Change-Id: I7ab349cf8ac5d7c710103c89bd4969ba35065e83 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename the Common instruction to NopLars Knoll2017-08-281-4/+10
| | | | | | | | And add Wide and XWide instructions that will get used as prefixes later on. Change-Id: I993865395ee2ac7d30eba2e41e7b437bfdb54391 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Decode instructions into registersLars Knoll2017-08-281-2/+2
| | | | | | | | Don't use the old instruction structures in the VME anymore, instead directly decode into scoped registers. Change-Id: Ie03ebad98050ebfd9eb9cc7e9273e5db92884a89 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Define instructions through a new formatLars Knoll2017-08-281-54/+53
| | | | | | | This will simplify moving over to a compressed bytecode format. Change-Id: Iba88723fe69149d798552582025867b19c881d00 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify instruction namingLars Knoll2017-08-281-5/+5
| | | | | | | | Simplify the naming conventions, so that both the instruction struct and enum start with upper case letters. Change-Id: I60c5a95d729e0b68b5a40f7db0e8f90be5938032 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move line number information into a side tableLars Knoll2017-08-251-8/+16
| | | | | | | | | Don't emit any Line instructions anymore, and instead store the info in a side table in the compiled data, where it can be looked up on demand. Change-Id: Idcaf3bf4ee4129fd62f9e717bf1277dc6a34fe19 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Specialize possible direct calls to evalLars Knoll2017-08-251-0/+4
| | | | | | | To avoid additional overhead on most function calls Change-Id: I2477b91fda6216b508c8331884a02b601f65590c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanup object construction instructionsLars Knoll2017-08-251-18/+2
| | | | | | | | Remove the unused Create/Construct instructions, and rename the single remaining one to 'Construct'. Change-Id: I10163a15681156f37e34d21a05d195d3c22adcff Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add optimized branch instructions for comparisons with intsLars Knoll2017-08-251-0/+9
| | | | | Change-Id: Ib5d5dc3b0e4a67b950ca9804edd3b6434fcdf9d1 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add optimized JmpCmpEq/NeNull instructionsLars Knoll2017-08-251-0/+8
| | | | | | | for comparisons with null or undefined. Change-Id: I4a70d12ace501e4c4735b2ccfd6de19aeb9fef22 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add a LoadZero instructionLars Knoll2017-08-181-0/+3
| | | | | | | as 0 is used quite often. Change-Id: I2c952ef077590f6e6cfe9aad50807f5e0f8686e4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Remove the Load/StoreScopedArgument instructionsLars Knoll2017-08-181-11/+9
| | | | | | | They are not used anymore. Change-Id: I0cb3754899a30d5f88279ff31296fd73edf90a9a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Remove the now unused LoadThis instructionLars Knoll2017-08-181-3/+0
| | | | | Change-Id: I2770ec4ef173cfa51c5ebd6600788de79684b953 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Optimize byte codes for loading true/falseLars Knoll2017-08-181-0/+6
| | | | | Change-Id: Ib726d55a32d868a4a547b0530b8b6dc6cd99a3cf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add specialized instructions for loading undefined, null and intsLars Knoll2017-08-181-0/+10
| | | | | Change-Id: Iab0b77328f5756972ef6eff82c0041b184290a32 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Don't use a return value register for regular functionsErik Verbruggen2017-08-181-1/+8
| | | | | | | | | | | | | | | | | | 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-38/+38
| | | | | Change-Id: Ib8af10a48749b16c48d75c91ad215396b201a9d5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split StoreName into StoreNameStrict and StoreNameSloppyLars Knoll2017-08-101-2/+6
| | | | | | | And adjust the name of the corresponding runtime functions. Change-Id: I4adf7b0e069d9b0dff9162cd1271dafc60be854b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor context handlingLars Knoll2017-08-101-7/+9
| | | | | | | | | | | | | | | 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>
* Remove unused lookup typesLars Knoll2017-08-101-8/+0
| | | | | | | | The indexed getters and setters haven't been used for a while and don't offer any performance benefits currently. Change-Id: Ifd5e1fab934e6e9940c4f1ad67f8850f04597504 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Create separate instructions to create both types of arguments objectsLars Knoll2017-08-101-2/+5
| | | | | | | | | We know at compile time whether an arguments object should be strict or non strict (unmapped/mapped in ecmascript 6), use separate instructions for both cases. Change-Id: Ia23e68003beeda41a1f3597c0ba0980954c80ec7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>