aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-08 10:56:34 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-10 08:19:18 +0000
commit5bc4f4d958a3b76f3435d61206ca0109f07aa1a3 (patch)
treecb2ef4772f2d343e9957271161ac32809bc5d0a6 /src/qml/jsruntime/qv4context.cpp
parent30e3664bf3668bda9a211fe7d1404f8f806dbf7b (diff)
Refactor context handling
Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4context.cpp')
-rw-r--r--src/qml/jsruntime/qv4context.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index ddb5dc4ea5..c9565468ad 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -232,18 +232,16 @@ bool ExecutionContext::deleteProperty(String *name)
// Do a standard call with this execution context as the outer scope
ReturnedValue ExecutionContext::call(ExecutionEngine *engine, CallData *callData, Function *function, const FunctionObject *f)
{
- Scope scope(engine);
- ExecutionContextSaver ctxSaver(engine);
-
- Scoped<CallContext> ctx(scope, newCallContext(function, callData));
+ Heap::CallContext *ctx = newCallContext(function, callData);
if (f)
- ctx->d()->function.set(engine, f->d());
- engine->pushContext(ctx);
+ ctx->function.set(engine, f->d());
- ReturnedValue res = Q_V4_PROFILE(engine, function, f);
+ ReturnedValue res = Q_V4_PROFILE(engine, ctx, function, f);
- if (function->hasQmlDependencies)
- QQmlPropertyCapture::registerQmlDependencies(engine, function->compiledFunction);
+ if (function->hasQmlDependencies) {
+ Q_ASSERT(d()->type == Heap::ExecutionContext::Type_QmlContext);
+ QQmlPropertyCapture::registerQmlDependencies(static_cast<QmlContext *>(this), engine, function->compiledFunction);
+ }
return res;
}
@@ -258,17 +256,12 @@ ReturnedValue QV4::ExecutionContext::simpleCall(ExecutionEngine *engine, CallDat
for (int i = callData->argc; i < (int)function->nFormals; ++i)
callData->args[i] = Encode::undefined();
- ExecutionContext *old = engine->currentContext;
- engine->currentContext = this;
- engine->current = d();
-
- ReturnedValue res = Q_V4_PROFILE(engine, function, 0);
+ ReturnedValue res = Q_V4_PROFILE(engine, d(), function, 0);
- if (function->hasQmlDependencies)
- QQmlPropertyCapture::registerQmlDependencies(engine, function->compiledFunction);
-
- engine->currentContext = old;
- engine->current = old->d();
+ if (function->hasQmlDependencies) {
+ Q_ASSERT(d()->type == Heap::ExecutionContext::Type_QmlContext);
+ QQmlPropertyCapture::registerQmlDependencies(static_cast<QmlContext *>(this), engine, function->compiledFunction);
+ }
engine->jsStackTop = jsStackTop;