aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4vme_moth.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-27 12:00:44 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-03 08:08:42 +0000
commit8e7f28339f57d22e4a8bdb30af449151c89d75db (patch)
treee890fcdb4d6219668b4eaa4da9b1955cff09e52d /src/qml/jsruntime/qv4vme_moth.cpp
parent65e799a9dec58b4bde3a085149f8cbcf0f5f3fba (diff)
Smaller refactoring of VME::exec() to preapre for upcoming changes
We'll need a more flexible interface here to support derived constructors properly. There's also quite some code in the generator functions that could benefit from some cleanups. Change-Id: I951b5d2171efa80d52fd6b0155f8f2c78af2f3b5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4vme_moth.cpp')
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp94
1 files changed, 51 insertions, 43 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 8cdf0937ad..ade2a36ad1 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -391,7 +391,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
}
}
-#define STORE_IP() frame.instructionPointer = int(code - function->codeData);
+#define STORE_IP() frame->instructionPointer = int(code - function->codeData);
#define STORE_ACC() accumulator = acc;
#define ACC Primitive::fromReturnedValue(acc)
#define VALUE_TO_INT(i, val) \
@@ -412,6 +412,39 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
} \
} while (false)
+ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
+{
+ CHECK_STACK_LIMITS(engine);
+
+ Function *function = frame->v4Function;
+ Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling
+ QV4::Debugging::Debugger *debugger = engine->debugger();
+
+#ifdef V4_ENABLE_JIT
+ if (debugger == nullptr) {
+ if (function->jittedCode == nullptr) {
+ if (engine->canJIT(function))
+ QV4::JIT::BaselineJIT(function).generate();
+ else
+ ++function->interpreterCallCount;
+ }
+ if (function->jittedCode != nullptr)
+ return function->jittedCode(frame, engine);
+ }
+#endif // V4_ENABLE_JIT
+
+ // interpreter
+ if (debugger)
+ debugger->enteringFunction();
+
+ ReturnedValue result = interpret(frame, engine, function->codeData);
+
+ if (debugger)
+ debugger->leavingFunction(result);
+
+ return result;
+}
+
QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObject, const QV4::Value *argv, int argc, const Value *newTarget)
{
qt_v4ResolvePendingBreakpointsHook();
@@ -467,46 +500,21 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
frame.jsFrame = callData;
engine->currentStackFrame = &frame;
}
- CHECK_STACK_LIMITS(engine);
-
- Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling
- QV4::Debugging::Debugger *debugger = engine->debugger();
-#ifdef V4_ENABLE_JIT
- if (function->jittedCode == nullptr && debugger == nullptr) {
- if (engine->canJIT(function))
- QV4::JIT::BaselineJIT(function).generate();
- else
- ++function->interpreterCallCount;
- }
-#endif // V4_ENABLE_JIT
+ ReturnedValue result = exec(&frame, engine);
- if (debugger)
- debugger->enteringFunction();
-
- ReturnedValue result;
- if (function->jittedCode != nullptr && debugger == nullptr) {
- result = function->jittedCode(&frame, engine);
- } else {
- // interpreter
- result = interpret(frame, function->codeData);
- }
-
- if (QV4::Debugging::Debugger *debugger = engine->debugger())
- debugger->leavingFunction(result);
engine->currentStackFrame = frame.parent;
engine->jsStackTop = stack;
return result;
}
-QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code)
+QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, const char *code)
{
- QV4::Function *function = frame.v4Function;
- QV4::Value &accumulator = frame.jsFrame->accumulator;
+ QV4::Function *function = frame->v4Function;
+ QV4::Value &accumulator = frame->jsFrame->accumulator;
QV4::ReturnedValue acc = accumulator.asReturnedValue();
- Value *stack = reinterpret_cast<Value *>(frame.jsFrame);
- ExecutionEngine *engine = function->internalClass->engine;
+ Value *stack = reinterpret_cast<Value *>(frame->jsFrame);
MOTH_JUMP_TABLE;
@@ -704,7 +712,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code)
MOTH_END_INSTR(LoadIdObject)
MOTH_BEGIN_INSTR(Yield)
- frame.yield = code;
+ frame->yield = code;
return acc;
MOTH_END_INSTR(Yield)
@@ -808,22 +816,22 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code)
MOTH_END_INSTR(ConstructWithSpread)
MOTH_BEGIN_INSTR(SetUnwindHandler)
- frame.unwindHandler = offset ? code + offset : nullptr;
+ frame->unwindHandler = offset ? code + offset : nullptr;
MOTH_END_INSTR(SetUnwindHandler)
MOTH_BEGIN_INSTR(UnwindDispatch)
CHECK_EXCEPTION;
- if (frame.unwindLevel) {
- --frame.unwindLevel;
- if (frame.unwindLevel)
+ if (frame->unwindLevel) {
+ --frame->unwindLevel;
+ if (frame->unwindLevel)
goto handleUnwind;
- code = frame.unwindLabel;
+ code = frame->unwindLabel;
}
MOTH_END_INSTR(UnwindDispatch)
MOTH_BEGIN_INSTR(UnwindToLabel)
- frame.unwindLevel = level;
- frame.unwindLabel = code + offset;
+ frame->unwindLevel = level;
+ frame->unwindLabel = code + offset;
goto handleUnwind;
MOTH_END_INSTR(UnwindToLabel)
@@ -853,7 +861,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code)
MOTH_END_INSTR(PushCatchContext)
MOTH_BEGIN_INSTR(CreateCallContext)
- stack[CallData::Context] = ExecutionContext::newCallContext(&frame);
+ stack[CallData::Context] = ExecutionContext::newCallContext(frame);
MOTH_END_INSTR(CreateCallContext)
MOTH_BEGIN_INSTR(PushWithContext)
@@ -1371,11 +1379,11 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code)
MOTH_END_INSTR(LoadQmlImportedScripts)
handleUnwind:
- Q_ASSERT(engine->hasException || frame.unwindLevel);
- if (!frame.unwindHandler) {
+ Q_ASSERT(engine->hasException || frame->unwindLevel);
+ if (!frame->unwindHandler) {
acc = Encode::undefined();
return acc;
}
- code = frame.unwindHandler;
+ code = frame->unwindHandler;
}
}