aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-06-13 12:29:02 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-03 13:21:10 +0200
commitdb3dd029d7cd911712102efd5ea71868494f9f6f (patch)
tree143e600d5393496b2b77ed7da74b94fc864efcf8 /src/qml/jsruntime
parenteeb00570679c447f4701a92cd2e836f098724979 (diff)
Fix various accumulator-saving problems
We need to keep the accumulator alive across function calls. This requires: 1, Saving the accumulator on the stack if the function might allocate, to protect it from the garbage collector. However, we don't need to do that if the result of the function is to be saved in the accumulator and the function itself doesn't use the accumulator as argument. In this case the previous value becomes unaccessible and we might as well GC it. 2, In the JIT, restoring the accumulator from the stack after the function call if we want to ignore the return value. 3, Therefore, also saving the accumulator on the stack before calling in case of 2. We assume that we don't need to keep the accumulator alive across the jump to the exception handler. Saving the accumulator more often than necessary is detrimental for performance. To make sure the assumption holds, explicitly load the accumulator with undefined _before_ jumping to any exception handler. Change-Id: I78cbc42847b8885a0659b23f3b81655b7f1a0bc4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index c69bb67061..47ad22f4f7 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -640,7 +640,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(LoadSuperProperty)
STORE_IP();
- STORE_ACC();
acc = Runtime::method_loadSuperProperty(engine, STACK_VALUE(property));
CHECK_EXCEPTION;
MOTH_END_INSTR(LoadSuperProperty)
@@ -787,12 +786,14 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(Construct)
STORE_IP();
+ STORE_ACC();
acc = Runtime::method_construct(engine, STACK_VALUE(func), ACC, stack + argv, argc);
CHECK_EXCEPTION;
MOTH_END_INSTR(Construct)
MOTH_BEGIN_INSTR(ConstructWithSpread)
STORE_IP();
+ STORE_ACC();
acc = Runtime::method_constructWithSpread(engine, STACK_VALUE(func), ACC, stack + argv, argc);
CHECK_EXCEPTION;
MOTH_END_INSTR(ConstructWithSpread)
@@ -820,7 +821,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(DeadTemporalZoneCheck)
if (ACC.isEmpty()) {
STORE_IP();
- STORE_ACC();
Runtime::method_throwReferenceError(engine, name);
goto handleUnwind;
}
@@ -989,6 +989,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
if (t->isNullOrUndefined()) {
*t = engine->globalObject->asReturnedValue();
} else {
+ STORE_ACC();
*t = t->toObject(engine)->asReturnedValue();
CHECK_EXCEPTION;
}
@@ -1001,6 +1002,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_END_INSTR(LoadSuperConstructor)
MOTH_BEGIN_INSTR(ToObject)
+ STORE_ACC();
acc = ACC.toObject(engine)->asReturnedValue();
CHECK_EXCEPTION;
MOTH_END_INSTR(ToObject)