aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4ssa.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Enable constant propagation for all typesLars Knoll2014-03-191-13/+20
| | | | | | | | | So far constant propagation was only enabled for numbers and booleans. Enable it for all types now and make sure the propagation does the right thing. Change-Id: I202b0073f463d8a42e34931a736544207284b6dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup our runtime methodsLars Knoll2014-03-111-8/+8
| | | | | | | | | Move all our runtime methods into the QV4::Runtime struct and give them nicer names without underscores. Sort them logically and remove a few unused methods. Change-Id: Ib69b71764ff194d0ba211aac581f9a99734d8180 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 SSA: remove unused code.Erik Verbruggen2014-03-081-49/+1
| | | | | Change-Id: I56b3e5400e7b9880b9534117ac17a80436ff1733 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix more MSVC2012 compiler warnings.Erik Verbruggen2014-03-071-4/+7
| | | | | | | All are conversions from size_t to int or to unsigned. Change-Id: Ic94c938dcad6d50a32dd6ec62da2341869cf994d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-58/+58
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Really eliminate a|0 and b&(-1)Lars Knoll2014-02-221-8/+8
| | | | | | | | The old code wasn't doing what it promised to do and failed to remove these expressions. Change-Id: I6718539fd528f293db537e47ff1c9ac4b27ada55 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Mask rhs of shift operations in the IR for constantsLars Knoll2014-02-221-0/+12
| | | | | | | Saves an instruction for shifts with contants Change-Id: Ia12355d2fe2b9f80631056cda5edd79b45189e99 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused text streamLars Knoll2014-02-221-3/+0
| | | | | Change-Id: I23a1f5f2c6f782fab315db4725412a9473178b70 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove some code duplicationLars Knoll2014-02-221-85/+27
| | | | | Change-Id: If336731a49bcb5e1812d50a39cb97e263f23b183 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup: Pass the function into the various SSA stagesLars Knoll2014-02-221-37/+33
| | | | | | | | Pass in the function object instead of the variablesCanEscape flag. Cleans up the code a bit. Change-Id: If2d24b30fb223fa03e27f75f40ad42b881b2b3a0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-02-181-1/+2
|\ | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4functionobject.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h Change-Id: Id164f6c3b45501aa466908659ec4e3b957323753
| * Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2014-02-111-1/+2
| |\ | | | | | | | | | Change-Id: I5ac68cc3ad3926190817f0d3d5b4526e70badff6
| | * Remove static initialization of QObjectsv5.2.1Eskil Abrahamsen Blomfeldt2014-01-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statically initializing QObjects will cause e.g. the main thread pointer in QCoreApplication to be set when the library is loading. On Android, this is never the real main thread. The effect was a warning about QApplication not being initialized on main thread, and a race condition which sometimes caused apps to hang on startup. [ChangeLog][Android] Fixed possible hang on startup for Qt Quick applications. Task-number: QTBUG-36426 Change-Id: I7bd8a8f35ef1a2548949978563e3157f8dc854c7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | | V4: Do not reverse-propagate int32 conversion through unary minus.Erik Verbruggen2014-02-141-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | Conversion to int32 might truncate, and because int32 is two's complement, INT_MIN might get converted incorrectly. Change-Id: Iaf893d3bd619f4c5791654e609f96cffca5c6917 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4 IR: remove unused phi targets.Erik Verbruggen2014-02-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove all phi nodes whose target temps have no uses. This obvious optimization was missing. Change-Id: I24354e225ba7b01a3c2a6f4b2e40dd78d6ee3d7d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4 IR: changed worklist used while doing optimizations.Erik Verbruggen2014-02-141-36/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the worklist in the optimizeSSA function to allow only one entry for a statement. This prevents re-processing a statement multiple times, and could lead to crashes when the statement was removed in an earlier pass. Change-Id: I2f09cf74525cfe19708ec7a8bc6d555218625e87 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-02-111-3/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/jsruntime/qv4arrayobject.cpp src/qml/jsruntime/qv4context.cpp Change-Id: Ied5b23bec4dc14abe51127c507aed668f855c1e1
| * | V4: fix range sortingErik Verbruggen2014-01-311-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a life-time interval is split from another interval, it has to come before an interval that starts at the same position but is not split. This also means that a means that the all ranges in a split interval are uses, which is important for allocation: all incoming parameters for an operation need to be allocated before allocating a register for the result as the result will only start its life "at the end" of the operation. This patch fixes a problem register allocation is done in a function where register pressure is high (e.g. on platforms that have few registers to start with). Specifically, crypto.js on x86 triggered it. Change-Id: Iee3e5d82a887b8de573dfc23513844143d0c8073 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * | V4: remove unused field.Erik Verbruggen2014-01-291-5/+3
| | | | | | | | | | | | | | | | | | Change-Id: Id1edc073db349cfc7e4b5a9dca045760016ebacf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* | | V4: stack slot allocator for the interpreter.Erik Verbruggen2014-02-071-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the life-time intervals to track which temps go out of scope, in order to re-use the stack-slots they occupied. This reduces the memory consumption on the JavaScript stack and allows for deeper call stacks. For the ECMA tests, this reduces the number of slots needed for the main/entry function from more than 650 to about 10 (depending on the test). Change-Id: Iff4044f5ff7f25e1f88ff1a04f4e80dd99a67590 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4: fix life range for phi node target that is never used.Erik Verbruggen2014-02-071-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | When a temp is defined by a phi-node, but never used, still insert the (very short) life range. Change-Id: Ia976f496736a1606108fab7597c5d90048d9d55a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4: remove unused field.Erik Verbruggen2014-01-301-5/+3
|/ / | | | | | | | | | | Change-Id: Ic62ac6be99b79aa2f8c37fc386fef6b04b480247 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* / V4: fix range splitting when split is between intervals.Erik Verbruggen2014-01-171-8/+39
|/ | | | | | | | | | | Also added some "white-box" unit tests and sprinkled in a bit of documentation. The case that went wrong is covered by the test rangeSplitting_1: before the fix, the new interval would have two ranges: [66-64],[70-71]. The first range is invalid and should not be there at all. Change-Id: If0742f4e6a96d98ea5d696f95126886ba66f92bb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 IR: do edge splitting after SSA transformationErik Verbruggen2014-01-161-8/+58
| | | | | | | | | | | | | | | This reduces the work for the dominator tree/frontier calculations, because there are less blocks to consider. All blocks inserted by splitting the critical edges, have (by definition) no effect on the dominator calculations. However, the immediate dominators for all new blocks needs to be added, because this information is used by the block scheduling. This change reduces memory/time usage during optimization passes, especially when processing excessively big switch statements. Change-Id: Ia69882e9dabdddffa1c98b1079012d8d988e1e8f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: lower memory allocator pressure.Erik Verbruggen2014-01-161-12/+18
| | | | | | | | | | | | | Changes to datastructures and more re-using of locally used temporary vectors. For the test regress-74474-002.js this lowers the total allocated memory from 1.98GB to 158MB. Thse peak memory usage stays at 75MB. There is no functional change. This should give a modest performance improvement which mainly depends on the speed of malloc()/free(). Change-Id: I1877c1903e59a33ee79ff2b801ef6f2c1cee30a6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 IR: update immediate dominators when purging unreachable basic-blocksErik Verbruggen2014-01-161-13/+19
| | | | | | | | | The basic block scheduling uses this information to place loops. When the immediate dominator information is invalid, the scheduling can be sub-optimal, or will sometimes forget to schedule some blocks. Change-Id: Iaeb45f2b757b676310be25a658ceadc07d5722ec Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: remove unnecessary spills and order them correctly.Erik Verbruggen2014-01-161-9/+13
| | | | | | | | | | | | | | | | | | | When doing edge resolving, too many spills were generated, and the dependency tracking of moves was not complete. Now we only insert spills that are caused by phi-nodes (because any other spill would be generated at the point a variable was defined). However, there can still be multiple dependencies between the moves generated by the edge resolving. Instead of only checking the first dependency, all of them are tracked. The bug report was a case where an unneccesary spill was generated, that got tracked, but "suppressed" the other (valid!) dependent move. The randomness was caused by the hash seeding of QHash. Task-number: QTBUG-35840 Change-Id: Ifbc3c8fc13de53c46a8b5859721b2497189921a3 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: optimize dominator frontier storage.Erik Verbruggen2014-01-081-7/+164
| | | | | | | | | | | | | | | | | | Changes the dominator frontier storage from a set of basic-blocks for every basic-block to a BasicBlockSet for every basic-block. This new class stores a maximum of 8 nodes in a vector, and switches to a bit vector when going beyond 8 nodes. This is important in two cases: most basic-blocks have 2-3 nodes in the frontier, and an array is faster than a set in these cases. The few cases where the frontier goes beyond 8 nodes, is when a switch statement is used with lots of cases that all fall-through. On regress-74474-003.js this reduces peak memory usage from 1.68G to 60M. The switch statement in this test results in 27000 basic-blocks. Change-Id: I42646522ba9f8642d42a5d70fc6b760bb47ae69f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: remove class field in DominatorTree that was used only once.Erik Verbruggen2014-01-021-21/+18
| | | | | | | | | Calculation of all the children of nodes in the dominator tree is now calculated as a local variable right before computing the dominator frontier. The effect is that they are not retained after their only use. Change-Id: I83c962c691b78cb767708eb04cf30d3b7a760deb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: do not add unconditional jumps to work listsErik Verbruggen2014-01-021-1/+4
| | | | | | | | | | Both type inference and the optimization pass do not do anything with unconditional jumps. So, instead of adding them to the worklist and later on removing them again, it’s faster to never add them in the first place. Change-Id: Ib81d43e9ea6df2b1a70e9dd1e9b9c29cb6d345d2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: change datastructures for dominator calculations.Erik Verbruggen2014-01-021-112/+172
| | | | | | | | Replace hashes from basic-block to basic-block with vectors that associate basic-block index to basic-block index. Change-Id: I834ea3d825e4d2b02c075b1b0f080f5a65f41317 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* V4 SSA: add some more literature references.Erik Verbruggen2013-12-191-5/+13
| | | | | | | Also fixed some comments. Change-Id: I4aedff84bdbf8de248025bc48805a859704bdd8a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: change block scheduling algorithm from recursive to iterative.Erik Verbruggen2013-12-121-102/+189
| | | | | | | | This makes time- and memory-complexity a lot better when compiling big JavaScript functions. Change-Id: I2a7cb9b5979844254747fa5cf7355cca0b113904 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* V4: change variable renumbering algorithm from recursive to iterative.Erik Verbruggen2013-12-101-89/+237
| | | | | | | | | Replace the recursive calls and subsequent clean-ups by pushing actions on a to-do stack, and processing that stack in a loop. Change-Id: I83536e88d400592b6e9f5fda3d795e41711a131a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* Clean up property dependency data structuresSimon Hausmann2013-12-051-3/+4
| | | | | | | | | | | | | | | | As a follow-up to the previous commit, this patch cleans up the data structures used to track dependencies of QML binding expressions and functions to context and scope properties, determined at compile time. Instead of "collecting" these depending properties upfront (codegen time), we propagate the information that a property is a context or scope property into the IR at codegen time and later in the isel collect these properties and their notify signal index in a hash in the IR functions. The CompileData structure generator then can read these hashes directly when writing out the dependency information. Change-Id: I32134706e2d24bf63d1b1abad0259ab072460173 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: reverse propagate int32 truncation.Erik Verbruggen2013-12-041-112/+271
| | | | | Change-Id: I5cb0c7798d0e530f3137710bf0e723bd7b64dc89 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 IR: remove common toInt32 casts.Erik Verbruggen2013-12-031-2/+29
| | | | | | | | | | | | | E.g.: a | 0 b & 0xffffffff These operations force the operands to be converted to int32 without changing their value. At this point we already added convert calls to the IR, so we can safely get rid of these operations. Change-Id: Ic4d3b989e13439eccd2c878fa7bf5030acae7630 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: change the worklist to a QSet for block scheduling.Erik Verbruggen2013-12-031-4/+4
| | | | | | | Fixes a crash in octane. Change-Id: Ib72ac0b7a2941230a87543f30fcf7e55d7094886 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Slightly accelerate access to value type propertiesSimon Hausmann2013-11-281-5/+1
| | | | | | | | | | | We can't do a fast property index based access on them, due to the inability to read individual fields from the original object (i.e. the logic in QQmlValueTypeWrapper). However what we can determine and propagate is the type information of the individual properties, i.e. that the x and y properties of a QPointF are always doubles. Change-Id: Iee71ece2117294b7bc0b93deb0a77d7c51148b11 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add support for accelerated property access to QML types and namespace supportSimon Hausmann2013-11-281-4/+14
| | | | | | | | | | | * Resolve lookups in namespaces at compile time and instruct the SSA optimizer to eliminate reads from the namespace (QQmlTypeWrapper) if possible. For example access to attached properties of types (i.e. MyNameSpace.ListView.isCurrentItem) requires neither reading the namespace nor the type. * Add support for accelerated lookup of attached properties Change-Id: Ib0b66404ed7e70e1d4a46a1ac8218743a4cc8608 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initial support for accelerated property access to QML singletons and enumsSimon Hausmann2013-11-251-0/+13
| | | | | | | | | With this patch we determine the meta-object of singletons, propagate it into the IR and load them separately using a dedicated run-time function. In addition enums in singletons and QML types are resolved at compile time. Change-Id: I01ce1288391b476d1c9af669cb2987a44c885703 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup, get rid of MemberOfQObject V4IR::Member specializationSimon Hausmann2013-11-251-1/+1
| | | | | | | It is technically redundant to the Member::property field. Change-Id: If0ee35b2c94a2c9373784d36a1f8dfe8ad7dcfb3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Improve type interference for QObject propertiesSimon Hausmann2013-11-251-46/+64
| | | | | | | | | | | | | | | | | | | | | | | | Propagate QObject properties in member expressions across temporaries as part of the type interference SSA pass. This replaces the earlier attempt to resolving QObject properties in fieldMemberExpression() in the codegen, but it was incomplete and now things like the following are fully resolved: var tmp = blah.somePropertyThatReturnsAQQuickItem; <-- QQuickItem property return type propagated into tmp var width = tmp.width; <-- and picked up here again to resolve the index of width instead of by name With this patch Temp gets a helper structure with a function pointer, initialized to aid the resolution of properties in Qt meta objects. This structure is propagated into the temps until it reaches the next member expression that uses the temp. Similarly QObjectType is added as IR type, next to VarType. The resolution inside the SSA type interference pass also requires passing through the QQmlEngine from the upper caller levels, in order to resolve the property type to a potential QMetaObject property. Change-Id: I14c98fa455db57603da46613ce49c174d0944291 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4: remove failing assert and fix code.Erik Verbruggen2013-11-191-3/+3
| | | | | | | | | | Assert failed for cases where the node’s ancestor with lowest semi-dominator number was not the same as the parent. The test case exemplifies this. Task-number: QTBUG-34792 Change-Id: Ie6847b22a27211801bff7479bfcbfaf329c6005a Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* V4 SSA: speed up dominator calculations.Erik Verbruggen2013-11-181-63/+137
| | | | | | | | | | | Changed three recursive routines to worklist-based iterative ones. This not only speeds up the dominator frontier calculation, but also prevents the algorithm to run out of stack space. This is a partial fix for QTBUG-34047. Change-Id: Ife8dc35724d50408ad356e1621884bdb82db9626 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: change basic-block cleanup to remove unreachable cycles too.Erik Verbruggen2013-11-121-22/+57
| | | | | | | | | | | | | | | | | | | | The previous version left unreachable cycles untouched. For example in: function f() { if (false) while (true) { doSomething(); } anotherThing(); } The edge to the then-part would be removed, but the loop itself would not be removed. This resulted in the basic-block scheduler choking when hitting the block with the anotherThing() call, because it wants to have all blocks from incoming edges resolved first. Task-number: QTBUG-34776 Change-Id: I5b3a79140e6058c4ade4ec7687c1a795f1a74f97 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
* Fix rounding behavior of Qml when assigning doubles to integer propertiesSimon Hausmann2013-11-051-8/+6
| | | | | | | | | | | | The engine used to round, but that is inconsistent with ECMAScript's way of converting doubles to integers by truncation. With this patch we can also enable the propagation of integer type information into the IR, but we have to be careful not to utilize it when writing properties. Change-Id: I04af4879ba5131349eca2eeff2b27f4598f5267b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-17/+5
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Propagate bool/int/double/string types from QML into the IRSimon Hausmann2013-10-311-3/+34
| | | | | | | | | | | | | | | ... by mapping the property type to the IR type if possible. In an expression like parent.width * 0.5 this avoids a to-double conversion for parent.width but instead we can rely on the result of the property read for the width property to always be a double. Unfortunately integer propertyes are currently not propagated, because upon assignment from a double we would do the ECMAScript compliant truncation while QML actually expects a round to happen. This needs to be solved separately. Change-Id: I9c8f58416201d406e6e11d157cae12a686b774e5 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Rework exception handlingLars Knoll2013-10-291-11/+12
| | | | | | | | | | | | | | Start the work to remove c++ exceptions from our JS exception handling. Rather rely on engine->hasException. Check the flag after we return from any runtime call in the JIT. Implement new try/catch handling code in qv4codegen and for the JIT that doesn't rely on exceptions. As an added bonus, we can remove the Try statement in the IR. Change-Id: Ic95addd6ae03371c43c47e04cac26afdce23a061 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>