aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* Optimize ScriptFunction::construct() and creation of FunctionObjectsLars Knoll2013-09-024-17/+27
| | | | | Change-Id: I7df04171a26cbe659e85f14878cc4e51030e8a5a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Inline identifier lookup where it makes senseLars Knoll2013-09-022-2/+9
| | | | | Change-Id: I42ac6f4232fec2ce1535a007007542d8cc116433 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use Q_ASSERT instead of assert to get rid of the checks in release buildsLars Knoll2013-09-021-2/+2
| | | | | Change-Id: Ia4b5bda273d44ec4c25ba955018a0f6fe220551e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize Function.apply()Lars Knoll2013-09-021-3/+15
| | | | | Change-Id: I693413e7be5520e13139594f7654a36ce54a59ce Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimise property lookups on primitive typesLars Knoll2013-09-023-31/+168
| | | | | | | | This gives a large speedup on code such as "foo".charAt(2), or (5.).toString(). Change-Id: I8b6c46f2f69a4b00f82048a9368d8e9baf4d89ee Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix a small bug in ExecutionContext::getPropertyAndBaseLars Knoll2013-09-021-1/+2
| | | | | | | | Don't return the activation object as base, as it's only a helper for mutable properties in regular call contexts Change-Id: I2c36a4aff9cf82d87f80e541b4ec21ef17e18e8d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more usages of Object::setPrototype()Lars Knoll2013-09-029-30/+23
| | | | | Change-Id: I33383baf14e764ce79252a100a6d769bde75331a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more usages of Object::setPrototype()Lars Knoll2013-09-024-62/+49
| | | | | Change-Id: I8c49f61bc85e3d98dea90bf05db1a3f22d08f7b1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup calls to Object::setPrototype()Lars Knoll2013-09-0217-92/+78
| | | | | | | | Rather use the correct internalClass directly when constructing the objects. Change-Id: I8e916f1ce8f83d291c08ca6332fe85b1f57b90b5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype pointer into QV4::InternalClassLars Knoll2013-09-0230-189/+255
| | | | | | | | | | | | | The prototype is actually the same for most objects. By moving it into the internal class, we can save 8 bytes per object, as well as allowing for some future optimizations. Also fix a bug in the implementation of the Error prototype objects. Change-Id: I4d4b641055f644a9b088f27be34bfdb0446279b7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add the object's prototype to the InternalClass structureLars Knoll2013-09-023-2/+39
| | | | | Change-Id: Ifa97d3354a7a7afadf70f9ba540716bd5b1eef44 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused arvument from Object constructorLars Knoll2013-09-023-3/+3
| | | | | Change-Id: I2c26bd8af9b352baed9b84a6b6401633ded4da85 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused constructorLars Knoll2013-09-022-12/+0
| | | | | Change-Id: Ibba688aea338c9f3deb33ae7488b7239ec9a485c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add Value::isNullOrUndefined()Lars Knoll2013-09-022-3/+5
| | | | | | | Allows for some smaller optimization in the call stack. Change-Id: Id5beeb04e9f9dbf9e61280cee7bf6758a4c02310 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix incorrect implementation of Array.toString()Lars Knoll2013-09-021-1/+9
| | | | | | | | The spec says we need to call join with empty arguments if it's callable, otherwise fall back to Object.toString() Change-Id: I36aed164b60fad89b7d23b8a6993964c344a9ed3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* change calling convention for JS function callsLars Knoll2013-09-0237-333/+454
| | | | | | | | | | | | This allows faster pass through of the data if we have nested calls. Also make sure we always reserve at least QV4::Global::ReservedArgumentCount Values on the stack to avoid stack corruption. Change-Id: I42976460f1ef11a333d4adda70fba8daac66acf3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* move methods to create a new context into the ExecutionContext classLars Knoll2013-09-026-36/+34
| | | | | | | | This avoids one indirection when calling the methods and cleans up the engine a bit. Change-Id: I426f41e23f6a7262af95b9807b00920530fef642 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a SimpleScriptFunction classLars Knoll2013-09-029-36/+176
| | | | | | | | | 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>
* Move call context creation into the ExecutionContext classLars Knoll2013-09-025-70/+63
| | | | | Change-Id: Ie66a5892b0e5ab74bead1fcb59ffad5a867e0509 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Temporarily collect a map of all functions in the engineSimon Hausmann2013-09-022-0/+15
| | | | | | | | | | | | | | | | At the moment we collect a lot of compilation units (one per binding expression!), which for long running QML accumulates and creates a horrible performance when trying to retrieve back traces. There is work in progress to reduces the number of units down to one per QML file, and then the fixed sorted QVector might proof to be a more efficient data structure for the lookups. But until that code lands, this patch proposes to use a QMap instead for the time being, that tracks all functions. This brings down the qtquickcontrols auto-test run from 2.5 minutes to just under a minute on my machine. Change-Id: I45bf609055877081daa984de90f291a030f2f24f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix crashes when running tst_qqmlecmascript::importScripts with aggressive gcSimon Hausmann2013-09-022-4/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | In the case of imported JavaScript files, it may happen that we parse the JS once and then re-use it across different places where it is imported. That means we parse and compile the JS once, keep the QV4::Script around and call it as a function closure with different qml global objects (contexts), depending on where it is imported from. In this situation it is possible that the QV4::Script's run() is called once, a new function object is created, we call it to return the JS library to "eval" itself into the qml scope and afterwards it may happen that the function object is garbage collected. It is at this point possible that the compilation unit's refcount therefore also drops to zero, and thus subsequent calls to QV4::Script::run() that create new QQmlBinding objects will access a dangling compilationUnit pointer. This patch fixes that by making QV4::Script - which is holding a QV4::Function pointer - also have a persistent, which maintainers a refcount on the compilation unit. If the script dies, the persistent will get collected and the last deref will delete the unit. A script can however outlive the engine, but PersistentValue has the mechanism built in to free itself on engine destruction, which will also deref the unit accordingly. Change-Id: I0a7f4e64497bde423ffa55c705af55cdb7d29cf2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix the header guard for the ARM unwinder helperThiago Macieira2013-09-021-2/+2
| | | | | | | | | Make it match the file name, instead of being exactly the same as the DWARF2 header. This way, it's possible for both headers to be included. Change-Id: I9a386d3203c8f1482d28b1d1074206cf354db33e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Rename the DW2 and ARM unwinder helpers to standard _p.hThiago Macieira2013-09-024-4/+4
| | | | | | | | | | The Qt convention is that private headers end in _p.h. A great deal of our build automation relies on this, including the choosing of which headers to install and which ones not to. Change-Id: I03ab6021e0a8a68d5a9cbc9d9387a9c5331f7bb7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix bad cast from non-const QMap iterator to const_iteratorThiago Macieira2013-09-021-1/+1
| | | | | | | | | At that point in the ARM unwinder, the non-POD QMap global static (!) is not const, so QMap::lowerBound returns a regular iterator. Change-Id: Ia4dad7ee1a9cf593b0e1d273d193337fac7d9b69 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* wince: Build fix, assert() is not present in this platform.Sérgio Martins2013-08-291-0/+5
| | | | | Change-Id: Ib29f1411b9829bc9bf6a94e4fb23a33f955ee1b2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* wince: Build fix, disable the assembler when JIT is disabled.Sérgio Martins2013-08-294-4/+0
| | | | | Change-Id: Ibd22f27401c3751bc64749c6f1eea3aba57d66eb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Generate code for conversion to signed int32.Erik Verbruggen2013-08-292-6/+4
| | | | | Change-Id: I862a8c9c262b658859cc9b57ea0b6e9eb60e32e5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Generate code conversion to double.Erik Verbruggen2013-08-282-0/+6
| | | | | | | | Performance improves by about 15% on fact.3.js when Qt is build in debug mode. Change-Id: I4a1c868fe211c1e0f9e7d9a5652f7726b37405d1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* The fast and the furious, register drift.Erik Verbruggen2013-08-272-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Silence MinGW/gcc-4.8.1 compiler warnings.Friedemann Kleint2013-08-262-60/+69
| | | | | | | | | | | | | | | | | Reorder V4::Object's and V4::Value's private object inline functions such that its definitions are visible from where they are being referenced. qv4object_p.h:418:13: warning: 'uint QV4::Object::arrayLength() const' redeclared without dllimport attribute after being referenced with dll linkage qv4object_p.h:430:13: warning: 'void QV4::Object::setArrayLengthUnchecked(uint)' redeclared without dllimport attribute after being referenced with dll linkage Change-Id: I49a3c9d1da637eaf038f53b29ec13c35253de9f1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup: Rename overloaded () operators of CodeGen to more descriptive ↵Simon Hausmann2013-08-222-3/+3
| | | | | | | function names Change-Id: I529c3d5c80ed7f703046a2803c492c4b15511049 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compilation with MSVC 2008 (and prospective Windows CE build fix)Simon Hausmann2013-08-225-7/+10
| | | | | | | | | | | | | | | | | * Only 2010 and newer ship stdint.h, so for 2008 we have to provide a little stdint.h compat header, for some of the third-party code we import. Our own Qt code this patch changes to use quint* types instead. * Include math.h and float.h for some math functions. * disable the JIT on Windows CE for now. * Change use of intptr_t to qintptr in Qt code. intptr_t is in inttypes.h, except that with VS 2008 it is indirectly available through stdio.h. Let's avoid the mess and just use the qt type, that's always available. Change-Id: I19055edd89e0a6b147d9edbb3b711798ed3c05a5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-08-2015-204/+245
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Fix ARM buildSimon Hausmann2013-08-191-2/+2
| | | | | | | | | | | | | | | | Re-add variable only needed for ARM build and replace references to removed codeRef variables from QV4::Function. Change-Id: Id47fe57be2aa653bd8f81996463d970f27427f37 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
| * Prospective MSVC build fixSimon Hausmann2013-08-191-2/+2
| | | | | | | | | | | | | | | | It seems LoadString is somehow expanded as a macro, so call the instruction LoadRuntimeString, which is closer to the meaning. Change-Id: I16836b495d29db8cb1af5874762c8e66acb9c529 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
| * Get rid of engine pointer in iselSimon Hausmann2013-08-182-2/+2
| | | | | | | | | | Change-Id: I58759712624713cd2215621dca4ccc86fa9a9194 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Fix invalid reads with stringsSimon Hausmann2013-08-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | It may happen that a dynamically created compilation unit disappears before any QV4::Strings it created. Those strings would still have a reference to the QString data in the compilation unit. I don't see a choice other than making a copy of the string data ;(. But this patch adds a flag that would allow for avoiding it if we happen to know that the compilation unit data is static. Change-Id: Ib35a4d2a566b301a25ffe56e392809e44e7b4ae8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Fix eval operating on incorrect runtime dataSimon Hausmann2013-08-186-31/+51
| | | | | | | | | | | | | | | | Moved compilationUnit and compiledFunction into the context and set it also during eval, along with the runtime strings. Change-Id: I627b3bea0f7c38ad91bc5e8ee85e1484d08ed3f3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Remove unused Function::engine member and line number mapping typeSimon Hausmann2013-08-162-10/+0
| | | | | | | | | | Change-Id: Id227139bf385aa92e539cdb0d0012e1360679c81 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Merge Function::init with the constructorSimon Hausmann2013-08-162-19/+18
| | | | | | | | | | Change-Id: I557f8a80aa2c74398b94e87ed0f29fe8d2297150 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Eliminate all vm functions on the isel sideSimon Hausmann2013-08-162-8/+0
| | | | | | | | | | Change-Id: I7c0e50498c937ce554b019f98829fa8c5d96c18e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Use indices into the runtime functions array instead of function pointers in ↵Simon Hausmann2013-08-162-2/+4
| | | | | | | | | | | | | | the isel for closures Change-Id: Ieaf7b112f80adc3f1041cb1397db4eab55fb0184 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Get rid of the functions list in QV4::ExecutionEngineSimon Hausmann2013-08-164-28/+13
| | | | | | | | | | Change-Id: I97067dbb2819936a1b2029c9f63f0627cb6b8bd2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Refcount the compilation unit and remove refcount from runtime functionSimon Hausmann2013-08-164-23/+4
| | | | | | | | | | Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Get rid of QV4::Function::lineNumberMappings by porting moth to the new mappingSimon Hausmann2013-08-161-2/+0
| | | | | | | | | | Change-Id: Ib79489ac4c6c93042143be1f512d29c13d4cd3c6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Get rid of QV4::Function::generatedValues by porting moths' regexps to ↵Simon Hausmann2013-08-163-4/+5
| | | | | | | | | | | | | | runtime expressions Change-Id: Iaae3c4855016948952159596d2528fca73341b72 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Ported identifiers in moth to use runtime stringsSimon Hausmann2013-08-164-28/+34
| | | | | | | | | | Change-Id: I09f04994a2ebe631b12fa76b77a622711de31926 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Initial port of moth to the new compile data structuresSimon Hausmann2013-08-161-1/+0
| | | | | | | | | | Change-Id: I2ead40c5c8c9b12b29c48c387ea424838d1f7d9e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Get rid of the QV4::Function in the masm iselSimon Hausmann2013-08-162-2/+7
| | | | | | | | | | Change-Id: Ide70ca5a3f3dcc793fb96fd64f8b8df6b07d1168 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Ported the compile-time class setup for object literals to be run-time basedSimon Hausmann2013-08-163-3/+6
| | | | | | | | | | Change-Id: I21225e4bf0f66914229cf64fa29ce870548c0e93 Reviewed-by: Lars Knoll <lars.knoll@digia.com>