aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
Commit message (Collapse)AuthorAgeFilesLines
* v4: Enable primitive conversation to QQmlScriptString in javascriptSebastian Sauer2014-08-222-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes following QML-code proper working: ParentChange { x: 0 Component.onCompleted: x = 10 } where x is a QQmlScriptString. Before this patch an error-message would be thrown that the bool/int/string/etc cannot be converted to a QQmlScriptString. With the patch primitive types including null and undefined are proper converted to a QQmlScriptString. The patch ignores (as in not implements) function/binding assignment. Unfortunately since commit aa25ad8d5f4 its not possible any longer to instanciate QQmlScriptString what means there is otherwise no (easy) way to inject a QQmlScriptString from within Javascript. Change-Id: I18aac6a6e9a57f3b7d0a2d66cdab2be6c3c153c5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 IR: Add loop peeling.Erik Verbruggen2014-08-183-23/+243
| | | | | | | | | | | | By peeling the first iteration off of a loop and putting it in front of the loop, type inference can deduce more type information for esp. loop induction variables. To prevent increasing the code size too much, only the inner-most loops are peeled. This gives a 10% speed-up on crypto.js. Change-Id: I57f9611695bc8defc0bff84e440b8a20b2c8a34e Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* V4 IR: add immediate dominator re-calculation.Erik Verbruggen2014-08-183-98/+276
| | | | | | | | | When removing edges, the control-flow graph changes, so some immediate dominators might need to be updated. This change collects all candidates and processes them in a single batch. Change-Id: I928f42232427a84bcb9658e314dadd0bd021b12f Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* CleanupSimon Hausmann2014-08-157-121/+118
| | | | | | | | | Merge QV4::CompiledData::QmlUnit into QV4::CompiledData::Unit. For pure JS units it means a slight increase of memory usage by a few bytes, but overall it makes the code a lot simpler. Change-Id: Ib48927749720b056f004aac0fe22cb8ec729e3f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* V4 IR: change IR printing to be more readable.Erik Verbruggen2014-08-133-127/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New structure: - "comments" now start with a semi-colon, and have a list of key: values. ; predecessors: L17 L26 L36, loop_header: yes ; line: 30, column: 3 - when a temporary has a known type, it is written in front of the teporary when it is being assigned, and not repeated. var %109 = this double %42 = 42 - an expression starts with the operation, followed by the operands that are separated by commas. The type of the operands is the type mentioned when they are assigned. int32 %115 = sub %184, %185 if gt %27, 0 goto L40 else goto L41 - conversions do mention the operand type in order to make them easier to read. double %178 = convert var to double %60 - phi node operands are prefixed by the from-label to make it easy to match those operands with the from-block. double %62 = phi L35: %58, L34: %61 - all names except for "this" and built-ins are prefixed by a dot in order to make it clear that a lookup will occur, just like member accesses. $6 = call .int2char($0) %7 = this %8 = %7.toString() Change-Id: I9f626a91f97ca7c3f27e01a5539f3c4fc10a46b4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4Simon Hausmann2014-08-121-6/+8
|\
| * Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-08-121-6/+8
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4include.cpp src/quick/items/qquickrendercontrol.cpp src/quick/items/qquickrendercontrol_p.h src/quickwidgets/qquickwidget.cpp Change-Id: Ib2dc0051a38cd283a37a7665eb4a76f6f7ec8b15
| | * Fix crash when loading invalid QML with behavior on invalid group propertySimon Hausmann2014-08-081-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Behaviors require the creation of a meta-object. However when trying to create a behavior on a non-existent group property, we don't have a base meta-object to base the "new" meta-object on, therefore this patch adds a null pointer check. The error in the QML file itself will be caught later on. The added test ensures that as well as that it doesn't crash of course. Change-Id: If73116053464e7e69b02ef59e8387060835083c8 Task-number: QTBUG-40369 Reviewed-by: Sérgio Martins <sergio.martins@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4 JIT: tune generated instructions for inplace binopsErik Verbruggen2014-08-121-4/+13
|/ / | | | | | | | | | | | | | | | | | | Generate better code for in-place binary operations where the right-hand side is either a constant or a memory address. Now that the JIT can do this, also tell the register allocator not to un-spill that right-hand side. Change-Id: I0ab852f6b92f90dfed99c05fbaf91aad2549ecf4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: extend BasicBlockSet functionality.Erik Verbruggen2014-08-081-4/+72
| | | | | | | | | | | | | | To be used in later patches. Change-Id: I379addaea225482bcbfd7a0b03dbdbaa254dd579 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4: add more line number information.Erik Verbruggen2014-08-082-52/+57
| | | | | | | | | | Change-Id: Ibd3e747918dc0bc939fcbd173585fb1e4d4f08fb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add support for conditional breakpoints and evaluate.Erik Verbruggen2014-08-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Also centralized the context state saver and added line number saving, so that the JS jobs for evaluation of breakpoint conditions don't change the state of the current engine context. Task-number: QTBUG-37119 Task-number: QTCREATORBUG-11516 Change-Id: Ia21b3d64e239e5b67f3c07e1c006d8e6748f29b6 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Accelerate property lookups for C++-based QObject singletons.Michael Brasser2014-08-077-8/+22
| | | | | | | | | | Change-Id: Icbdf06a077014db5dd57cba42f84591433ec4196 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make ssa compile on Android with gcc 4.6Laszlo Agocs2014-08-041-14/+15
| | | | | | | | | | | | | | | | | | | | | | Avoid errors like compiler/qv4ssa.cpp:660:59: error: no matching function for call to 'sort(QVector<QV4::IR::BasicBlock*>::iterator, QVector<QV4::IR::BasicBlock*>::iterator, (anonymous namespace)::DominatorTree::calculateDFNodeIterOrder() const::Cmp)' Change-Id: I4189bd621f1cef5e00b06f5b6b6dd430fefe653f Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-291-2/+2
|\| | | | | | | Change-Id: Id95f7b01de36bccecbb7b73acc041654a1fe2ebe
| * Fix interaction of garbage collector with JS objects during QML type ↵Simon Hausmann2014-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instantiation It may happen that during the lengthy process of instantiating a tree of objects for QML, the garbage collector runs. For objects created by QML we support different ownership models, for example in QtQuick visual parents keep their visual children alive, despite perhaps a lack of QObject parentship. That ownership becomes active once the QML autoparent function has assigned the correct visual parent, which happens after object instantiation (after QQmlObjectCreator). Similarly when a composite type is created, its QObject parent is only set after all properties have been set. The root QObject is kept alive through a special boolean, but if the sub-objects aren't children yet, their JS wrapper might get deleted. For composite types with var properties, that also means their var properties get deleted, such as the model property of TableView.qml in the bug report. In the future we want to support creating QWidget hierarchies with QML, which also for layouts may rely on a delayed parent assignment for layouts. To accommodate all this, this patch introduces an array on the JS stack that keeps track of all JS wrappers for all QObjects created. This array is alive during object tree creation. Afterwards, the different ownership models take over, for example the auto parent function assigning a visual parent. This patch also fixes an off-by-one in the total object count calculation for composite types, where when instantiating a composite type as a sub-object we counted the sub composite's object count but forgot the object itself. Task-number: QTBUG-38835 Task-number: QTBUG-39966 Change-Id: I6104b2434510642081e0c54793ed296adeca7481 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge remote-tracking branch 'origin/5.3' into devSimon Hausmann2014-07-261-15/+26
|\| | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/jsruntime/qv4arrayobject.cpp src/qml/jsruntime/qv4engine.cpp Change-Id: Ie3ef6202b6a3a8521971e1be10c40c6a2db6989c
| * V4: work around a bug in libc++'s std::vector<bool>Erik Verbruggen2014-07-241-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ++operator of std::vector<bool>::iterator in libc++ has a bug when using it on an iterator pointing to the last element. It will not be set to ::end(), but beyond that. (It will be set to the first multiple of the native word size that is bigger than size().) See http://llvm.org/bugs/show_bug.cgi?id=19663 Task-number: QTBUG-39911 Change-Id: Ic244d9c90ee6b596261a6e322301c411a14820a8 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: loop detection: also record loop information separately.Erik Verbruggen2014-07-241-7/+133
| | | | | | | | | | | | | | | | Now loop-specific algorithms can easily query which blocks are loop headers, which blocks make up a loop body, and whether loops are nested. Change-Id: I442af34d3cca816b61ee761335ff3571b72a6d3e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: change dominator tree to hold on to less memory.Erik Verbruggen2014-07-241-59/+72
| | | | | | | | | | | | | | | | Move all data needed to calculate the immediate dominators into a struct that is freed immediately after finishing this calculation. Change-Id: Id0cefa4088643539d59c4c593cba1848422c1726 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: add IR verification functions.Erik Verbruggen2014-07-241-1/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - CFG verification: check if all edges are correctly registered on both the outgoing basic-block and the incoming one, and that jumps/cjumps targets correspond to outgoing edges. - immediate dominator verification: check if the current immediate dominators are the same as they would be if being recalculated from scratch. - no shared expressions/statements: check if not more than one IR node points to a statement/expression. Also add a function that writes out the CFG as a .dot file for graphviz. Will be used in upcoming patches. Change-Id: I784561f581f9f8ec22f3ab449afd87a9e7a8bdaf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: change debug code enabling to use compile-time constantsErik Verbruggen2014-07-241-50/+68
| | | | | | | | | | | | | | | | This will make sure that debug code gets compiled/checked, even when it is disabled. An optimized build will remove the code. Change-Id: Ia32de550ea95c44afa5ed84bc17cfeeada06f2f4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: copy arguments to temps at function start.Erik Verbruggen2014-07-233-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | When arguments cannot "escape" from the current context, and when the arguments array is not used, actual arguments can be treated the same as temporaries instead of memory locations. This has the benefits that they are subject to the same optimizations, and type deduction can assume that the value/type didn't change since its assignment. Another effect is that the values can be kept in registers, and loads from the stack take only 1 indirect load instead of 2 (from the formals array). Change-Id: I209da7991ec5d903b3c5acdbcaf6b1cc67502520 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | qml: Make ownership of CompiledUnit more clearHolger Hans Peter Freyther2014-07-212-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | The coverity scan utility didn't understand the code flow and assumed the compiledData would be leaked. Use a QScopedPointer and have the ::backendCompileStep() forward the ownership. From what I see the code has not leaked memory. Fixes: CID 10605, CID 10607 Change-Id: I7759f681871bbe12e2aa320a5f39c47c70f4e4e0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: (natural) loop detection.Erik Verbruggen2014-07-045-81/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We perform loop detection to be able to assign to each block its loop, an chain them up from inner loop to outer loop. The new algorithm works on each basic block just once, and looks at a basic block just the number of connections it has. As it relies on the dominator tree it is more robust on actually finding al looping constructs and only those rather than relying on the statements used. It assumes that a basic block is analyzed before the one that dominate it (to guarantee finding outer loop headers before inner loop headers), so blocks are ordered to work on them in a way that guarantees that, using dominator tree depth, that is trivially available. Loop detection allows us to then schedule the loop body before the part after the loop (the header dominates both so just domination cannot choose between both), and can be used to optimize loops (either unrolling the first iteration or hoisting constant parts out of it). It also helps with generated JavaScript code: in order to simulate gotos or other unconditional branches, nested labeled do-while(false) loops are often used in combination with break/continue to "jump" between "loops". Change-Id: Idfcc74589e057b191f74880ffd309d0a9c301811 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* | Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-021-0/+8
|\| | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf examples/quick/scenegraph/openglunderqml/squircle.h src/quick/doc/src/qmltypereference.qdoc src/quick/scenegraph/qsgthreadedrenderloop.cpp Change-Id: Ife4f4b897044a7ffcd0710493c6aed1d87cf1ef9
| * Fix Stmt:Data object leakLiang Jian2014-06-131-0/+8
| | | | | | | | | | | | | | | | | | call Stmt::destroyData() whenever a Stmt object is to be removed in BasicBlock to delete the Stmt::Data object hold in the Stmt object. Change-Id: I59c939d79b935153e6f8613e54f149120f5198f5 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | Allow integer values to be assigned QList<qreal> propertiesOleg Shparber2014-06-251-1/+1
| | | | | | | | | | | | | | | | Before this patch it was not possible to assign an integer value to QList<qreal> property, while it worked for non-list properties. Change-Id: Iab00288f7d78f4f76056ab4291700d7f51626de4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 JIT: add some documentation and literature references.Erik Verbruggen2014-06-191-0/+2
| | | | | | | | | | Change-Id: I67667b74672b94b951361bf2a446476edf44b826 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | V4 RegAlloc: simplify algorithm after introducing half open ranges.Erik Verbruggen2014-06-131-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that all ranges are half open, and temporaries are defined at the end of the (defining) statement, the linear scan algorithm get simpler. Specifically, when allocating a register for a temporary, the check if the temporary is defined or used is not needed anymore. Another simplification is the handling of phi-nodes. Previously they shared the same statement number as the first "real" statement in a basic-block, and special checks were needed to handle them. Those are now gone too. Change-Id: Ia4266ea5ede8c2aff0e70c6579fba9575c6719fb Sanity-Review: Qt Sanity Bot <qt_sanitybot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | V4 RegAlloc: change life-time intervals from closed to half-open.Erik Verbruggen2014-06-135-35/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two changes in this patch, that go hand-in-hand. First, when re-numbering the statements in order of occurrence in the scheduled basic-blocks, the (new) position is not stored in the statement itself, but in the LifeTimeIntervals class. This makes it possible to re-use information gathered during SSA formation or optimization. The re-numbering itself has also changed, resulting in some minor changes to the life-time interval calculation. The new numbering is described in LifeTimeIntervals::renumber(). The reason is to make it easy for the register allocator and stack-slot allocator to distinguish between definition of a temporary and its uses. Example: 20: %3 = %2 + %1 22: print(%3) If the life-time of %2 or %1 ends at 20, then at the point that %3 gets assigned, it can re-use the storage occupied by %1 or %2. Also, when both %1 and %2 need to get a register assigned (because they were spilled to the stack, for example), %3 should be allocated "after" both %1 and %2. So, instead of having a closed interval of [20-22] for %3, we want to use an open interval of (20-22]. To simulate the "open" part, the life-time of %3 is set to [21-22]. So, all statements live on even positions, and temporaries defined by a statement start at statmentPosition + 1. Change-Id: I0eda2c653b0edf1a529bd0762d338b0ea9a66aa0 Sanity-Review: Qt Sanity Bot <qt_sanitybot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | V4 IR: Store positions for life-time intervals outside the statement.Erik Verbruggen2014-06-065-36/+96
| | | | | | | | | | | | | | | | | | | | | | | | The statement ids are now stable, so the life-time interval calculation can re-use information calculated by the optimizer. This re-use will be done in a separate patch. It also allows for changes to the numbering in a non-intrusive way. This will also come in a later patch. Change-Id: Ie3a2e1d9e3537cc8070ff3e3007f3a5e8ca0579a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: add def statements to the worklist when removing uses.Erik Verbruggen2014-06-061-13/+11
| | | | | | | | | | | | | | | | | | | | When removing a phi node, add the def statement for the (previously) used temps to the worklist. These statements might now be eligible for further optimizations (specifically removal when there are no uses left). Change-Id: I05d7c7bc0a243d328b5f9d1c2dcc53a10bd7491d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove copy and accidental detach.Erik Verbruggen2014-06-062-3/+3
| | | | | | | | | | Change-Id: Iedd751424ff0b651ba9e00a30f50e197ecd7967d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 RegAlloc: store, pass, and use life-time intervals by pointer.Erik Verbruggen2014-06-053-36/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By storing LifeTimeIntervals by pointer (instead of by value), other data-structures can safely use pointers too. This removes a lot of copies, especially in vectors that act as worklists. Also change the order of the "unhandled" list of intervals to be sorted in descending order. Not only is this more efficient, but it also removes the need to reverse the results of the life-range calculation (which produces the list in exactly this order). This change speeds up register allocation by about 20%. Change-Id: I6ea3dcd110f250d9ccc881753dc7392510a26d87 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup: Get rid of the url and file name members in QQmlCompiledDataSimon Hausmann2014-06-054-7/+5
| | | | | | | | | | | | | | | | This is part of the effor of moving members from QQmlCompiledData into QV4::CompilationUnit in order to eliminate the former in the long run. Change-Id: Icce7fe0ee9a49cb3a7677fd7020008fc55ecdcf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-06-042-28/+47
|\| | | | | | | | | | | | | | | | | | | | | | | | | The merge conflict is about the removal of "d1" from the register set on ARM, but that was already done in dev in commit ddb33ee9ba9e1344caa9be5dbf4b534c3ede692e The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675eab163b22dcc4e8ded80ed04d06369b was reverted to what it was before, per Laszlo's advice. Conflicts: src/qml/jit/qv4isel_masm.cpp Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
| * Fix compilation on MSVC 2008Simon Hausmann2014-05-271-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We are using std::lower_bound on a vector where the item we search for is of a different type than the items in the container. MSVC 2008's STL is very happy to check all sorts of constraints and also compare the order of items within the container. That means it tries to call the compare function not only with the key we're searching and one item but also two items from the container. The existing compare function can't satisfy that constraint, so instead we'll go back to the old approach of a proper functor that operates outside of the class scope, in order to build with older compilers. That functor now offers all necessary overloads. Task-number: QTBUG-38873 Change-Id: I6f350106f98cb03a4ff7e1671a84e67f629cedd3 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
| * Fix crash when sharing data structures between 32-bit and 64-bitSimon Hausmann2014-05-261-23/+31
| | | | | | | | | | | | | | | | | | | | The data structures in QV4::CompiledData are intended to be shareable between different architectures (if endianness is the same). This requires us to pack them, which is possible with MSVC and GCC (which also includes clang) Change-Id: I078254b9d314f60f8973a0c9404f53af41a48fb8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Rework custom parser integrationSimon Hausmann2014-06-042-25/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The custom parser design used to be so that the custom parser operates on the "AST", creates its own binary representation of the data it needs, stores it in a QByteArray and gets that at object instantiation time. That meant serializing everything necessary. With the introduction of the "binary" QML data structure, that process of serialization becomes obsolete and would require extra work in the custom parsers for example for QQuickStates to store the translation parameters. The clean solution is to eliminate this unnecessary serialization process and instead let the custom parsers do a verification pass at type compile time and then simply operate directly on the QV4::CompiledData::Bindings at object instantiation time. That simplifies the code, and allows for support of translations throughout all list model properties. Additionally this speeds up the creation of state objects and reduces memory consumption. Previously a text: qsTr("foo") binding in states would result in an actual java script binding. After this patch it is merely stored as a string and translated at object instantiation time. Change-Id: I7550274513f54abb09a0ab4de51c4c0bcdb23cae Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | V4 IR: lower the number of memory allocations.Erik Verbruggen2014-06-031-24/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | By using vectors indexed on temp-id instead of hashes. Also record the order in which intervals are removed from the list of life ranges. This order is the inverse of the list of ranges sorted by start position. So instead of building _sortedIntervals and then sorting them, reverse iterating over the finished intervals will do the same. This speeds up the interval calculation by 40%. Change-Id: If3c78496d7ca2d0e23f0a51302dcd1094dad7d4a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4: support calling constants.Erik Verbruggen2014-06-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider: function f() { var a; a(); } Here the constant propagation will propagate the value for a (undefined) to the call site. This was not yet handled, resulting in Q_UNIMPLEMENTED warnings when running a debug build. Change-Id: I5f85f681d975b54df7a9e00bd5b50e6f4350139a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: make the local-with-temp substitution into a separate pass.Erik Verbruggen2014-06-021-0/+81
| | | | | | | | | | | | | | This makes it easier to turn it off when needed. Change-Id: I1a9f2882dd7a1ad7bc76143e3c44e4677e49357a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: clean up DefUses(Calculator)Erik Verbruggen2014-06-021-375/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the DefUsesCalculator was a pass over the IR to find all definitions and uses of temps. This is now merged with the variable renaming when transforming into SSA form, where all definitions and all uses are already visited (and changed). As it no longer calculates anything, the class is also renamed to DefUses. The interface is also cleaned up, as are all usages. This involved some small changes to the data-structures storing return values from DefUses. Change-Id: I40e665f5dee6144fc81066fbf6950355ebe8dfa4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: make statement numbering fixed and clean up statement worklists.Erik Verbruggen2014-05-284-179/+240
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Every statement in the IR now gets a fixed unique number. This number can be used to store statements or information for a statement into an array where the number is used as an index. This removes the need for many hashes. In the process of changing the code the two statement worklists in the optimizer are merged into one. A single instance can be (and is) re-used by the various algorithms. Change-Id: I8f49ec7b1df79cf6914c5747f5d2c994dad110b2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: replace QHash in DefUses with a vector.Erik Verbruggen2014-05-271-41/+65
| | | | | | | | | | Change-Id: Ibf21f5fe0f8ab035add5354f45f7869f4cdfead8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4 IR: removed a couple of hashes and sets.Erik Verbruggen2014-05-262-58/+92
| | | | | | | | | | Change-Id: I09f9aa1921745b9aa323349d90c334b156f690cb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | V4: Split arguments/locals from temps.Erik Verbruggen2014-05-2310-386/+417
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a couple of reasons to split the temporaries off from the arguments and locals: Temporaries are invisible, and changes to them cannot be observed. On the other hand, arguments and locals are visible, and writes to them can be seen from other places (nested functions), or by using the arguments array. So, in practice these correspond to memory locations. (One could argue that if neither nested functions, nor eval(), nor arguments[] is used, the loads/stores are invisible too. But that's an optimization, and changing locals/arguments to temporaries can be done in a separate pass.) Because of the "volatile" nature of arguments and locals, their usage cannot be optimized. All optimizations (SSA construction, register allocation, copy elimination, etc.) work on temporaries. Being able to easily ignore all non-temporaries has the benefit that optimizations can be faster. Previously, Temps were not uniquely numbered: argument 1, local 1, and temporary 1 all had the same number and were distinguishable by their type. So, for any mapping from Temp to something else, a QHash was used. Now that Temps only hold proper temporaries, the indexes do uniquely identify them. Add to that the fact that after transforming to SSA form all temporaries are renumbered starting from 0 and without any holes in the numbering, many of those datastructures can be changed to simple vectors. That change gives a noticeable performance improvement. One implication of this change is that a number of functions that took a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr. However, it turns out that there are very few places where that applies, as many of those places also need to take constants or names. However, explicitly separating memory loads/stores for arguments/locals from temporaries adds the benefit that it's now easier to do a peep-hole optimizer for those load/store operations in the future: when a load is directly preceded by a store, it can be eliminated if the value is still available in a temporary. Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Merge "Merge remote-tracking branch 'origin/stable' into dev" into ↵Simon Hausmann2014-05-223-31/+18
|\ \ | | | | | | | | | refs/staging/dev
| * | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-05-223-31/+18
| |\| | | | | | | | | | Change-Id: I0dd91626837276f5811e4830f4a4e9f89bf1e1bd