aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4vme_moth.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-27 17:23:39 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-03 08:08:53 +0000
commitdeaa99f66ddedc2ea79e6902c665925b04665e68 (patch)
treeaf0cb554eb40d9138f9cf723f0aa982991205635 /src/qml/jsruntime/qv4vme_moth.cpp
parent2666fe4a1440cc798b9db68fcc807450d46069c2 (diff)
Refactor initialization code for JS stack frames
Move code into qv4stackframe_p.h, so that it can be re-used from different places. Clean up VME::exec and the generatorfunctions using this. Change-Id: Ib4f7eceeb5f55d98dd6ccf2584d13a3b864caea1 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.cpp65
1 files changed, 1 insertions, 64 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index ade2a36ad1..4f0f9f27ec 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -414,6 +414,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
{
+ qt_v4ResolvePendingBreakpointsHook();
CHECK_STACK_LIMITS(engine);
Function *function = frame->v4Function;
@@ -445,70 +446,6 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
return result;
}
-QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObject, const QV4::Value *argv, int argc, const Value *newTarget)
-{
- qt_v4ResolvePendingBreakpointsHook();
- ExecutionEngine *engine;
- QV4::Value *stack;
- CppStackFrame frame;
- frame.originalArguments = argv;
- frame.originalArgumentsCount = argc;
- frame.yield = nullptr;
- frame.unwindHandler = nullptr;
- frame.unwindLabel = nullptr;
- frame.unwindLevel = 0;
-
- Function *function;
-
- {
- Heap::ExecutionContext *scope;
-
- quintptr d = reinterpret_cast<quintptr>(fo);
- if (d & 0x1) {
- // we don't have a FunctionObject, but a ExecData
- ExecData *data = reinterpret_cast<ExecData *>(d - 1);
- function = data->function;
- scope = data->scope->d();
- fo = nullptr;
- } else {
- function = fo->function();
- scope = fo->scope();
- }
-
- engine = function->internalClass->engine;
-
- stack = engine->jsStackTop;
- CallData *callData = reinterpret_cast<CallData *>(stack);
- callData->function = fo ? fo->asReturnedValue() : Encode::undefined();
- callData->context = scope;
- callData->accumulator = Encode::undefined();
- callData->newTarget = newTarget ? *newTarget : Primitive::undefinedValue();
- callData->thisObject = thisObject ? *thisObject : Primitive::undefinedValue();
- if (argc > int(function->nFormals))
- argc = int(function->nFormals);
- callData->setArgc(argc);
-
- int jsStackFrameSize = offsetof(CallData, args)/sizeof(Value) + function->compiledFunction->nRegisters;
- engine->jsStackTop += jsStackFrameSize;
- memcpy(callData->args, argv, argc*sizeof(Value));
- for (Value *v = callData->args + argc; v < engine->jsStackTop; ++v)
- *v = Encode::undefined();
-
- frame.parent = engine->currentStackFrame;
- frame.v4Function = function;
- frame.instructionPointer = 0;
- frame.jsFrame = callData;
- engine->currentStackFrame = &frame;
- }
-
- ReturnedValue result = exec(&frame, engine);
-
- engine->currentStackFrame = frame.parent;
- engine->jsStackTop = stack;
-
- return result;
-}
-
QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, const char *code)
{
QV4::Function *function = frame->v4Function;