summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4codegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Specialize possible direct calls to evalLars Knoll2017-08-251-1/+5
| | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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-4/+18
| | | | | | | | | | | | | | | Change-Id: Ib5d5dc3b0e4a67b950ca9804edd3b6434fcdf9d1 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add optimized JmpCmpEq/NeNull instructionsLars Knoll2017-08-251-2/+38
| | | | | | | | | | | | | | | | | | | | | for comparisons with null or undefined. Change-Id: I4a70d12ace501e4c4735b2ccfd6de19aeb9fef22 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Make sure the for-in loop variable is an lvalueErik Verbruggen2017-08-211-2/+2
| | | | | | | | | | | | | | | Change-Id: Ia040a5e0080e1619d5ec19a07138cf26e7a8086b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | still emit global load instructions when 'undefined' is used as lhsLars Knoll2017-08-211-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using undefined/NaN as LHS instructions, we need to emit them as global loads to get the correct runtime type error. Amends c8a2e4acb101967c254d7e9d3c4e7d9f25c5eecc Change-Id: Ic03fb88e43b4f1c7e5dfb99faa78e7d35a3a6f8a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Store the actual string for name in ReferenceLars Knoll2017-08-211-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Split store-on-stack functions for "known destination"Erik Verbruggen2017-08-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the destination slot is known, there is no need to return and use it. This also works around certain versions of GCC that won't recognize the cast-to-void pattern to ignore return results. Change-Id: Iabf7ab1141c4f606030f2dda10ef69d1b090fb72 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Add a LoadZero instructionLars Knoll2017-08-181-0/+5
| | | | | | | | | | | | | | | | | | | | | 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-20/+3
| | | | | | | | | | | | | | | | | | | | | They are not used anymore. Change-Id: I0cb3754899a30d5f88279ff31296fd73edf90a9a 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>
* | | Constant fold &, | and ^Lars Knoll2017-08-181-3/+18
| | | | | | | | | | | | | | | Change-Id: Ia882e14f5521d45343288a267ffee5f756286012 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Emit JumpStrict(Not)Equal instructions where neededLars Knoll2017-08-181-0/+16
| | | | | | | | | | | | | | | | | | | | | Instead of falling back to the generic binop instruction. Change-Id: Ib13014ee003eae6b25f6a5743fc52070af377255 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add specialized instructions for loading undefined, null and intsLars Knoll2017-08-181-3/+22
| | | | | | | | | | | | | | | Change-Id: Iab0b77328f5756972ef6eff82c0041b184290a32 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Avoid lookup calls for constant values of the global objectLars Knoll2017-08-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | undefined, Infinity and NaN can never be changed in the global object, so we can directly resolve them to constants in the parser. Change-Id: I0cf43ff299518921d914121e150bc64ae5ea0c6e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Stop generating instructions when encountering a throw/returnErik Verbruggen2017-08-181-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Any code in a block or a SourceElementList that comes after a throw or a return is unreachable and doesn't need any code generated. Also do not generate an extra return for a function that ends with a throw. Change-Id: I448e8172766ecfe9a2c5b8cff63ebad8b0657701 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Don't use a return value register for regular functionsErik Verbruggen2017-08-181-41/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Cleanup naming of Stack frame structuresLars Knoll2017-08-101-1/+1
| | | | | | | | | | | | | | | Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Always retrieve the this object from the stackLars Knoll2017-08-101-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | There is actually no point in even having it in the context, as it's immutable and can't become part of a closure. Change-Id: I375fd07b9c442d667488430ebd246e174fdb243f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | More consistent naming of instructions and runtime methodsLars Knoll2017-08-101-16/+16
| | | | | | | | | | | | | | | Change-Id: Ib8af10a48749b16c48d75c91ad215396b201a9d5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split StoreName into StoreNameStrict and StoreNameSloppyLars Knoll2017-08-101-3/+10
| | | | | | | | | | | | | | | | | | | | | 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-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Avoid creating a CallContext for simple functionsLars Knoll2017-08-101-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | This cuts out quite a bit of overhead when entering and leaving functions. Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Create separate instructions to create both types of arguments objectsLars Knoll2017-08-101-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Load the this argument through LoadReg for simple callsLars Knoll2017-08-101-2/+9
| | | | | | | | | | | | | | | Change-Id: Iac0fb5c955354c8137b551196278b822acc1b324 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Introduce a JS stack frame that corresponds to the C++ stack frameLars Knoll2017-08-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | The frame currently contains the function itself and the current context. Change-Id: I7d3402627fbc90e860a7bdc277585f365f5b4cb5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Inline more of the runtime code into the interpreterLars Knoll2017-08-081-8/+7
| | | | | | | | | | | | | | | Change-Id: I4744c9b39d4de599f02dd91622dd19713c8cc7eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Use the accumulator for the rhs of CmpJmp instructionsLars Knoll2017-08-081-7/+1
| | | | | | | | | | | | | | | Change-Id: Ib7923863a88aacab93b06fa3c75d788fcfc0bf4e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add instructions for <, <=, >, >=Lars Knoll2017-08-081-1/+36
| | | | | | | | | | | | | | | Change-Id: Ibdd784507083da4c2cdc49208e842cc2e9c40da5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Parse foo["bar"] as a member expressionLars Knoll2017-08-081-0/+11
| | | | | | | | | | | | | | | Change-Id: I9295ca7957783ed85c07e1522d05e300781361e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move the function to call into the accumulatorLars Knoll2017-08-081-1/+3
| | | | | | | | | | | | | | | Change-Id: Ie84f3f029111b17d62912c653edc35b4cc2de026 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix bytecode dumping for argumentsErik Verbruggen2017-08-041-1/+1
| | | | | | | | | | | | | | | Change-Id: Ic29284da0ed555186db0e969b3c2c1ba8a1e5eba Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Store arguments in the stack frame before the locals/tempsErik Verbruggen2017-08-031-70/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All escaping arguments will still be loaded/stored from/to the CallData, but this is not the common case. In a subsequent patch we can make the caller prepare the stack frame, and for the common case we don't even need to copy arguments around. Change-Id: I3fbb6fe575a564d05a9fd5dcc0c8f4129eac3bc2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Where applicable, rename Temp* to Register*Erik Verbruggen2017-08-031-38/+38
| | | | | | | | | | | | | | | Change-Id: Ib7839ac09f520aaff3fadfdb37ea63d85a257bfd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Rename a number of types from Temp(orary) to StackSlotErik Verbruggen2017-08-031-103/+103
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Use lookup instructions when calling propertiesLars Knoll2017-08-021-5/+13
| | | | | | | | | | | | | | | | | | | | | Speeds up parts of v8-bench by 20%. Change-Id: Ic7e3d9103308b19bbe6bf1e40756b0f7f132d162 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add commonly used JumpCompare instructionsErik Verbruggen2017-08-021-6/+64
| | | | | | | | | | | | | | | Change-Id: I00d4ed5d8b6ab30ee3459d1cc7a2737144474f8a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Allow for more values to be in the accumulatorErik Verbruggen2017-08-021-38/+148
| | | | | | | | | | | | | | | | | | | | | For subscript indices and the base of a property name lookup Change-Id: I20394aa5daf6e49137b66575e56d1f8937160a8d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Introduce an accumulator in the interpreter, and change instructionsErik Verbruggen2017-08-021-444/+375
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Fix various signed/unsigned warningsErik Verbruggen2017-08-021-1/+1
| | | | | | | | | | | | | | | Change-Id: I9f4a5a8470c1abc6b07a28c71fdad0d208e1fea1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Replace Q_ASSERT(!"unreachable") with Q_UNREACHABLE()Erik Verbruggen2017-08-021-35/+35
| | | | | | | | | | | | | | | Change-Id: I86cdc545e2186926d9a10bbd4102cb89c88a87c7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Remove Moth::Param from the interpreter instructionsErik Verbruggen2017-07-191-92/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | The Param struct is now internal to the interpreter loop. It can be removed in a second step so we can directly access constants/temporaries/locals/arguments. Change-Id: I47ecbfe7508f352a8f212af48461dc92b35f4695 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix assignments-to-self like x=xErik Verbruggen2017-07-071-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | For those expressions, the load and store of x do need to be generated: they are observable and might have side-effects. Change-Id: Ifbfdfa1cb40c58ca99468548b94a42de9b704ae0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix QML disk cachingErik Verbruggen2017-07-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add correct generator name (always moth for the interpreter). Also fix the test: where we generated a dummy function 0, we now don't do that anymore, so correct the function index, and the check for the code offset. Change-Id: I4c07b2b53483c513dfaf8993e1d0111bcc825179 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix bug when a ternary expression was used in a if conditionErik Verbruggen2017-07-041-74/+75
| | | | | | | | | | | | | | | | | | | | | | | | This also changes the Result, so its members cannot be overwritten by accident. Change-Id: Id3679cb668da74468cbe17853cb13340683f11c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Bring back captureRequired on scope/contest property loadingErik Verbruggen2017-07-041-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needed to properly register permanent/temporary dependencies This patch also removes related interpreter instructions that should have changed, but were not used. Change-Id: Ie53c4611766680734c02e328b7f2c752cae150e0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Limit the amount of escaping variablesLars Knoll2017-07-041-21/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calculate more exactly which variables can be referenced from an inner context, and convert all the non escaping ones to temporaries on the stack. Change-Id: I0e33e85b0f6f426ef2812b8ecccee1870492b7b5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Properly calculate escaping variablesLars Knoll2017-07-041-2/+2
| | | | | | | | | | | | | | | Change-Id: Ia9f0b6d3f31bd3a7bd4316ee3f3e9ff977f973b7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Move the Runtime codegen into it's own fileLars Knoll2017-07-031-42/+1
| | | | | | | | | | | | | | | Change-Id: I3d09fc4b8aebe19acae0ba5a688491428a4af715 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move Codegen::ScanFunctions into it's own fileLars Knoll2017-07-031-357/+1
| | | | | | | | | | | | | | | Change-Id: I2c6c2fa09bc58a26a350011f5d525ec9f4b89d7f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>