diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-27 12:07:15 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:20:43 +0000 |
commit | 7ab47893a5647ecd2fc12e9e4e7504969b4185bb (patch) | |
tree | 1419ca0eb4c90c5148d3858bfde56cfe1f4eaed4 /src | |
parent | 481f69ef2b507454e15a2354a7b6e85d671ee793 (diff) |
Move interpreter loop into it's own function
This will be required to make Generators work properly
Change-Id: I1262d8694674ea3436f496fae30668a939327ab7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 43 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth_p.h | 1 |
3 files changed, 26 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index fce220907e..87eec81afb 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -197,6 +197,7 @@ namespace Heap { template <typename T, size_t> struct Pointer; } +struct CppStackFrame; class MemoryManager; class ExecutableAllocator; struct StringOrSymbol; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 1567269932..17255c7e9e 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -479,7 +479,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs) } } -#define STORE_IP() frame.instructionPointer = int(code - codeStart); +#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) \ @@ -553,10 +553,6 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling QV4::Debugging::Debugger *debugger = engine->debugger(); - const uchar *exceptionHandler = nullptr; - - QV4::Value &accumulator = frame.jsFrame->accumulator; - QV4::ReturnedValue acc = Encode::undefined(); #ifdef V4_ENABLE_JIT if (function->jittedCode == nullptr && debugger == nullptr) { @@ -570,12 +566,30 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj if (debugger) debugger->enteringFunction(); + ReturnedValue result; if (function->jittedCode != nullptr && debugger == nullptr) { - acc = function->jittedCode(&frame, engine); + result = function->jittedCode(&frame, engine); } else { // interpreter - const uchar *code = function->codeData; - const uchar *codeStart = code; + 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 uchar *code) +{ + QV4::Function *function = frame.v4Function; + QV4::Value &accumulator = frame.jsFrame->accumulator; + QV4::ReturnedValue acc = Encode::undefined(); + Value *stack = reinterpret_cast<Value *>(frame.jsFrame); + ExecutionEngine *engine = function->internalClass->engine; + const uchar *exceptionHandler = nullptr; MOTH_JUMP_TABLE; @@ -1372,7 +1386,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj MOTH_END_INSTR(ShlConst) MOTH_BEGIN_INSTR(Ret) - goto functionExit; + return acc; MOTH_END_INSTR(Ret) MOTH_BEGIN_INSTR(Debug) @@ -1394,17 +1408,8 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj Q_ASSERT(engine->hasException); if (!exceptionHandler) { acc = Encode::undefined(); - goto functionExit; + return acc; } code = exceptionHandler; } - } - -functionExit: - if (QV4::Debugging::Debugger *debugger = engine->debugger()) - debugger->leavingFunction(ACC.asReturnedValue()); - engine->currentStackFrame = frame.parent; - engine->jsStackTop = stack; - - return acc; } diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index 3b7723ca7e..737ff3f519 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -72,6 +72,7 @@ public: return exec(reinterpret_cast<const FunctionObject *>(d), thisObject, argv, argc); } static QV4::ReturnedValue exec(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc); + static QV4::ReturnedValue interpret(CppStackFrame &frame, const uchar *codeEntry); }; } // namespace Moth |