aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
Commit message (Collapse)AuthorAgeFilesLines
* V4 debugger: retrieve formals and locals.Erik Verbruggen2013-10-243-5/+8
| | | | | Change-Id: I47507a4d7d1b429b9c43ed3a7822079efe577327 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add support CompositeSingleton to the new V4 compiler.v5.2.0-beta1Antti Piira2013-10-213-4/+64
| | | | | | | | | | | | | | | | | Implements QQmlCodeGenerator::visit(AST::UiPragma *) to process any pragma statements in a QML file for the new V4 compiler approach. Only pragma Singleton is supported, others will generate errors. Also adds necessary hooks to treat types as Singletons. Basic functionality is working, but three of the QML Singleton unit tests fail. Some of them are dependent on other language capabilities that seem to have problems. In addition removes unnecessary toString() call in the equivalent visit(AST::UiPragma *) function of the old parser. Change-Id: Iec9fa887f953b80b7f9a11878d846637a8f519ef Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Qml JavaScript code generation cleanupsSimon Hausmann2013-10-206-8/+15
| | | | | | | | | | | | | | | * Run the binding expressions, functions and signal handlers through the V4 codegen _per_ component, and run the isel at the end for the entire file. We need to do per-component codegen because we want to set up the correct id and object scopes, which are different for the root component and anonymous components. * Changed V4IR::Module to allow for the concept of "qml modules" where there is no root function defined. This is a logical consequence of running v4 codegen multiple times with different input but the same V4IR::Module. Change-Id: Ib3a719f83507cbab7c2e4e145ccad5b663c795cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Avoid unnecessary irModule->functions.indexOf callsSimon Hausmann2013-10-207-50/+58
| | | | | | | | | With a growing number of functions per module, these calls become expensive and are unnecessary. defineFunction in the code generator can simply return the correct index right away. Change-Id: I8ab56a3083bf215674a1b46c502b415be694e465 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix build on ARM in ARM mode (instead of thumb2)Simon Hausmann2013-10-173-7/+13
| | | | | | | | | | We don't support the traditional ARM assembler (yet), only JIT on thumb2. In order for us to reliably check that, we have to wait until the pre-processor runs, which this patch achieves by moving all JIT enable/disable decisions into qv4global_p.h Change-Id: I7eff5b4fbf1cd26297a08dee16984ad867358113 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up stack trace generation for the JITSimon Hausmann2013-10-161-0/+20
| | | | | | | | | | | | | | It turns out that in QML it is not unusual that during early binding evaluations due to the undefined order, the evaluation tries to look up properties in objects that aren't initialized yet and thus exceptions are thrown. Eeach thrown exception saves a stack trace, which is expensive to generate when using the JIT, as it does full stack unwinding. This patch implements a more light-weight approach by storing the instruction pointer in the context before leaving JIT generated code. Change-Id: I95e1cfd01179247dfc2c1df949828f474a23161b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* inline get_element callsLars Knoll2013-10-142-9/+92
| | | | | | | | | | | Inline calls to get_element if the base is an object with a simple array structure, and the index is an integer number. Implemented for 64bit only for now, saves ~25% on crypto.js Change-Id: I3e34a6409169d90d3937f62264707d52a6c2f9f7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix performance regression introduced by 6adb06Lars Knoll2013-10-141-1/+1
| | | | | | | | | The global scope is compiled as EvalCode. Because of this we were never using global lookups anymore, slowing down the v8 test suite by ~20%. Change-Id: I6c47ccf90f4d9ec3bf531bbb689d3f1511f69968 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix a small bug in conversion to SInt32Lars Knoll2013-10-141-8/+0
| | | | | | | | | If the truncation from double returned out of bounds, the code was not generating the right call to the fallback method on 64 bit. Change-Id: I6a126dd013c5b6373762beef0c1459fae1c26ef2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 JIT: fix stack size calculation on 32bit.Erik Verbruggen2013-10-141-2/+3
| | | | | | | | | Registers containing outgoing parameters for calls are saved as Value (so, 8 bytes long) instead of native register size. For 64 bit this is the same, but not for 32 bits. Change-Id: If1d55e9d552a301782816c9228390dc5611c6d00 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Implement >>> inline for the JIT backendLars Knoll2013-10-123-8/+13
| | | | | | | | | The unsigned right shift operations can use a signed int as input, unifying the handling with the other shift operations. The only difference now is in the type of the return value. Change-Id: Ia9b83568951d1c1c77322d07cd734e2c37d34573 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* V4 JIT: fix register allocator after change to s/uint32 usage.Erik Verbruggen2013-10-121-8/+2
| | | | | | | | Now that shifts can take a signed int32, reflect it in the check if a binop will generate a call. Change-Id: I3cab436bace31cdda327cf6132aa873b6c5456b1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 JIT: clean-up conversion functions and add toUInt32.Erik Verbruggen2013-10-123-45/+107
| | | | | Change-Id: I7ac685145fa41db2a0e02c4d15d1d287d80621f8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Compile binding expressions in the QQmlCompilerSimon Hausmann2013-10-113-29/+45
| | | | | | | | | | | | | | | | | | | | | | | | This is done by re-using the JS code generator from the new compiler. A few bugs were fixed on the way: * The index into the compiledData->runtimeFunctions array is not the same as the function index when they are collected (from the AST), as for example binding expressions may create extra V4IR::Function objects that break the 1:1 mapping. Therefore the JS code gen will return a mapping from incoming function index to V4IR::Module::Function (and thus runtimeFunction) * Binding expressions in the old backend get usually unpacked from their ExpressionStatement node. The reference to that node is lost, and instead of trying to preserve it, we simply synthesize it again. This won't be necessary anymore with the new compiler in the future. * Commit 1c29d63d6045cf9d58cbc0f850de8fa50bf75d09 ensured to always look up locals by name, and so we have to do the same when initializing the closures of nested functions inside binding expressions (in qv4codegen.cpp) * Had to change the Qml debugger service auto-test, which does toString() on a function that is now compiled. Even if we implemented FunctionPrototype::toString() to do what v8 does by extracting the string from the file, it wouldn't help in this test, because it feeds the input from a string instead of a file. * In tst_parserstress we now end up compiling all JS code, which previously was only parsed. This triggers some bugs in the SSA handling. Those tests are skipped and tracked in QTBUG-34047 Change-Id: I44df51085510da0fd3d99eb5f1c7d4d17bcffdcf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix failing assertion (index != -1) when trying to re-declare a function ↵Simon Hausmann2013-10-111-8/+3
| | | | | | | | | | | | | | | | | parameter Testcase: (covered in parserstress) function foo(x) { var x = 42; } In variableDeclaration, the lookup for "x" with findMember will return -1, and instead code for checking against arguments using indexOfArgument is needed. The easiest fix is to simply use identifier(), which handles this accordingly. Change-Id: I6a738d6196d4bff1fc987f111aebbaa83ed8f88f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix determination of lookup mode in V4 code generatorSimon Hausmann2013-10-114-43/+39
| | | | | | | | | | | | | | | | | | In order to determine the type of lookup we need (name or directly in environment members), we used Codegen::_mode, which is set to the currently suitable mode depending on the function (parameter to defineFunction). However that's not quite correct, the look-up mode depends on the function itself, not where it was called from. This patch corrects that by moving the compilation mode into the Environment itself. This is needed by follow-up patches. Additionally the "bool deletable" parameter to the builtin_declare_vars was always set to false, because it used mode instead of _mode, which was never set to Eval or QmlBinding. This will be cleaned up in a future patch. Change-Id: I878f187945e5de091689ab5d70a0f33eb5a9e38f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix crash in duplicate labelled statement checkSimon Hausmann2013-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | Testcase (part of parserstress in tests/auto/qml): outer: { do { inner: {} } while (false) } The labelled statement visitor, when hitting the outter label, would call enterLoop(), which sets _labelledStatement back to zero. That then gets added to the Loop object the do-while loop creates, and the duplicate labelled statement check then for inner would unconditionally dereference loop->labelledStatement. In all other places where we access loop->labelledStatement we have a null pointer check, so let's have one here as well. Change-Id: I9d5925a2abf4db691c49c0cdec3550938ee02efa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix possible crashesLars Knoll2013-10-111-4/+9
| | | | | | | | This can (and does crash) when a gc gets triggered during the linking stage of a compilation unit. Change-Id: I06f1299adab68ff8e0a4755d02e246870797e7f2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimise code generation for convertTypeToSInt32Lars Knoll2013-10-111-5/+52
| | | | | | | | Add 64 bit code patch and avoid some duplicated calculation in 32 bit mode Change-Id: I0e111de8ac4e733aa8802c49b4b15d785688d7ea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix build on Android with -developer-buildSimon Hausmann2013-10-111-2/+2
| | | | | | | | | | | | That configuration implies -Werror for some kind of warnings. This patch fixes * Mix of different types in conditional (qv4isel_masm.cpp) * Noreturn function returning instead of calling another noreturn function at the end (qv4engine_cxxabi.cpp) * An out-of-line function being declared inline Task-Number: QTBUG-33998 Change-Id: I3ba58dcadeac6774c5de63e6bb551354a2f23332 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Mark strings stored in the lookupsLars Knoll2013-10-111-0/+2
| | | | | Change-Id: I4cb72a3eee9f87305316137b0a1bfd4a003de840 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Small optimisation for bit shift operationsLars Knoll2013-10-112-6/+6
| | | | | | | | | We don't need the right side of the shift operation as uint. Converting it to int is cheaper and more then enough, as all but the lowest 5 bits are ignored anyway. Change-Id: I8833e6cc4e565b8bd1e35a22250e03a9b34938df Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add support for showing disassembled ARM JIT codeSimon Hausmann2013-10-101-1/+1
| | | | | | | | | | Ported the ARM disassembler from upstream trunk. QtQml needs to be configured with qmake CONFIG+=disassembler and QV4_SHOW_ASM=1 enables the dump at run-time. Change-Id: Ia13a98835829fde0d3c5a795cb8f6ef9de951807 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 JIT: ISel for bitwise or/xor.Erik Verbruggen2013-10-102-9/+63
| | | | | | | Removes another 4mln calls when running v8-bench.js. Change-Id: I7fd777e4e6303f989391c4d1e361277cc24b37e8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 JIT: generate some strict (not) equal conditionsErik Verbruggen2013-10-103-31/+186
| | | | | | | | | | | Checks for strict (not) equal to null, undefined, or a boolean value can be generated without reserving extra registers, or doing a call. This reduces the amount of runtime calls from >25mln to ~6500 for v8-bench.js Change-Id: If08d1124b2869227654b1233a89833c5b5e7b40c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 JIT: do not generate inline fall-back code for strings types.Erik Verbruggen2013-10-101-1/+3
| | | | | Change-Id: I30ac6fcbc7d03f412ff03e87f2ecf61fd2617108 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: Remove more jumps.Erik Verbruggen2013-10-106-1/+55
| | | | | | | | | | | | | | | | | | | | | Do not generate jump instructions when the target immediately follows the current basic block, even if there are intermediate jumps in between as long as they jump to the same basic block. In the IR snippet below, no jumps will be generated at all. … L8: goto L6; L12: goto L6; L6: goto L4; L11: goto L4; L4: goto L2; L10: goto L2; L2: …. Before this change, the gotos in L8, L6, and L2 were still generated. Change-Id: I718ed0d41c603a6905f2279b782cd9e9cafb7d55 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QStringRef has toInt(), so no need to create a new QStringThiago Macieira2013-10-071-5/+3
| | | | | | | | Saves up on memory allocations. Change-Id: I0f7c82521b0b10085861fc62fed9b9d591169b5a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 JIT: enable register allocator for linux/x86.Erik Verbruggen2013-10-041-1/+7
| | | | | Change-Id: I9424838139a419beb2e207f168fc25c0c47c64e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 JIT: fix visitRet for 32-bit architectures.Erik Verbruggen2013-10-041-10/+43
| | | | | Change-Id: I004fe8d5de0f5a932c23393ed06a04738b8e8bf1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get lookups working (somehow) on ARMPetr Nejedly2013-10-031-1/+7
| | | | | | | | | | | Edit(Simon): This is a workaround for the register clash on ARM. r0 (ReturnValueRegister) is also used to pass the first argument, therefore we can't use it as "temporary" register for the duration of the parameter setup. Temporarily allocate r8 for now until we have constraints like these properly propagated into the register allocator. Change-Id: Iae266672856dea247b720367b8e8393333622e4e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup exception handlingSimon Hausmann2013-10-031-1/+0
| | | | | | | | | | The code in the Exception class operates entirely on the engine's data, so move it into ExecutionEngine instead. This eliminates the need for a QV4::Exception class and catches and old code that tries to still do catch (Exception &) instead of catch (...) Change-Id: Ie608bec6af652038aca6c9423c225a4d7eb13b39 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use a QVector instead of a QListLars Knoll2013-10-035-15/+20
| | | | | | | | This makes the code go quite a bit faster (saves ~7-8% of the total amount of instructions executed when running crypto.js Change-Id: I6b3bd08eca98b45593262e2fc6e0ce5056257e76 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 JIT: implement convertUInt32ToDouble on ARMv7.Erik Verbruggen2013-10-032-22/+0
| | | | | Change-Id: I11caf07a8776bb2c6527639f22d47103f4ca1cef Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: fix dead-code elimination.Erik Verbruggen2013-10-031-93/+109
| | | | | Change-Id: If00a108fb107d331478dd36ad7feae4c4521c2ae Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: invert conditions when the true block follows the test.Erik Verbruggen2013-10-034-23/+48
| | | | | Change-Id: I5044acd4263b71734e4eb5d7e74b1a4a8414741e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change exception handling APISimon Hausmann2013-10-021-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the exception handling API in the engine slightly, encapsulating any use of direct throw statements and catch blocks with concrete types. In the future we need to be able to change the way these are implemented, in order to ensure that the correct stack unwinding code is triggered for throw and re-throw. This patch separates the C++ exception object thrown from the V4 exception (that includes value, throwing context pointer) and stores the latter inside the engine. In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to move into the QV4 namespace directly. In addition the syntax for catching exceptions changes from try { ... } catch (QV4::Exception &ex) { ex.accept(context); QV4::ScopedValue exceptionValue(scope, ex.value()); } to try { ... } catch (...) { QV4::ScopedValue exception(scope, context->catchException()); } Context::catchException() checks if there's a "current" exception in the engine, and if not assumes that we caught an unrelated exception and consequently re-throws. partiallyUnwind() is also gone and replaced with rethrowException(), in order to encapsulate the re-throw. Lastly, in the future nesting try/catch blocks isn't going to be possible due to limitations in the common C++ ABI with regards to foreign exceptions. Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove some more uses of QV4::ValueLars Knoll2013-10-022-11/+11
| | | | | | | All remaining uses should be GC safe now. Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more uses of ValueLars Knoll2013-10-028-44/+43
| | | | | Change-Id: I889e760f75b485a28e1f2a2c26b2337ae9bfafac Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 IR: fix type inference.Erik Verbruggen2013-10-021-0/+8
| | | | | | | | | | | | | | | | | | When a phi-node couldn't be fully typed (e.g., when one of the temps was not yet typed), VarType was assumed. When a circular dependency between two phi-nodes occurred, like with a condition inside a loop, then depending on the ordering of the work-list, the two phi-nodes could start oscillating between VarType and the correct type. The fix is to check if one of the temps is not fully typed, and if so, assume whatever we currently have as the result and have the statement re-scheduled. Full typing will occur when the temp with the missing type information is typed. Change-Id: I950d81fe7fa8272cb37f7eea5b88092d1eb4817e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compilation on Android with 4.8 toolchainLaszlo Agocs2013-10-011-0/+6
| | | | | Change-Id: I1ce4ec8c9c671f0130c1530c772c1dd74f1fb1f4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix invalid alias error reporting in new compilerSimon Hausmann2013-09-303-6/+52
| | | | | | | | Match exactly the VME code path by reporting the right type of error as well as the right hand side of the alias binding if necessary. Change-Id: I35d192a20641e0acbf25d20f3dc5fb53cc7cbae5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix error message for group property definitions on signals in new compilerSimon Hausmann2013-09-301-3/+4
| | | | | | | | | | | | | It may happen that people forget the colon after the handler name in onSomeSignal { code here } and we have to print out the correct error message. It looks like a group property, but we can identify this binding due to its reserved use of starting with "on". Change-Id: I7c502c1a2a5f2a6c613879468a60bc57a7d20fe8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix error messages when assigning to non-existent properties in new compilerSimon Hausmann2013-09-301-1/+1
| | | | | | | | | Introduce a simple valdator pass early on to catch those assignments. Also fix storing the correct line/col for default property object bindings and remember the minor/major version of an import in the final type reference. Change-Id: Ib2a93dfe1a30fcd9c09b5443fb8199ad11b19769 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix line/column in import related error messages with the new compilerSimon Hausmann2013-09-301-2/+2
| | | | | | | | Grab the line/column from the import token, not the import id token, as the latter is not always present in all import statements. Change-Id: Iaa0c2f1d60422fb779fa7a6c4fd1c895fa3f777b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Compile imported scripts in the loader threadSimon Hausmann2013-09-302-1/+7
| | | | | | | | | | | | | | | | | This has the benefit of blocking the GUI thread less and speeding up type creation in the GUI thread (for types that import js libraries). This patch also brings one behavioral change: Due to the parsing at type instantiation type, things like syntax errors for script imports would only generate a run-time warning and the code in the QML file would just see "undefined". Errors in the script now generate real errors at component compilation time, meaning the errors come out earlier and as real errors. This patch implements the separation for the VME only (to keep the size of this patch small). Change-Id: I82f7f3a2d3d4524ea12a7ab62abd8640aba6a47f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: do type inference/propagation before optimization.Erik Verbruggen2013-09-301-40/+90
| | | | | | | | | | | | | This gives slightly better results for inplace increment/decrement, where the operand has to be converted to a number. When that operand is known to be a number, this conversion can be removed. By doing the optimizations after typing, these conversions will not only turn into assignments, but they will be propagated through the IR. That saves a copy/move, which, in turn, will lighten the work for the register allocator and the instruction selection. Change-Id: If76575a71fbcb2d810b94060e61b4364bdaaa065 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: remove inplace operationsErik Verbruggen2013-09-3012-334/+86
| | | | | | | | | Inplace operations are expanded when building the IR, so the neither the IR, nor the instruction selection backends or runtime need to handle them. Change-Id: Id01f9544e137dd52364cf2ed2c10931c31ddfff3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: changed environment variable SHOW_CODE.Erik Verbruggen2013-09-302-2/+2
| | | | | | | | | Use QV4_SHOW_ASM for the generated assembly from the JIT, and use QV4_SHOW_IR to get dumps of the IR. Change-Id: Id85d3d6c87b47088c312475a7c737d54c58c7791 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 regalloc: fix the case where too few regs are available.Erik Verbruggen2013-09-282-6/+16
| | | | | | | | | | When all registers are allocated, and a new range gets active, some other range will have to be split and spilled to the stack. This gets slightly more complicated when the temporary is defined by a phi-node, so in that case, the temporary is immediately spilled. Change-Id: Iaab8b8e88849866e5841ae752377796e8540e30f Reviewed-by: Lars Knoll <lars.knoll@digia.com>