aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4jsir.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Clean up property dependency data structuresSimon Hausmann2013-12-051-15/+5
| | | | | | | | | | | | | | | | 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>
* Add support for accelerated property access to QML types and namespace supportSimon Hausmann2013-11-281-5/+19
| | | | | | | | | | | * 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/+6
| | | | | | | | | 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>
* IR Cleanup, resolve ID objects through array subscriptsSimon Hausmann2013-11-251-15/+3
| | | | | | | | | | | | ...instead of a special MEMBER type. This allows removing the type member from V4IR::Member altogether (and thus unshadow from V4IR::Expr::type). By not requiring the base of a id lookup member expression to be a NAME, we can also speed up repeated id lookups by fetching the id object array wrapper only once per function. Change-Id: I3e9b8f498d32ace4a0cc2254f49e02ecc124f79c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup, get rid of MemberOfQObject V4IR::Member specializationSimon Hausmann2013-11-251-13/+4
| | | | | | | 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-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix property dependency generation for accelerated QML QObject propertiesSimon Hausmann2013-11-121-25/+0
| | | | | | | | | | | | | | The previous approach of collecting the dependencies through an IR visitor doesn't work, because it relies on a fixed structure - for example MEMBER(NAME, prop) - which we can't guarantee (it's usually MEMBER(TEMP, prop)). But it turns out that we can only pre-calculate dependencies for context, scope or id properties, so we can do that right away in the QML specific JS codegen, store that information in the IR function and use it from there in the data structure generator as well as in the isel as a parameter to getQObjectProperty to tell the run-time whether capture is required or not. Change-Id: I33711c3420d6534c653c2a6a4284f0fc12e941cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move conversion of this object into generated codeLars Knoll2013-11-051-0/+2
| | | | | | | | | | | | When a non strict mode function uses the this object, we need to make sure it's being correctly converted into a object before being accessed. So far this was being done by ScriptFunction::call. Move this into the generated code to avoid overhead for methods not using 'this', and simplify our ScriptFunction::call() implementation. Change-Id: I739f4a89d29ed8082ce59e48d1523776224fc29d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-1/+3
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Speed up lookups of imported scriptsSimon Hausmann2013-10-311-2/+2
| | | | | | | | | | The QQmlContextData stores the JS objects of imported scripts in a QList<PersistentValue>. Instead of indexing into that list, this patch changes ctxt->importedScripts to be a JavaScript array, that in the IR we can index via subscript. Change-Id: Ie2c35fb5294a20a0b7084bb51d19671a27195fec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement loading of resolved imported scriptsSimon Hausmann2013-10-311-8/+12
| | | | | | | | We can resolve the use of names that refer to imported scripts at compile time and load them at run-time by index through context->importedScripts. Change-Id: I681b19e7d68dbf3b9a68af00b4cea2a9254c2d78 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initial support for resolving meta-property access for the scope and context ↵Simon Hausmann2013-10-311-8/+40
| | | | | | | | | | | | | | | | | objects at QML compile time This avoids having to do a string lookup for ids and in the import cache at run-time, before we can do a string hash lookup in the property cache. Instead we resolve final properties in the context and scope object at compile time and look them up at run-time using their index instead. The dependencies to these properties are also tracked separately and recorded in the compiled data. This is merely the initial patch. There's a lot left to do, such as having specialized getter and setters for specific property types. Setters are missing altogether right now and will fall back to name lookup. Change-Id: If3cb4e7c9454ef4850a615f0935b311c9395b165 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up id object lookupsSimon Hausmann2013-10-291-1/+22
| | | | | | | | | | | | | | | | | We can resolve lookups for objects referenced by id at QML compile time and use a run-time helper to extract the id object out of the QML context data by index instead of name. Dependencies to id objects are also tracked at compile time and registered separately before entering the generated function code. The lookup of id objects is encoded in the IR as special member lookups. Members will also then in the future be used to for property lookups in context and scope properties, as well as any other property lookups in QObjects where we can determine the meta-object. Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Rework IR code generation for try/catch/finallyLars Knoll2013-10-291-0/+2
| | | | | | | | | | | | | | | | | | Simplify the generated code. Add a special block to catch exceptions thrown inside a catch() statement. store the exception on the stack when entering finally and rethrow it at the end. This ensure correct behavior for break/continue/return statements inside finally. Don't check for exceptions after calling push_catch_scope and pop_scope in the JIT'ed code. This can lead to infinite loops when throwing inside an exception handler. Change-Id: I67e9325794e2fd25b0773b21e02fbaadb43faab0 Change-Id: Ic1ea9c0c43eec1d49177dc1ab4552a1da04e96fe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rework exception handlingLars Knoll2013-10-291-41/+10
| | | | | | | | | | | | | | 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>
* Qml JavaScript code generation cleanupsSimon Hausmann2013-10-201-2/+4
| | | | | | | | | | | | | | | * 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-201-3/+3
| | | | | | | | | 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>
* V4: remove inplace operationsErik Verbruggen2013-09-301-4/+2
| | | | | | | | | 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>
* Merge branch 'wip/v4' of qtdeclarative into devSimon Hausmann2013-09-201-3/+1
|\ | | | | | | | | | | | | | | This brings in the infrastructure for the new compilation of QML and JS in the loader thread and the new VME replacement for creating objects in the GUI thread. Change-Id: Ib8127c10f5cb3ad238e57469723d031ab765a79b
| * Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into HEADSimon Hausmann2013-09-201-4/+0
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_masm.cpp src/qml/jsruntime/qv4script.cpp src/qml/qml/qml.pri src/qml/qml/qqmltypeloader_p.h Change-Id: Ia784d855a2131e3289454f12d841ca2c65be15c1
| * | Beginning of a new qml parserSimon Hausmann2013-09-081-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to parse QML and JavaScript binding expressions/functions in one go and generate data structures that allow for the parsing to happen in a thread and the instantiation of the object tree in another thread, just reading from the generated data structures. This will replace qqmlcompiler and the VME. This new way of loading QML is currently hidden behind the QML_NEW_COMPILER=1 environment variable. There's lots of work left to fill in the gaps in object construction, Component support, Component.onComplete, error messages, etc. etc. Change-Id: I5e40643cff169f469f0b6ce151584ffee5ca5e90 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | V4 IR: rename ObjectType to VarTypeErik Verbruggen2013-09-201-1/+1
| |/ |/| | | | | | | | | | | | | | | The ObjectType was a misnomer: it was used to indicate that the expression could have multiple types, or that the type could not be inferred statically. Change-Id: Ic48a0cd1dd7ae7bfafd361e0c9792ab161417039 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove unused code to generate post increment and decrement expressionsLars Knoll2013-09-121-4/+0
|/ | | | | | | | We generate lower level code in codegen and don't use these runtime methods anymore. Change-Id: If1023ce5295431305f4528839bcf2a3031fa7ad2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* wince: Build fix, abort() is not available on this platformSergio Martins2013-08-281-1/+1
| | | | | Change-Id: I0962f8b89de465d84d913b46ba482a538fe25495 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* wince: Build fix, CONST conflicts with Windows macros.Sérgio Martins2013-08-281-0/+4
| | | | | | | | Don't #undef system macros in header files, they propagate quickly through other headers and make it very difficult to fix these problems. Change-Id: Id5efdfa69d0eefa8c740b14f839194039bd9752b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* The fast and the furious, register drift.Erik Verbruggen2013-08-271-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable the register allocator for X86_64 on Linux and MacOS. The implications are: - handle as much as possible with current code with as few changes as possible - temporarily force the register allocator to spill unop/binop arguments to the stack by doing a call in the implementation (as is the current case), so no change is needed here - only have loadThis and loadConst handle registers - have any method that might need to handle registrers actually cope with them - the inline versions of binops are not generated, as they cannot cope with registers. This will change when ISel for binops is added in the next patch. This means that we are still running with the handbrakes on, but allow for full-throttle in certain/limited cases. Note about the changed test: multiplication always returns a Number (double), so the operands are passed as doubles, so __qmljs_mul will return a double. For addition this is different: because it might return a Number or a String, the operands are passed as whatever fits best. So __qmljs_add will return an int when both operands are ints. Hence the change to the tests. Change-Id: If5bd7dffca8f7de5ba45af700b9c7bb568fc74b7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-08-201-0/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into dev Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4codegen_p.h src/qml/compiler/qv4isel_moth.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4runtime_p.h src/qml/jsruntime/qv4script.cpp sync.profile Change-Id: I1d785e2134bffac9553a1c16eed12816cbd1ad2c
| * Store the file name per compilation unit, not per compiled functionSimon Hausmann2013-08-151-0/+9
| | | | | | | | | | Change-Id: Id699897b241a9ff6495689e5685092d311acb8c2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Various fixes to the optimizer.Erik Verbruggen2013-08-201-1/+8
| | | | | | | | | | | | | | | | | | | | Mainly type inference and type propagation. Also added constant/copy propagation pass, which is disabled for the moment. Change-Id: I286c1fbced0d175be76868e870ca92c0da88babd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add linear scan register allocation.Erik Verbruggen2013-08-191-2/+10
| | | | | | | | | | | | | | | | Currently disabled for all platforms. Will be enabled step-by-step when specific platforms get supported. Change-Id: I144c6c991b1666e1ff752d776bca0a7b57a4fe7c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move arguments object creation into the generated codeLars Knoll2013-08-171-0/+2
| | | | | | | | | | | | | | | | | | | | So far we've been creating the arguments object at runtime in initCallContext(). It's much more efficient to simply add arguments as a local variable in qv4codegen if it's being used and initialize it through a builtin method. Change-Id: I6913f3565adf3aa1917adae8dceef9f50ecf1722 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make some clone methods statically accessible.Erik Verbruggen2013-08-141-8/+3
|/ | | | | Change-Id: I5943c30d239a26869fefec608cb8e4a27a31aaaa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix leaks in Phi nodes in the V4 IRSimon Hausmann2013-08-131-3/+3
| | | | | | | | | | | The phi nodes store a QVector, but as the destructors of the IR nodes aren't called, the QVector internal data is leaked. This patch re-uses the existing Stmt::Data mechanism that was introduced to serve exactly that purpose. It replaces the now unused QVectors there with the Phi::incoming vector and adjusts usage accordingly. Change-Id: I22f351a17c1983637b54fa73a93dd40d64fec46c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix leak of QString in V4 IRSimon Hausmann2013-08-121-1/+1
| | | | | | | | | The destructors of the IR nodes won't be called because they come out of a memory pool. Therefore we must store strings by pointer from the function's string pool. Change-Id: I841e801b81c871e8d08cf63ee1e053744c0bf4dc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Restructure source codeLars Knoll2013-08-081-0/+1024
Move the v4 engine classes from a subdir of qml/qml into two subdirs (compiler and jsruntime) of the qml module Remove an unsued qv4syntaxchecker class, and move the moth code directly into compiler. Change-Id: I6929bede1f25098e6cb2e68087e779fac16b0c68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>