aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Re-enable Debug instructions and locations for QML functionsUlf Hermann2017-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Debug instructions are used to trigger break points and are added for every source line. We also need to insert Debug instructions before Ret, so that we can step out. We also need to assign line numbers to the entry and return points of "abbreviated" QML functions (by simulating lbrace and rbrace) so that we can set break points on them. The line numbers on Ret need to be negative, so that you cannot (accidentally) set break points on them. A typical signal handler or binding in QML consists of only one line and if you set a break point on that line, you want it to hit only once, when entering the function. If the line numbers on Ret were positive, it would be hit again on exit. Some of the tests in tst_qqmldebugjs implicitly check for that. Also the new interpreter does something on the left brace, so a function actually starts there, not on the first statement. Change-Id: Id9dfb20e35696b420d0950deab988f7cc5197bfc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Remove Binop/BinopContext instructions and implement missing binopsErik Verbruggen2017-10-231-67/+42
| | | | | | | | | | | | | | | Change-Id: Ibefac50246045066c90c4c2dbc36d2776c5dab0e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix potential crash in codegenErik Verbruggen2017-10-231-15/+24
| | | | | | | | | | | | | | | | | | | | | | | | Do more checking for previous errors: evaluating a condition can return an invalid result, because it might bail out because of an error. Change-Id: I14709e48f00146baac9599320e436abb30acc938 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Improve while(true/false) condition generationErik Verbruggen2017-09-261-2/+12
| | | | | | | | | | | | | | | | | | | | | Both in while-loops and in do-while-loops. Change-Id: I50be52e3ea6ecb9ce6886e6da03c35a1790a45e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix delayed loading of arguments in binary expressionsErik Verbruggen2017-09-201-4/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following functions: function f(x) { return x + (++x) } function g(x) { return x + x } In f() it is not correct to delay the load of x on the left-hand side of the + operator, while in g() it is. The reason is that calculating the right-hand side of the + operator in f() will change the value of x. So, if an argument is written to in an expression in a statement, it cannot be delay-loaded. The same is true for member/field accesses, because the accessors can be overwritten and do anything. Change-Id: I5bed4b0d03919edc1c94a82127e2dd705fc1d9b1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix name lookup in QML signal handlersErik Verbruggen2017-09-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to use an activation context for signal handlers, because parameter names are not explicitly stated, but loaded from the meta- object. However, while compiling we don't know if a function is a signal handler or not, so we need an activation context for all bindings. Change-Id: Ia2fce3bcb1bc1abb11e74fedb429dda9205fa7e5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Get rid of the hack for named expressionsLars Knoll2017-09-021-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | Instead simply use the pointer to the FunctionObject we have in the CallData now. Change-Id: I6d7ed8af22e89e0217bef427110611b661ac7965 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Generate a Decrement instead of a Sub with -1 as the rhsErik Verbruggen2017-09-011-5/+11
| | | | | | | | | | | | | | | Change-Id: Ie7f5f620089d58752d8f284293acda5794b4e99a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Generate Cmp* instructions instead of calling into the runtimeErik Verbruggen2017-09-011-8/+84
| | | | | | | | | | | | | | | Change-Id: Ia8f214e60f394f25235358b4ec529f78f4d3f263 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix invalid condition inversion for conditional jumpsErik Verbruggen2017-09-011-62/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Fix compiler warning on gccLars Knoll2017-09-011-1/+1
| | | | | | | | | | | | | | | Change-Id: I9a1b7d1ec9c0a66a34418ae3822b96c1c0d3eb86 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Don't emit bytecode just to set the thisObject to undefinedLars Knoll2017-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The stubs doing the calls often overwrite the value, and can in any case do it more efficiently. Change-Id: I0bb2fb3dcc34e805e0a4a178db02f99816d5cf46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move CallContext construction into a interpreter instructionLars Knoll2017-09-011-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+9
| | | | | | | | | | | | | | | Change-Id: I4494dae8166026074c9efc74bac62de9d3fa2342 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add the current context and function object to CallDataLars Knoll2017-09-011-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | Like this we can avoid creating Scope's when calling functions. Change-Id: I59b82c85eafd3a5437c233aba5f2e8330d5ce104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Get rid of the specialized Moth::CompilationUnitLars Knoll2017-08-311-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | It didn't do anything special anymore, so fold the last small bit of functionality back into the base class. Change-Id: Ic8f62e645b2742aa91f13f63adaf321353962bc5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove the codeRefs in the Moth::CompilationUnitLars Knoll2017-08-301-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | There's no point in allocating that vector of byte arrays, if we can directly embed those int the CompiledData and reference it from there. Change-Id: I8fc92b1efaca5a9646f40fc84a2ac4191c8f3444 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix compilation failures on Ubuntu 16.10 (gcc 6.2.0)Erik Verbruggen2017-08-291-2/+4
| | | | | | | | | | | | | | | Change-Id: Ia70727deb008021cbef6e546816b33ff0ce64afa Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Cleanup closure handling in codegenLars Knoll2017-08-281-19/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | We don't really need closure's to part of the Reference type. Instead simply load them into the accumulator when needed, and use a reference to the Accumulator instead. Change-Id: I4ca8c60083c9f2fa0da1db6c3c53718e3a32fc6f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add a load/storeLocal instructionLars Knoll2017-08-281-8/+20
| | | | | | | | | | | | | | | Change-Id: I084979a6fef7cce9a825cae9ce57234583ceb3ce Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix naming conflict for "swap" functionErik Verbruggen2017-08-251-2/+2
| | | | | | | | | | | | | | | Change-Id: I542ecabaaa9cd01bd1266456e317c842abd0a3de Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Correctly initialize the first function line in the bytecode generatorErik Verbruggen2017-08-251-0/+1
| | | | | | | | | | | | | | | Change-Id: I54824554a908de4ac764d637fb43a0c79809c718 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Move line number information into a side tableLars Knoll2017-08-251-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-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>