diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-28 12:33:00 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-28 13:20:29 +0000 |
commit | 1e6b41cc180b99dfdbc58d61258871677a643ca6 (patch) | |
tree | b50bebf4fff02dca7e59cafc198b13fdf68eecb4 /src/qml/jsruntime | |
parent | 4c66a78e2f72a2767a7a4b7587436ecdfb3aebdb (diff) |
Cleanup and inline context push/pop related code
Change-Id: I38ee6c3039663e10aee47b2005f8755fc9c50289
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 26 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 10 |
3 files changed, 15 insertions, 27 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 8fe000507f..115129672d 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1189,27 +1189,18 @@ ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine) * * Instead the push/pop pair acts as a non local scope. */ -ReturnedValue Runtime::method_pushWithContext(const Value &o, NoThrowEngine *engine) +ReturnedValue Runtime::method_createWithContext(ExecutionContext *parent, const Value &o) { Q_ASSERT(o.isObject()); - ExecutionContext *c = engine->currentContext(); - ReturnedValue oldContext = c->asReturnedValue(); const Object &obj = static_cast<const Object &>(o); - engine->setCurrentContext(c->newWithContext(obj.d())); - return oldContext; + return parent->newWithContext(obj.d())->asReturnedValue(); } -ReturnedValue Runtime::method_pushCatchContext(NoThrowEngine *engine, int exceptionVarNameIndex) +ReturnedValue Runtime::method_createCatchContext(ExecutionContext *parent, int exceptionVarNameIndex) { - ExecutionContext *c = engine->currentContext(); - ReturnedValue oldContext = c->asReturnedValue(); - engine->setCurrentContext(c->newCatchContext(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0))); - return oldContext; -} - -void Runtime::method_popContext(NoThrowEngine *engine, const Value &oldContext) -{ - engine->setCurrentContext(static_cast<const ExecutionContext &>(oldContext).d()); + ExecutionEngine *e = parent->engine(); + return parent->newCatchContext(e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex], + e->catchException(0))->asReturnedValue(); } void Runtime::method_declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) @@ -1287,11 +1278,6 @@ ReturnedValue Runtime::method_loadQmlContext(NoThrowEngine *engine) return engine->qmlContext()->asReturnedValue(); } -ReturnedValue Runtime::method_regexpLiteral(ExecutionEngine *engine, int id) -{ - return static_cast<CompiledData::CompilationUnit*>(engine->currentStackFrame->v4Function->compilationUnit)->runtimeRegularExpressions[id].asReturnedValue(); -} - ReturnedValue Runtime::method_loadQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, bool captureRequired) { const QmlContext &c = static_cast<const QmlContext &>(context); diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index c46e848ca4..68ac28919d 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -125,9 +125,8 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> { /* exceptions & scopes */ \ F(void, throwException, (ExecutionEngine *engine, const Value &value)) \ F(ReturnedValue, unwindException, (ExecutionEngine *engine)) \ - F(ReturnedValue, pushWithContext, (const Value &o, NoThrowEngine *engine)) \ - F(ReturnedValue, pushCatchContext, (NoThrowEngine *engine, int exceptionVarNameIndex)) \ - F(void, popContext, (NoThrowEngine *engine, const Value &oldContext)) \ + F(ReturnedValue, createWithContext, (ExecutionContext *parent, const Value &o)) \ + F(ReturnedValue, createCatchContext, (ExecutionContext *parent, int exceptionVarNameIndex)) \ \ /* closures */ \ F(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)) \ @@ -140,7 +139,6 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> { /* literals */ \ F(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)) \ F(ReturnedValue, objectLiteral, (ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)) \ - F(ReturnedValue, regexpLiteral, (ExecutionEngine *engine, int id)) \ \ /* foreach */ \ F(ReturnedValue, foreachIterator, (ExecutionEngine *engine, const Value &in)) \ diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 607b0b978c..37d2e52fb5 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -825,7 +825,9 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat MOTH_END_INSTR(UnwindException) MOTH_BEGIN_INSTR(PushCatchContext) - STACK_VALUE(reg) = Runtime::method_pushCatchContext(static_cast<QV4::NoThrowEngine*>(engine), name); + STACK_VALUE(reg) = STACK_VALUE(JSStackFrame::Context); + ExecutionContext *c = static_cast<ExecutionContext *>(stack + JSStackFrame::Context); + STACK_VALUE(JSStackFrame::Context) = Runtime::method_createCatchContext(c, name); MOTH_END_INSTR(PushCatchContext) MOTH_BEGIN_INSTR(PushWithContext) @@ -833,11 +835,13 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat STORE_ACC(); accumulator = accumulator.toObject(engine); CHECK_EXCEPTION; - STACK_VALUE(reg) = Runtime::method_pushWithContext(accumulator, static_cast<QV4::NoThrowEngine*>(engine)); + STACK_VALUE(reg) = STACK_VALUE(JSStackFrame::Context); + ExecutionContext *c = static_cast<ExecutionContext *>(stack + JSStackFrame::Context); + STACK_VALUE(JSStackFrame::Context) = Runtime::method_createWithContext(c, accumulator); MOTH_END_INSTR(PushWithContext) MOTH_BEGIN_INSTR(PopContext) - Runtime::method_popContext(static_cast<QV4::NoThrowEngine*>(engine), STACK_VALUE(reg)); + STACK_VALUE(JSStackFrame::Context) = STACK_VALUE(reg); MOTH_END_INSTR(PopContext) MOTH_BEGIN_INSTR(ForeachIteratorObject) |