diff options
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 2 |
9 files changed, 19 insertions, 23 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 107ec60943..ebd28b36e0 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -63,7 +63,7 @@ void JavaScriptJob::run() { QV4::Scope scope(engine); - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(engine); QV4::ExecutionContext *ctx = engine->currentContext; QObject scopeObject; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index cbf4eb1539..c4d5e5f683 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -249,7 +249,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Scope scope(m_engine); m_runningJob = true; - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(m_engine); QV4::ExecutionContext *ctx = m_engine->currentContext; m_engine->pushContext(ctx); diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index e4c150057a..1c7540778b 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -438,7 +438,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in { QV4::ExecutionEngine *v4 = d->m_v4Engine; QV4::Scope scope(v4); - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(v4); QV4::ExecutionContext *ctx = v4->currentContext; if (ctx->d() != v4->rootContext()->d()) diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index da76da839b..4053eb4f09 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -234,7 +234,7 @@ bool ExecutionContext::deleteProperty(String *name) // Do a standard call with this execution context as the outer scope ReturnedValue ExecutionContext::call(Scope &scope, CallData *callData, Function *function, const FunctionObject *f) { - ExecutionContextSaver ctxSaver(scope); + ExecutionContextSaver ctxSaver(scope.engine); Scoped<CallContext> ctx(scope, newCallContext(function, callData)); if (f) @@ -254,7 +254,7 @@ ReturnedValue QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData { Q_ASSERT(function->canUseSimpleFunction()); - ExecutionContextSaver ctxSaver(scope); + ExecutionContextSaver ctxSaver(scope.engine); CallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 344c38ee79..f09772115c 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -360,14 +360,11 @@ ReturnedValue ScriptFunction::construct(const Managed *that, CallData *callData) CHECK_STACK_LIMITS(v4); Scope scope(v4); - ExecutionContextSaver ctxSaver(scope); - Scoped<ScriptFunction> f(scope, static_cast<const ScriptFunction *>(that)); InternalClass *ic = f->classForConstructor(); ScopedObject proto(scope, ic->prototype); - ScopedObject obj(scope, v4->newObject(ic, proto)); - callData->thisObject = obj.asReturnedValue(); + callData->thisObject = v4->newObject(ic, proto); QV4::Function *v4Function = f->function(); Q_ASSERT(v4Function); @@ -382,7 +379,7 @@ ReturnedValue ScriptFunction::construct(const Managed *that, CallData *callData) if (Q_UNLIKELY(v4->hasException)) return Encode::undefined(); else if (!result->isObject()) - return obj.asReturnedValue(); + return callData->thisObject.asReturnedValue(); return result->asReturnedValue(); } @@ -393,12 +390,11 @@ ReturnedValue ScriptFunction::call(const Managed *that, CallData *callData) return Encode::undefined(); CHECK_STACK_LIMITS(v4); - Scope scope(v4); - Scoped<ScriptFunction> f(scope, static_cast<const ScriptFunction *>(that)); - + const ScriptFunction *f = static_cast<const ScriptFunction *>(that); QV4::Function *v4Function = f->function(); Q_ASSERT(v4Function); + Scope scope(v4); ScopedContext c(scope, f->scope()); if (v4Function->canUseSimpleCall) return c->simpleCall(scope, callData, v4Function); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index dab6de572d..69d9683eaa 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -344,7 +344,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const ExecutionEngine *v4 = engine(); Scope scope(v4); - ExecutionContextSaver ctxSaver(scope); + ExecutionContextSaver ctxSaver(scope.engine); ExecutionContext *currentContext = v4->currentContext; ExecutionContext *ctx = currentContext; diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 7df723e9d0..f6cb6fda5d 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -401,19 +401,19 @@ struct ScopedProperty struct ExecutionContextSaver { - Scope scope; // this makes sure that a reference to context on the JS stack goes out of scope as soon as the context is not used anymore. + ExecutionEngine *engine; ExecutionContext *savedContext; - ExecutionContextSaver(const Scope &scope) - : scope(scope.engine) + ExecutionContextSaver(ExecutionEngine *engine) + : engine(engine) { - savedContext = scope.engine->currentContext; + savedContext = engine->currentContext; } ~ExecutionContextSaver() { - Q_ASSERT(scope.engine->jsStackTop > scope.engine->currentContext); - scope.engine->currentContext = savedContext; - scope.engine->current = savedContext->d(); + Q_ASSERT(engine->jsStackTop > engine->currentContext); + engine->currentContext = savedContext; + engine->current = savedContext->d(); } }; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 019fa54fb0..b771978def 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -148,7 +148,7 @@ ReturnedValue Script::run() if (qmlContext.isUndefined()) { TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction); - ExecutionContextSaver ctxSaver(valueScope); + ExecutionContextSaver ctxSaver(valueScope.engine); ContextStateSaver stateSaver(valueScope, scope); scope->d()->strictMode = vmFunction->isStrict(); scope->d()->v4Function = vmFunction; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index a736fb9f9d..3b15157ff5 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1210,7 +1210,7 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV if (engine->hasException) return; - QV4::ExecutionContextSaver saver(scope); + QV4::ExecutionContextSaver saver(scope.engine); engine->pushContext(qmlContext); while (1) { |