aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* Compile binding expressions in the QQmlCompilerSimon Hausmann2013-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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-111-26/+20
| | | | | | | | | | | | | | | | | | 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>
* Compile imported scripts in the loader threadSimon Hausmann2013-09-301-0/+5
| | | | | | | | | | | | | | | | | 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: remove inplace operationsErik Verbruggen2013-09-301-5/+4
| | | | | | | | | 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>
* Move Value::toInteger(double) and related to PrimitiveLars Knoll2013-09-281-4/+4
| | | | | | | Also clean up a few other direct uses of Value Change-Id: Ie27d42c1b31b9e6d16d0a60071cb5e4e1c5b9e8b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge branch 'wip/v4' of qtdeclarative into devSimon Hausmann2013-09-211-1/+4
|\ | | | | | | | | | | Pull in the remaining bits of the new compiler/vme branch. Change-Id: I4706011c5eaf35f893d0733c4e130a31ce0ebb66
| * [new compiler] Fix local variable declarations in binding expressionsSimon Hausmann2013-09-201-1/+4
| | | | | | | | | | | | | | Always look up locals by name Change-Id: I2fa14499f6d8749f450bfe2b8a53d684b93bd1dc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Add Singleton support for QMLAntti Piira2013-09-211-1/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces Singleton support for QML (Composite Singleton). For now, the Singleton support is only availabe for QML types in modules or (remote and local) directories with qmldir file. However, in the future this support may be expanded to arbitrary QML file imports without by leaving out the qmldir requirement. You define a QML type as a Singleton with the following two steps: 1. By adding a pragma Singleton to a type's QML file: pragma Singleton The pragma and import statements can be mixed and their order does not matter. Singleton is the only supported pragma for now. Others will generate errors. 2. By specifying a qmldir file for the directory of your imported type and prepending the type with "singleton" keyword as follows: singleton TestTypeSingleton TestTypeSingleton.qml Alternatively you may specify a qmldir file for a module and specify your type as a singleton as follows: singleton TestTypeSingleton 1.0 TestTypeSingleton.qml Composite Singletons may be included in a module and may be used with a local namespace qualifier when imported with: "import xxx as NameSpace" A singleton instance is created at first use and stored into the QmlEngine (one instance per engine) and eventually released by the engine's destructor. CompositeSingletonType has a dual nature and will return true to both isComposite() and isSingleton() calls. In most cases its enough to check for just isComposite() or isSingleton(). However, there is a isCompositeSingleton() available as well. I used "qlalr --no-debug --no-lines --qt qqmljs.g" to generate the qqmljsparser and qqmljsgrammar files from qqmljs.g. Unit tests are included. Change-Id: I91b303612c5e132143b325b9a8f982e9355bc90e Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* [new compiler] Fix crash with empty function bodiesSimon Hausmann2013-09-201-8/+2
| | | | | | | | | | | | Change defineFunction back to taking AST::SourceElements for the body (how it was originally) Then in the new compiler, do the same "function->body ? function->body->elements : 0" dance for function expressions and for binding expressions, synthesize the AST::SourceElements. Change-Id: Iaedb15925a6bb8482cde2b371a6e781477252435 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into HEADSimon Hausmann2013-09-201-3/+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
| * V4: Fix SSA decomposition when no regalloc is used.Erik Verbruggen2013-09-131-3/+0
| | | | | | | | | | | | | | | | | | Add scheduling for moves generated by removing phi nodes by re-using the MoveMapping class from the register allocator. This change applies to both the JIT when no register allocator is used, and the interpreter. Change-Id: I38eac5b13759c7790132d1ef07fa17fcb53187e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | [new compiler] Improve error reportingSimon Hausmann2013-09-121-0/+4
| | | | | | | | | | | | | | | | Re-enable COMPILE_EXCEPTION calls that were commented out due to missing location information (that this patch also adds). Change-Id: I0d584f474cc7e879350c8aae2869a9603ba415aa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Beginning of a new qml parserSimon Hausmann2013-09-081-2/+8
|/ | | | | | | | | | | | | | 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>
* Fix some bugs in the code generatorLars Knoll2013-09-021-12/+27
| | | | | | | | | | | | | arguments can't be used as lvalue in strict mode. We however also threw an error in some cases where it was used as an rvalue, e.g. in (arguments < 10) the delete operator should throw a syntax error in strict mode on all unqualified variables Optimize the identifier() code a little: arguments and local variables inside eval do not need to be looked up by name. Change-Id: If3e9305187acf72820c5164aa9754927a2c4d5d5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a SimpleScriptFunction classLars Knoll2013-09-021-1/+1
| | | | | | | | | Choose whether we use a stack based context for a function, when the actual closure is generated, not at call time. This speeds up function calling for leaf functions. Change-Id: Ibcbf3acb5610a7f59b6474e982122df03c1c5298 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Allow for function declarations inside conditionalsSimon Hausmann2013-08-231-27/+0
| | | | | | | | | This is strictly speaking a regression from 5.1/v8, which allows for that as real world JavaScript appears to require it. Task-number: QTBUG-33064 Change-Id: Iceaca84373f12fb08459ed007afb25b5a705fa31 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Rename overloaded () operators of CodeGen to more descriptive ↵Simon Hausmann2013-08-221-2/+2
| | | | | | | function names Change-Id: I529c3d5c80ed7f703046a2803c492c4b15511049 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Separate JS environment scanner class declaration from definitionSimon Hausmann2013-08-221-305/+287
| | | | | | | This will allow the use of it from outside. Change-Id: Ia05a17b4b4f3e772554979e215a6252a75a63273 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-08-201-7/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | | | | | | | | Change-Id: Id699897b241a9ff6495689e5685092d311acb8c2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove QV4::DiagnosticMessageLars Knoll2013-08-201-39/+23
| | | | | | | | | | | | | | | | | | | | QQmlError provides the same functionality, so let's rather use that where required. Remove the dependency of codegen onto the ExecutionContext that was only required for error handling. Change-Id: Ib0b61c0e138f89ff989c32996c93c339e4b62223 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move arguments object creation into the generated codeLars Knoll2013-08-171-1/+9
| | | | | | | | | | | | | | | | | | | | 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>
* | Change post-increment/-decrement to not use a built-in.Erik Verbruggen2013-08-131-14/+20
|/ | | | | Change-Id: I98af408db1e5d23e73a77d2614071bc998170f5e 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/+2605
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>