Commit Graph

25 Commits

Author SHA1 Message Date
Lars Knoll 34bf0139c7 Rework IR code generation for try/catch/finally
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>
2013-10-29 10:38:48 +01:00
Lars Knoll 5229a8b259 Rework exception handling
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>
2013-10-29 10:38:45 +01:00
Simon Hausmann b93ddb95a7 Qml JavaScript code generation cleanups
* 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>
2013-10-20 21:11:54 +02:00
Erik Verbruggen 7c3f891c45 V4: remove inplace operations
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>
2013-09-30 11:28:55 +02:00
Simon Hausmann bbb78a92a9 Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into HEAD
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
2013-09-20 08:29:17 +02:00
Lars Knoll 525c4ee8a9 Remove unused code to generate post increment and decrement expressions
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>
2013-09-12 21:52:16 +02:00
Simon Hausmann bf22c55036 Fix passing of exception table pointers to ARM runtime on unwinding
Our synthetic exception unwind table for ARM is located at

    (char *)codeStart + function->codeSize;

This relies on function->codeSize to contain the number of bytes of
instructions the function has, not the size of the MacroAssemblerCodeRef
(which contains the size of the entire area).

This patch fixes the calculation of function->codeSize and also replaces
the QHash for the IR::Function* -> CodeRef mapping in the masm backend
with a simple vector that's perfectly sufficient.

Bug spotted by Petr Nejedly

Change-Id: I78a53599085c613c6d97aa2490922f54e0bb4f63
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-12 19:05:44 +02:00
Simon Hausmann 5b456c8da4 Beginning of a new qml parser
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>
2013-09-08 09:00:05 +02:00
Simon Hausmann c5694ba573 Make it possible to supply an external JS unit generator to the isel
This is needed for QML unit generation, when we share the JS generator
for QML types/strings and JS code.

Change-Id: I50f0c1fa6721d6e3e59417c6c256c82aec124e8f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-05 20:26:42 +02:00
Erik Verbruggen 7313a37119 The fast and the furious, register drift.
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>
2013-08-27 13:55:24 +02:00
Simon Hausmann 461892e492 Merge branch 'wip/v4' of ssh://codereview.qt-project.org/qt/qtdeclarative 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
2013-08-20 16:54:29 +02:00
Simon Hausmann d04ba0f62a Cleanup: Make isel subclass the unit generator
Change-Id: Iadff4974ec6fde25c6586d03d23136ea280f9555
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-18 12:35:47 +02:00
Simon Hausmann 41cc5cca4f Get rid of engine pointer in isel
Change-Id: I58759712624713cd2215621dca4ccc86fa9a9194
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-18 12:32:53 +02:00
Lars Knoll 3cfc7e0c02 Move arguments object creation into the generated code
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>
2013-08-17 09:26:30 +02:00
Simon Hausmann 3314912318 Eliminate all vm functions on the isel side
Change-Id: I7c0e50498c937ce554b019f98829fa8c5d96c18e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 21:38:07 +02:00
Simon Hausmann 0f0e7443ae Refcount the compilation unit and remove refcount from runtime function
Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 19:18:48 +02:00
Simon Hausmann 2aee966baa Initialize formals and locals from the compiled function data instead of in the isel
Change-Id: I9db976df310a5986ceca66d21efeeae536dbede4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 10:37:29 +02:00
Simon Hausmann 335a903d4b Move the masm compilation unit entirely into qv4isel_masm
Change-Id: If24b6a761dc2f2443520b31b5130ab44b739cdf3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:11:42 +02:00
Simon Hausmann 3e49617bc6 Move QV4::Function::sourceFile to CompiledFunction
Change-Id: Iacf907c475070bab4a5a1583280f110c089141c4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:11:36 +02:00
Simon Hausmann 83a975ae1c Get rid of flags in QV4::Function and use CompiledFunction::flags instead
Change-Id: Iffe72ff6dd0311d7548d1ea41164a400fd3a7600
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:08:53 +02:00
Simon Hausmann 0d1e37e9f5 Fix writing the function offset table and initialize the pointer to the compiled function in the runtime function
Change-Id: I9aed9f394fedc4a4ea334f6ab1b72fe749c64c72
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:08:44 +02:00
Simon Hausmann 5f3ef18bf8 Begin using the compiled data structures for runtime strings
Change-Id: Idbf278a96624bf101df35de40577b38e593f22be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:08:39 +02:00
Simon Hausmann 7c2adbbb6c Add reference counting to the VM functions
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>
2013-08-12 13:29:27 +02:00
Simon Hausmann e14df5bb36 Get rid of unused outer function pointer of QV4::Function
Change-Id: I3ea88d3c259447081d1ac5f85d7da95fed8f02f6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-12 07:53:43 +02:00
Lars Knoll 3288b87e2f Restructure source code
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>
2013-08-08 12:22:30 +02:00