aboutsummaryrefslogtreecommitdiffstats
path: root/tools/v4/main.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename v4 to qmljsSimon Hausmann2013-10-221-230/+0
| | | | | | | | We don't want to officially support this binary in our release builds, so give it a "safer" name and enable it only in developer builds. Change-Id: Iaa007bc2ccdb133635161aae01d140efe0f44e23 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup exception handlingSimon Hausmann2013-10-031-1/+0
| | | | | | | | | | The code in the Exception class operates entirely on the engine's data, so move it into ExecutionEngine instead. This eliminates the need for a QV4::Exception class and catches and old code that tries to still do catch (Exception &) instead of catch (...) Change-Id: Ie608bec6af652038aca6c9423c225a4d7eb13b39 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change exception handling APISimon Hausmann2013-10-021-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the exception handling API in the engine slightly, encapsulating any use of direct throw statements and catch blocks with concrete types. In the future we need to be able to change the way these are implemented, in order to ensure that the correct stack unwinding code is triggered for throw and re-throw. This patch separates the C++ exception object thrown from the V4 exception (that includes value, throwing context pointer) and stores the latter inside the engine. In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to move into the QV4 namespace directly. In addition the syntax for catching exceptions changes from try { ... } catch (QV4::Exception &ex) { ex.accept(context); QV4::ScopedValue exceptionValue(scope, ex.value()); } to try { ... } catch (...) { QV4::ScopedValue exception(scope, context->catchException()); } Context::catchException() checks if there's a "current" exception in the engine, and if not assumes that we caught an unrelated exception and consequently re-throws. partiallyUnwind() is also gone and replaced with rethrowException(), in order to encapsulate the re-throw. Lastly, in the future nesting try/catch blocks isn't going to be possible due to limitations in the common C++ ABI with regards to foreign exceptions. Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move Value::fromBool, ... to a new Primitive classLars Knoll2013-09-281-2/+2
| | | | | | | | This will simplify finding the remaining direct usages of QV4::Value that need fixing. Change-Id: I223099727436d5748027c84c53d9dfc4028e38ed Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Prevent objects from being collected while in their constructorLars Knoll2013-09-221-4/+2
| | | | | | | | | | | | | 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 Managed::put() API to be GC safeLars Knoll2013-09-221-5/+5
| | | | | Change-Id: I09198ce372fa545372db389fac26828d21ad5731 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a StringRef for Managed::get()Lars Knoll2013-09-221-1/+3
| | | | | | | | | 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>
* Convert more methods to use ReturnedValueLars Knoll2013-09-181-5/+8
| | | | | | | Change Exception.value() and a few other places. Change-Id: I53ce17e5656e260138b1ac7f6d467e4636c0a0b9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use ReturnedValue for Managed::get().Lars Knoll2013-09-181-1/+1
| | | | | Change-Id: Ia8f35d227b69d32e1f6a041283abbbd083aa34ca Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a ReturnedValue for Managed::call()Lars Knoll2013-09-181-4/+4
| | | | | Change-Id: Ief2d75e9789dd367c603d90dc0fe5316a0d055e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a ReturnedValue when converting to String or ObjectLars Knoll2013-09-121-1/+1
| | | | | | | | Also rename Value::toQString() to Value::toQStringNoThrow(), and add a throwing toQString() method for JS use. Change-Id: I821b33fc61abb7d08839df965fd337685f61a545 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change signature of call/construct() to take a pointer to a CallDataLars Knoll2013-09-111-4/+4
| | | | | Change-Id: I5467aadba083e4b01fb0a7170946695207033680 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup calls to Object::setPrototype()Lars Knoll2013-09-021-2/+0
| | | | | | | | 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-2/+2
| | | | | | | | | | | | | 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>
* change calling convention for JS function callsLars Knoll2013-09-021-4/+4
| | | | | | | | | | | | 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>
* Fix crashes when running tst_qqmlecmascript::importScripts with aggressive gcSimon Hausmann2013-09-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-08-201-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Refcount the compilation unit and remove refcount from runtime functionSimon Hausmann2013-08-161-0/+2
| | | | | | | | | | Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove QV4::DiagnosticMessageLars Knoll2013-08-201-13/+1
|/ | | | | | | | | | 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 the llvm isel backendLars Knoll2013-08-081-169/+1
| | | | | | | This code never worked. Change-Id: I0fd7421ae983f3ad43e84e5d7579cdbb610ab2b2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Initial support for debugging in the v4 interpreterSimon Hausmann2013-07-261-14/+0
| | | | | | | | | This adds breakpoint support to the Debugger, a helper function in the engine for enabling debugging (which will switch from JIT to the interpreter) and a DebuggingAgent interface, for use by v4 clients. Change-Id: I78e17a6cbe7196b0dfe4ee157fc028532131caa3 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Move QV4::Exception into a separate compilation unit with header fileSimon Hausmann2013-07-121-0/+1
| | | | | | | | This is in preparation for some platform specific code regarding throwing exceptions, as well as a general cleanup :) Change-Id: I23fb4f12fd09423a1f2cb225145780925002677b Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Disable the JIT on Windows/AMD64 as well as on iOSSimon Hausmann2013-06-261-1/+6
| | | | | Change-Id: I7402981caa2f73fd0712975e657488a4065f403f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove the context argument from Managed::callLars Knoll2013-06-221-5/+5
| | | | | Change-Id: I0895f9a94af47c8aab1dc93579921737e9516f7d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove context parameter from Manged::put.Lars Knoll2013-06-221-5/+3
| | | | | Change-Id: Ib99e726ffbb20463d45a8444b4fbdfe32cd6dbef Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make it possible to evaluate JS with the v4 tool the QML waySimon Hausmann2013-06-171-0/+7
| | | | | Change-Id: I2a40e82612c2da1b52a37cbff2507951e4ac0349 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix file and line number reporting of QML/JS errorsSimon Hausmann2013-05-271-1/+1
| | | | | | | | | | | * Replace QUrl with QString in V4 for the source location (we don't need URL parsing) * Replace line number and file in QV4::Exception with the information we retrieve from the stack trace of the exception. Fixes about five tst_qqmlecmascript tests that relied on correct file/line number information Change-Id: I2a3daa72be6c5587fd965211ea8f6fb77142e7ee Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add support for line numbers in stack traces (Linux/Mac OS X only at this point)Simon Hausmann2013-05-271-16/+22
| | | | | | | | | | | | | | | | * Add support for debug annotations on statement boundaries to the IR, to get accurate line/column information * Use binary search to retrieve the function and line number for a given program counter * Save the stack trace in the exception class and print it in v4 * Fix initial line number in QV4::Script to start a 1, just like the initial column in QQmlJS::Lexer also starts at 1 The native stack frame tracing is currently only implemented on Linux and Mac OS X. The implementation for Windows using StackWalk64 is still missing. Change-Id: I771fe44816397e29c69952772a772bf0d985236f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Various fixesLars Knoll2013-05-221-5/+4
| | | | | | | | Fix a regression in Script::run, and compilation for v4 and an auto test. Change-Id: I4026eebec0e02f4af03ca49ba714916ad90b34e7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add flag to the engine to enable/disable RegExp JITting.Erik Verbruggen2013-05-081-1/+6
| | | | | Change-Id: I4b632e6f8ab7cf20576f94764ed506de8be63efb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanups to QV4::LookupLars Knoll2013-04-201-19/+19
| | | | | | | | | Better naming for the methods, deinline some code, add a generic path for setters and prepare for moving parts of it into the Managed's vtable. Change-Id: Ide8d32181fdabdf34c910db20b28fb8f87167570 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix compilation with built-in v4vm JS engineSimon Hausmann2013-04-151-9/+9
| | | | | Change-Id: Ieda9267e296acf6392a5461f4cfb9233a7a409a0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Store the global object as an Object pointer in the engineLars Knoll2013-04-081-1/+1
| | | | | Change-Id: Ia8b010a9d9c9dd3aacb1b08ce34a42236fa73195 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Check if "use strict" has no escaped chars.Erik Verbruggen2013-03-181-1/+1
| | | | | Change-Id: I7dc172eba02d454467ead1e18a1a59e98890dd54 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Rename qmljs_runtime to qv4runtimeLars Knoll2013-03-141-1/+1
| | | | | Change-Id: I46ba9b2621be72116d94bee249ad5b798e951c88 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rename qmljs_environment.* to qv4context.*Lars Knoll2013-03-141-1/+1
| | | | | Change-Id: I6fe62b501803422f78b47a87c55e4278820725aa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* "Fix" llvm build.Erik Verbruggen2013-03-071-0/+5
| | | | | | | In a way that it the compiler doesn't complain anymore. Change-Id: I877b1a051b2ffcbd63a04cf219733b2b21cb9128 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup put and properly implement it for stringsLars Knoll2013-03-071-2/+2
| | | | | Change-Id: I10dda09c8a087bc7ef34c0315c698e08c35ec28d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* First part of moving get/put etc. into the Managed vtbl.Lars Knoll2013-03-071-1/+1
| | | | | Change-Id: I6fe14b02205901dbffa25c6c1b4883fb99586417 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of 'Value ExecutionEngine::exception' memberSimon Hausmann2013-03-061-5/+4
| | | | | | | | | Instead the JS exception value is now part of the C++ Exception object. This also allows getting rid of some run-time functions. Change-Id: I43ff773cacd5e925ba96601f3633ccf3b62273be Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move function execution into a little ExecutionEngine::run helper functionSimon Hausmann2013-03-051-13/+5
| | | | | | | This will allow for re-use from the v8 wrapper API. Change-Id: I2330432dad43d7fd7af6147e96a0cbbb340cd917 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Get rid of manual unwind stackSimon Hausmann2013-03-041-1/+2
| | | | | | | | | | | | | | | | | Instead of doing the ExecutionContext unwinding at the time of throw, do it at the time of catch, conveniently through an accept() method of the Exception object. That allows us to get rid of the separate handler registration stack. The only tricky part are that some execution contexts are allocated on the stack. When exceptions are thrown through that, we have to catch, unwinding up until that point (or rather the parent of the stack allocated context that's going to be deleted) and then simply rethrow. This patch also gets rid of the __builtin_delete_exception_handler. The next patch will rename the remainder to what it really does now. Change-Id: I00bb113b3a2fe24f7054c03fdfb8fed5cc1258b1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement JavaScript exceptions using C++ exceptionsSimon Hausmann2013-03-031-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of registering catch handlers with setjmp and throwing JS exceptions with longjmp, they are now thrown and caught as C++ exceptions. This allows for tight interoperability between C++ and JS in the future and allows for clear semantics with regards to cleaning up memory in the engine when throwing exceptions. (destructors are guaranteed to be called, unlike with setjmp/longjmp). The recent unwind table additions allow for the exceptions to be thrown through JIT generated code. Catching the exception is done by re-using the existing IR semantics where the beginning of a try block is marked by registering an exception handler. Execution after the registration continues conditionally, based on the return value of builtin_create_exception_handler. A return value of is 0 the try block(s) are executed. If an exception is thrown during that time, execution resumes at the point where builtin_create_exception_handler returns, but with a return value of 1. If an exception is thrown within the catch handler, the execution resumes again at the same point, but the inCatch IR variable will guide execution straight to the finally block(s), which calls delete_exception_handler. In the JIT as well as the interpreter this is implemented by entering a C++ code section that contains a C++ try {} catch {} block, in which the calling function is called again and continues right at the next instruction (or the interpreter loop is recursively entered). An exception will throw us out of that scope and back into the try {} catch {} wrapper, which can call again into the calling function. The IR guarantees that delete_exception_handler is always called, regardless of how the try or catch blocks are terminated. That is where in the JIT and interpreter we return from the nested function call and return back into the original stack frame, effectively unregistering the catch handler. Further cleanups with regards to the naming and the exception handler stack will come in subsequent patches, this is merely the minimal patch set to change to the new mechanism. This patch set breaks ARM until ARM exception handler tables are implemented. The interpreter changes are based on a patchset from Erik from https://codereview.qt-project.org/#change,45750 Change-Id: I543f2bd37b2186f7e48ffcab177d57b5ce932a0c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Silence compilerLars Knoll2013-02-141-1/+1
| | | | | Change-Id: Id248400c50609811baebb1ea710210915e5274c9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move call/construct over into the new vtable.Lars Knoll2013-02-141-2/+12
| | | | | Change-Id: I4f58a1fac25440695bdc62a49adb51a887616a5c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix print and gc in builtin v4 methodSimon Hausmann2013-02-141-34/+4
| | | | | | | Also removed unused TestHarness stuff. Change-Id: I6332d9a34f471df07cfa0e9709a203e99a48b524 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement a first iteration of the fast property lookup schemeLars Knoll2013-02-121-0/+1
| | | | | | | | | Fast lookups still require a function call, and will only work for properties defined on the object itself. Properties of the prototype will still be slow. Change-Id: I07c601998d312b1bd8e9977708d3375bf72df3e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unnecessary sys/mman.h inclusionSimon Hausmann2013-02-091-1/+0
| | | | | Change-Id: Ic4bbc6a595849042a9c970ba2d0ad5785fe1b89a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix exports in v4 binarySimon Hausmann2013-02-091-3/+3
| | | | | | | Don't use the export macro on internal debug classes. Change-Id: Id2f8069cc8b6703a3fafd3058524d46252eb57f8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fixed the llvm bits of the build process.Erik Verbruggen2013-02-061-17/+16
| | | | | Change-Id: I618e0ee413e9548817f84473917ccb8051f689f2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>