aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Prevent objects from being collected while in their constructorLars Knoll2013-09-221-1/+1
| | | | | | | | | | | | | While objects are being constructed, we don't have a reference to them on the JS stack yet. So the constructor needs to protect itself against being collected by putting the this object onto the JS stack. Added an environment switch MM_EXACT_GC to test exact garbage collection. Change-Id: Ie37665a954de800359c272ffbebbe1488e7a8ace Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert the last methods in qv4object_p.hLars Knoll2013-09-221-2/+2
| | | | | | Change-Id: I4fda83a0832760c277e629d4e658da718c0bf92b Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a StringRef for Managed::get()Lars Knoll2013-09-221-0/+4
| | | | | | | | | also store "toString" and "valueOf" as identifiers in the engine and fix two places where we compared strings the wrong way. Change-Id: I70612221e72d43ed0e3c496e4209681bf254cded Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup Object::define*Property APILars Knoll2013-09-221-42/+42
| | | | | Change-Id: I99125908a9bc1d41a2642c409af9704def7a0832 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Start using StringRef for parameter passingLars Knoll2013-09-221-1/+1
| | | | | Change-Id: If2c41daeda2862cd1162c5da8163a9d62fe4111d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Introduce a Referenced<T> class to pass Objects into methodsLars Knoll2013-09-221-2/+14
| | | | | | | | | | Added some convenience typedefs (StringRef, ObjectRef, ReturnedString, ScopedString, ...) Used StringRef in newBuiltinFunction() for testing. Cleaned up the duplicated code for thrower functions. Change-Id: I7b7676690cbe70d9eabb0a5afd0d922f0be3aefd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup ExecutionEngine::newBuiltinFunction() usagesLars Knoll2013-09-221-2/+2
| | | | | | | And change the return type to be GC safe Change-Id: I6d7513962370fea4072a3d8c6b2c6f2d1705992e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Further work towards an exact GCLars Knoll2013-09-221-7/+7
| | | | | | | | | | | Add some more convenience in the helper classes in qscopedvalue_p.h Make accesses to CallData safer, and change ExecutionEngine::newObject() to return a safe pointer. Change-Id: I980909754ce9681cf6faa1355bab3a1e5d6dd186 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix destruction of QV4::CompiledData::CompilationUnit objectsSimon Hausmann2013-09-201-0/+6
| | | | | | | | | | | Now that we store them per QML file, they live in the type cache and can outlive the engine. Therefore the engine needs to free to unlink any remaining units upon destruction. This needs to be done after the "death" of the memory manager, which is likely to sweep away any function objects that also hold a reference to the compilation units. Change-Id: I3968d5995289e8d2bc1e3abbb1f8be88a0ab4e03 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Convert more methods to return a Returned<>Lars Knoll2013-09-181-22/+29
| | | | | Change-Id: If294c9c4f574824c308b63a11da1337226180105 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert some methods to use Returned<>Lars Knoll2013-09-181-8/+10
| | | | | Change-Id: I631606cb5ab3b35b72104e70092a5200dd235fbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert a few more methods in ExecutionEngine to use protected pointersLars Knoll2013-09-181-9/+9
| | | | | Change-Id: I2e6b1b9dff52bbd16f35a00152c9ac557f8346eb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Extend the ReturnedValue mechanism to pointers to Managed objectsLars Knoll2013-09-181-4/+4
| | | | | | | | | | | | | Add a Returned<T> that we can return instead of raw pointers to Managed objects. Start using the Returned<T> for a few methods. Also clean up all our classes to use the Q_MANAGED macro instead of manually defining their vtable. Change-Id: I0a2962e47f3de955cd2cd8474f8f3fcc9e36d084 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert builtin methods to return a ReturnedValueLars Knoll2013-09-181-1/+1
| | | | | Change-Id: I6b75adbf53a5be0deab023d2eed98ce2a7915551 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rename BuiltinFunctionOld to BuiltinFunctionLars Knoll2013-09-181-1/+1
| | | | | | | | This is the correct abstraction for a builtin method. Time to get rid of the 'old' in the name. Change-Id: Ia386d2cc8ef0e6c269ab24da6fc8ebfac52d7f69 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Properly unwind the js stack for generated codeLars Knoll2013-09-111-3/+3
| | | | | | | | | | | | | Surround all calls into generated code with a try {} catch {} statement that resets the jstack to the correct position. Like this we properly unwind the js stack in all cases, and can also use stricter assertions in our ScopedCallData, etc. classes to check that the stack is healthy. Change-Id: I7ca03e06ea55007be683305d9c2a6898cf5fc689 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Create a stack for JS values and use it in the interpreterLars Knoll2013-09-111-0/+8
| | | | | | | | | | | | First step towards being able to do an exact GC. Create a stack for JS Values that is separate from the C++ stack. Use the stack for generated methods (masm and moth). Change-Id: I80ac0e5b5d86439dda5e9ea2b21fa0c57d8aef22 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: add environment variable QV4_FORCE_INTERPRETERErik Verbruggen2013-09-111-1/+6
| | | | | | | | By setting this variable, the interpreter will always be used, even when the JIT is available. Change-Id: I66a439b649fd22e0d10be4f07f1e7be392b012f5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize String.replace and RegExp.execLars Knoll2013-09-021-0/+15
| | | | | | | This speeds up the v8 regexp benchmark by a factor 2.5 :) Change-Id: Ibd6b18ee28181aa712429cbec4598984e0c69820 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize ScriptFunction::construct() and creation of FunctionObjectsLars Knoll2013-09-021-0/+5
| | | | | Change-Id: I7df04171a26cbe659e85f14878cc4e51030e8a5a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more usages of Object::setPrototype()Lars Knoll2013-09-021-8/+6
| | | | | Change-Id: I33383baf14e764ce79252a100a6d769bde75331a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more usages of Object::setPrototype()Lars Knoll2013-09-021-15/+14
| | | | | Change-Id: I8c49f61bc85e3d98dea90bf05db1a3f22d08f7b1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup calls to Object::setPrototype()Lars Knoll2013-09-021-50/+27
| | | | | | | | 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-021-64/+52
| | | | | | | | | | | | | 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-021-0/+2
| | | | | Change-Id: Ifa97d3354a7a7afadf70f9ba540716bd5b1eef44 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused arvument from Object constructorLars Knoll2013-09-021-1/+1
| | | | | Change-Id: I2c26bd8af9b352baed9b84a6b6401633ded4da85 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* move methods to create a new context into the ExecutionContext classLars Knoll2013-09-021-29/+0
| | | | | | | | 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-021-8/+0
| | | | | | | | | 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-021-21/+0
| | | | | Change-Id: Ie66a5892b0e5ab74bead1fcb59ffad5a867e0509 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Temporarily collect a map of all functions in the engineSimon Hausmann2013-09-021-0/+14
| | | | | | | | | | | | | | | | 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>
* Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-08-201-30/+16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Eliminate all vm functions on the isel sideSimon Hausmann2013-08-161-6/+0
| | | | | | | | | | Change-Id: I7c0e50498c937ce554b019f98829fa8c5d96c18e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Get rid of the functions list in QV4::ExecutionEngineSimon Hausmann2013-08-161-20/+8
| | | | | | | | | | Change-Id: I97067dbb2819936a1b2029c9f63f0627cb6b8bd2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Fix crashes with unmarked runtime stringsSimon Hausmann2013-08-151-0/+4
| | | | | | | | | | | | | | | | | | Runtime strings are identifiers, but they still require to be marked. Keep track of all compilation units in the engine (one per file) and mark its run-time strings. Change-Id: Ie70b00dfa373c4567279591de2f717e8103c288f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Move QV4::Function::sourceFile to CompiledFunctionSimon Hausmann2013-08-151-4/+4
| | | | | | | | | | Change-Id: Iacf907c475070bab4a5a1583280f110c089141c4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove QV4::DiagnosticMessageLars Knoll2013-08-201-6/+6
| | | | | | | | | | | | | | | | | | | | 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>
* | Remove unused overload of newCallContext()Lars Knoll2013-08-171-10/+0
| | | | | | | | | | Change-Id: I9b9de585b18bf87ea256db36b320a7defdcc4ac8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Optimize contruction of Arguments objectsLars Knoll2013-08-171-0/+5
| | | | | | | | | | Change-Id: If77bff28a25462a6069d646a2594dd903fefb9e5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix memory leak in identifier tableSimon Hausmann2013-08-131-1/+1
|/ | | | | Change-Id: I8bc393856cad85734160b52dee745509be502247 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Re-enable JITSimon Hausmann2013-08-121-1/+1
| | | | | | | Ooops, an earlier commit accidentally disabled it. Change-Id: I7b732e0addba8b6403e0d6818d784f267711af42 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Add reference counting to the VM functionsSimon Hausmann2013-08-121-3/+2
| | | | | | | | | This reduces memory pressure, keep engine->functions small and thus makes back trace lookup faster. It became visible for example in the QtQuickControls auto-tests that use plenty of loaders and we ended up with 30k+ functions. Change-Id: Iaa5981f44e1e49ad9417a50c1e6a74946090dd28 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Restructure source codeLars Knoll2013-08-081-0/+837
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>