diff options
author | Lars Knoll <[email protected]> | 2014-11-28 09:31:10 +0100 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2014-12-19 16:30:19 +0100 |
commit | da2b7576daa58ad2881e41ad6f0f85ec55db4fd2 (patch) | |
tree | 1bb0dcfd7011f87aa1c238174205ce79c66273b6 | |
parent | 45f77a6bfc05b97e6312a379c63840243b5815f3 (diff) |
Return Heap::ExecutionContext for currentContext()
Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34
Reviewed-by: Simon Hausmann <[email protected]>
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4debugging.cpp | 44 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 26 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 22 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 95 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4typedarray.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 4 |
19 files changed, 160 insertions, 137 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 9e94cd8bd8..f40d37973a 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -670,8 +670,8 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) { #ifndef QT_NO_SETTINGS QV8Engine *engine = args->engine(); - QV4::ExecutionContext *ctx = args->v4engine()->currentContext(); - QV4::Scope scope(ctx); + QV4::Scope scope(args->v4engine()); + QV4::ScopedContext ctx(scope, args->v4engine()->currentContext()); if (engine->engine()->offlineStoragePath().isEmpty()) V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled.")); diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index d283537292..eaca874d76 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -119,10 +119,10 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con pd->value = mappedArguments()->data[index]; } - bool strict = engine->currentContext()->d()->strictMode; - engine->currentContext()->d()->strictMode = false; + bool strict = engine->currentContext()->strictMode; + engine->currentContext()->strictMode = false; bool result = Object::defineOwnProperty2(scope.engine, index, desc, attrs); - engine->currentContext()->d()->strictMode = strict; + engine->currentContext()->strictMode = strict; if (isMapped && attrs.isData()) { Q_ASSERT(arrayData()); @@ -138,7 +138,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con } } - if (engine->currentContext()->d()->strictMode && !result) + if (engine->currentContext()->strictMode && !result) return engine->throwTypeError(); return result; } diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 483d75011a..22815b8542 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -232,7 +232,7 @@ void Debugger::resume(Speed speed) if (!m_returnedValue.isUndefined()) m_returnedValue = Encode::undefined(); - m_currentContext = m_engine->currentContext()->d(); + m_currentContext = m_engine->currentContext(); m_stepping = speed; m_runningCondition.wakeAll(); } @@ -262,7 +262,7 @@ Debugger::ExecutionState Debugger::currentExecutionState() const { ExecutionState state; state.fileName = getFunction()->sourceFile(); - state.lineNumber = engine()->currentContext()->d()->lineNumber; + state.lineNumber = engine()->currentContext()->lineNumber; return state; } @@ -272,18 +272,18 @@ QVector<StackFrame> Debugger::stackTrace(int frameLimit) const return m_engine->stackTrace(frameLimit); } -static inline CallContext *findContext(ExecutionContext *ctxt, int frame) +static inline Heap::CallContext *findContext(Heap::ExecutionContext *ctxt, int frame) { if (!ctxt) return 0; - Scope scope(ctxt); + Scope scope(ctxt->engine); Scoped<ExecutionContext> ctx(scope, ctxt); while (ctx) { CallContext *cCtxt = ctx->asCallContext(); if (cCtxt && cCtxt->d()->function) { if (frame < 1) - return cCtxt; + return cCtxt->d(); --frame; } ctx = ctx->d()->parent; @@ -292,17 +292,17 @@ static inline CallContext *findContext(ExecutionContext *ctxt, int frame) return 0; } -static inline CallContext *findScope(ExecutionContext *ctxt, int scope) +static inline Heap::CallContext *findScope(Heap::ExecutionContext *ctxt, int scope) { if (!ctxt) return 0; - Scope s(ctxt); + Scope s(ctxt->engine); Scoped<ExecutionContext> ctx(s, ctxt); for (; scope > 0 && ctx; --scope) ctx = ctx->d()->outer; - return ctx ? ctx->asCallContext() : 0; + return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0; } void Debugger::collectArgumentsInContext(Collector *collector, int frameNr, int scopeNr) @@ -332,11 +332,11 @@ void Debugger::collectArgumentsInContext(Collector *collector, int frameNr, int if (frameNr < 0) return; - CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr); + Scope scope(engine); + Scoped<CallContext> ctxt(scope, findScope(findContext(engine->currentContext(), frameNr), scopeNr)); if (!ctxt) return; - Scope scope(engine); ScopedValue v(scope); int nFormals = ctxt->formalCount(); for (unsigned i = 0, ei = nFormals; i != ei; ++i) { @@ -379,11 +379,11 @@ void Debugger::collectLocalsInContext(Collector *collector, int frameNr, int sco if (frameNr < 0) return; - CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr); + Scope scope(engine); + Scoped<CallContext> ctxt(scope, findScope(findContext(engine->currentContext(), frameNr), scopeNr)); if (!ctxt) return; - Scope scope(engine); ScopedValue v(scope); for (unsigned i = 0, ei = ctxt->variableCount(); i != ei; ++i) { QString qName; @@ -495,13 +495,12 @@ QVector<Heap::ExecutionContext::ContextType> Debugger::getScopeTypes(int frame) if (state() != Paused) return types; - CallContext *sctxt = findContext(m_engine->currentContext(), frame); + Scope scope(m_engine); + Scoped<CallContext> sctxt(scope, findContext(m_engine->currentContext(), frame)); if (!sctxt || sctxt->d()->type < Heap::ExecutionContext::Type_SimpleCallContext) return types; - CallContext *ctxt = static_cast<CallContext *>(sctxt); - Scope scope(m_engine); - Scoped<ExecutionContext> it(scope, ctxt); + Scoped<ExecutionContext> it(scope, sctxt->d()); for (; it; it = it->d()->outer) types.append(it->d()->type); @@ -524,7 +523,7 @@ void Debugger::maybeBreakAtInstruction() return; QMutexLocker locker(&m_lock); - int lineNumber = engine()->currentContext()->d()->lineNumber; + int lineNumber = engine()->currentContext()->lineNumber; if (m_gatherSources) { m_gatherSources->run(); @@ -534,7 +533,7 @@ void Debugger::maybeBreakAtInstruction() switch (m_stepping) { case StepOver: - if (m_currentContext.asManaged()->d() != m_engine->currentContext()->d()) + if (m_currentContext.asManaged()->d() != m_engine->currentContext()) break; // fall through case StepIn: @@ -560,7 +559,7 @@ void Debugger::enteringFunction() QMutexLocker locker(&m_lock); if (m_stepping == StepIn) { - m_currentContext = m_engine->currentContext()->d(); + m_currentContext = m_engine->currentContext(); } } @@ -573,8 +572,8 @@ void Debugger::leavingFunction(const ReturnedValue &retVal) QMutexLocker locker(&m_lock); Scope scope(m_engine); - if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->currentContext()->d()) { - m_currentContext = m_engine->currentContext()->d()->parent; + if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->currentContext()) { + m_currentContext = m_engine->currentContext()->parent; m_stepping = StepOver; m_returnedValue = retVal; } @@ -594,7 +593,8 @@ void Debugger::aboutToThrow() Function *Debugger::getFunction() const { - ExecutionContext *context = m_engine->currentContext(); + Scope scope(m_engine); + ScopedContext context(scope, m_engine->currentContext()); if (CallContext *callCtx = context->asCallContext()) return callCtx->d()->function->function; else { diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 47e7236c5b..fdcda17c29 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -519,7 +519,7 @@ ExecutionContext *ExecutionEngine::pushGlobalContext() Scoped<GlobalContext> g(scope, memoryManager->alloc<GlobalContext>(this)); g->d()->callData = rootContext()->d()->callData; - Q_ASSERT(currentContext() == g.getPointer()); + Q_ASSERT(currentContext() == g->d()); return g.getPointer(); } @@ -716,7 +716,7 @@ Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o) Heap::Object *ExecutionEngine::qmlContextObject() const { - Heap::ExecutionContext *ctx = currentContext()->d(); + Heap::ExecutionContext *ctx = currentContext(); if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer) ctx = ctx->parent; @@ -737,7 +737,7 @@ Heap::Object *ExecutionEngine::qmlContextObject() const QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const { - Scope scope(this->currentContext()); + Scope scope(const_cast<ExecutionEngine *>(this)); ScopedString name(scope); QVector<StackFrame> stack; @@ -890,7 +890,7 @@ void ExecutionEngine::markObjects() setter->mark(this); } - Heap::ExecutionContext *c = currentContext()->d(); + Heap::ExecutionContext *c = currentContext(); while (c) { Q_ASSERT(c->inUse); if (!c->markBit) { diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 813b5fce5b..bb5d1c543b 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -73,8 +73,8 @@ private: friend struct ExecutionContext; friend struct Heap::ExecutionContext; public: - ExecutionContext *current; - ExecutionContext *currentContext() const { return current; } + Heap::ExecutionContext *current; + Heap::ExecutionContext *currentContext() const { return current; } Value *jsStackTop; quint32 hasException; @@ -272,7 +272,7 @@ public: ExecutionContext *pushGlobalContext(); void pushContext(CallContext *context); - ExecutionContext *popContext(); + Heap::ExecutionContext *popContext(); Heap::Object *newObject(); Heap::Object *newObject(InternalClass *internalClass, Object *prototype); @@ -354,17 +354,16 @@ private: inline void ExecutionEngine::pushContext(CallContext *context) { - Q_ASSERT(current && current->d() && context && context->d()); - context->d()->parent = current->d(); - current = context; + Q_ASSERT(current && context && context->d()); + context->d()->parent = current; + current = context->d(); } -inline ExecutionContext *ExecutionEngine::popContext() +inline Heap::ExecutionContext *ExecutionEngine::popContext() { - Q_ASSERT(current->d()->parent); - // ### GC - current = reinterpret_cast<ExecutionContext *>(current->d()->parent); - Q_ASSERT(current && current->d()); + Q_ASSERT(current->parent); + current = current->parent; + Q_ASSERT(current); return current; } @@ -374,14 +373,13 @@ Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t) , type(t) , strictMode(false) , engine(engine) - , parent(engine->currentContext()->d()) + , parent(engine->currentContext()) , outer(0) , lookups(0) , compilationUnit(0) , lineNumber(-1) { - // ### GC - engine->current = reinterpret_cast<QV4::ExecutionContext *>(this); + engine->current = this; } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 437de33b3f..c3d7a65a32 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -216,7 +216,8 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) { FunctionCtor *f = static_cast<FunctionCtor *>(that); ExecutionEngine *v4 = f->internalClass()->engine; - ExecutionContext *ctx = v4->currentContext(); + Scope scope(v4); + ScopedContext ctx(scope, v4->currentContext()); QString arguments; QString body; if (callData->argc > 0) { @@ -397,7 +398,7 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) ScopedObject proto(scope, f->protoForConstructor()); ScopedObject obj(scope, v4->newObject(ic, proto)); - ExecutionContext *context = v4->currentContext(); + ScopedContext context(scope, v4->currentContext()); callData->thisObject = obj.asReturnedValue(); Scoped<CallContext> ctx(scope, context->newCallContext(f.getPointer(), callData)); @@ -423,8 +424,8 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) return Encode::undefined(); CHECK_STACK_LIMITS(v4); - ExecutionContext *context = v4->currentContext(); - Scope scope(context); + Scope scope(v4); + ScopedContext context(scope, v4->currentContext()); Scoped<CallContext> ctx(scope, context->newCallContext(f, callData)); @@ -482,8 +483,7 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) ScopedObject proto(scope, f->protoForConstructor()); callData->thisObject = v4->newObject(ic, proto); - ExecutionContext *context = v4->currentContext(); - ExecutionContextSaver ctxSaver(scope, context); + ExecutionContextSaver ctxSaver(scope, v4->currentContext()); CallContext::Data ctx(v4); ctx.strictMode = f->strictMode(); @@ -497,7 +497,7 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) callData->args[callData->argc] = Encode::undefined(); ++callData->argc; } - Q_ASSERT(v4->currentContext()->d() == &ctx); + Q_ASSERT(v4->currentContext() == &ctx); Scoped<Object> result(scope, Q_V4_PROFILE(v4, f->function())); @@ -519,8 +519,7 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that); Scope scope(v4); - ExecutionContext *context = v4->currentContext(); - ExecutionContextSaver ctxSaver(scope, context); + ExecutionContextSaver ctxSaver(scope, v4->currentContext()); CallContext::Data ctx(v4); ctx.strictMode = f->strictMode(); @@ -534,7 +533,7 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) callData->args[callData->argc] = Encode::undefined(); ++callData->argc; } - Q_ASSERT(v4->currentContext()->d() == &ctx); + Q_ASSERT(v4->currentContext() == &ctx); ScopedValue result(scope, Q_V4_PROFILE(v4, f->function())); @@ -578,13 +577,12 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) CHECK_STACK_LIMITS(v4); Scope scope(v4); - ExecutionContext *context = v4->currentContext(); - ExecutionContextSaver ctxSaver(scope, context); + ExecutionContextSaver ctxSaver(scope, v4->currentContext()); CallContext::Data ctx(v4); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; - Q_ASSERT(v4->currentContext()->d() == &ctx); + Q_ASSERT(v4->currentContext() == &ctx); return f->d()->code(reinterpret_cast<CallContext *>(&ctx)); } @@ -598,13 +596,12 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) CHECK_STACK_LIMITS(v4); Scope scope(v4); - ExecutionContext *context = v4->currentContext(); - ExecutionContextSaver ctxSaver(scope, context); + ExecutionContextSaver ctxSaver(scope, v4->currentContext()); CallContext::Data ctx(v4); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; - Q_ASSERT(v4->currentContext()->d() == &ctx); + Q_ASSERT(v4->currentContext() == &ctx); return f->d()->code(reinterpret_cast<CallContext *>(&ctx), f->d()->index); } diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index eb243f6e86..3424e9d980 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -355,7 +355,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ExecutionEngine *v4 = engine(); Scope scope(v4); - ExecutionContext *parentContext = v4->currentContext(); + ScopedContext parentContext(scope, v4->currentContext()); ExecutionContextSaver ctxSaver(scope, parentContext); ExecutionContext *ctx = parentContext; diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index c4a8ac13b9..8bcb2e4708 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -956,7 +956,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValue &value) { if (value.isString()) - return engine->currentContext()->d()->engine->newString(value.toString())->asReturnedValue(); + return engine->currentContext()->engine->newString(value.toString())->asReturnedValue(); else if (value.isDouble()) return Encode(value.toDouble()); else if (value.isBool()) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 62d4eea21c..9febcaab69 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -42,7 +42,7 @@ using namespace QV4; ReturnedValue Lookup::lookup(ValueRef thisObject, Object *o, PropertyAttributes *attrs) { ExecutionEngine *engine = o->engine(); - Identifier *name = engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]->identifier; + Identifier *name = engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]->identifier; int i = 0; Heap::Object *obj = o->d(); while (i < Size && obj) { @@ -76,7 +76,7 @@ ReturnedValue Lookup::lookup(Object *thisObject, PropertyAttributes *attrs) { Heap::Object *obj = thisObject->d(); ExecutionEngine *engine = thisObject->engine(); - Identifier *name = engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]->identifier; + Identifier *name = engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]->identifier; int i = 0; while (i < Size && obj) { classList[i] = obj->internalClass; @@ -250,7 +250,7 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va Q_ASSERT(object->isString()); proto = engine->stringPrototype.asObject(); Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); if (name->equals(engine->id_length.getPointer())) { // special case, as the property is on the object itself l->getter = stringLengthGetter; @@ -328,7 +328,7 @@ ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const V QV4::ScopedObject o(scope, object->toObject(scope.engine)); if (!o) return Encode::undefined(); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); return o->get(name); } @@ -602,7 +602,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionEngine *engine) } } Scope scope(engine); - Scoped<String> n(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + Scoped<String> n(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); return engine->throwReferenceError(n); } @@ -709,7 +709,7 @@ void Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, const ValueRef ob o = RuntimeHelpers::convertToObject(scope.engine, object); if (!o) // type error return; - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); o->put(name, value); return; } @@ -740,7 +740,7 @@ void Lookup::setterFallback(Lookup *l, ExecutionEngine *engine, const ValueRef o QV4::Scope scope(engine); QV4::ScopedObject o(scope, object->toObject(scope.engine)); if (o) { - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); o->put(name, value); } } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index fea809745f..9d077cf59c 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -118,7 +118,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val return; reject: - if (engine()->currentContext()->d()->strictMode) + if (engine()->currentContext()->strictMode) engine()->throwTypeError(); } @@ -465,7 +465,7 @@ void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) { Scope scope(m->engine()); ScopedObject o(scope, static_cast<Object *>(m)); - ScopedString name(scope, scope.engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); InternalClass *c = o->internalClass(); uint idx = c->find(name); @@ -722,7 +722,7 @@ void Object::internalPut(String *name, const ValueRef value) return; reject: - if (engine()->currentContext()->d()->strictMode) { + if (engine()->currentContext()->strictMode) { QString message = QStringLiteral("Cannot assign to read-only property \""); message += name->toQString(); message += QLatin1Char('\"'); @@ -795,7 +795,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value) return; reject: - if (engine()->currentContext()->d()->strictMode) + if (engine()->currentContext()->strictMode) engine()->throwTypeError(); } @@ -817,7 +817,7 @@ bool Object::internalDeleteProperty(String *name) InternalClass::removeMember(this, name->identifier()); return true; } - if (engine()->currentContext()->d()->strictMode) + if (engine()->currentContext()->strictMode) engine()->throwTypeError(); return false; } @@ -835,7 +835,7 @@ bool Object::internalDeleteIndexedProperty(uint index) if (!ad || ad->vtable()->del(this, index)) return true; - if (engine()->currentContext()->d()->strictMode) + if (engine()->currentContext()->strictMode) engine()->throwTypeError(); return false; } @@ -901,7 +901,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const return __defineOwnProperty__(engine, memberIndex, name, p, attrs); reject: - if (engine->currentContext()->d()->strictMode) + if (engine->currentContext()->strictMode) engine->throwTypeError(); return false; } @@ -917,7 +917,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, const Pr return defineOwnProperty2(engine, index, p, attrs); reject: - if (engine->currentContext()->d()->strictMode) + if (engine->currentContext()->strictMode) engine->throwTypeError(); return false; } @@ -953,7 +953,7 @@ bool Object::defineOwnProperty2(ExecutionEngine *engine, uint index, const Prope return __defineOwnProperty__(engine, index, 0, p, attrs); reject: - if (engine->currentContext()->d()->strictMode) + if (engine->currentContext()->strictMode) engine->throwTypeError(); return false; } @@ -1046,7 +1046,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String * setHasAccessorProperty(); return true; reject: - if (engine->currentContext()->d()->strictMode) + if (engine->currentContext()->strictMode) engine->throwTypeError(); return false; } @@ -1165,7 +1165,7 @@ Heap::ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) ReturnedValue ArrayObject::getLookup(Managed *m, Lookup *l) { Scope scope(m->engine()); - ScopedString name(scope, m->engine()->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, m->engine()->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); if (name->equals(m->engine()->id_length)) { // special case, as the property is on the object itself l->getter = Lookup::arrayLengthGetter; diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index bc0e3c4649..fc57daa123 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -323,7 +323,8 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String if (hasProperty) *hasProperty = true; - return getProperty(d()->object, scope.engine->currentContext(), result); + ScopedContext ctx(scope, scope.engine->currentContext()); + return getProperty(d()->object, ctx, result); } ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, bool captureRequired) @@ -436,7 +437,9 @@ bool QObjectWrapper::setQmlProperty(ExecutionEngine *engine, QQmlContextData *qm return false; } - setProperty(object, engine->currentContext(), result, value); + Scope scope(engine); + ScopedContext ctx(scope, engine->currentContext()); + setProperty(object, ctx, result, value); return true; } @@ -1825,7 +1828,8 @@ ReturnedValue QObjectMethod::call(Managed *m, CallData *callData) ReturnedValue QObjectMethod::callInternal(CallData *callData) { - ExecutionContext *context = engine()->currentContext(); + Scope scope(engine()); + ScopedContext context(scope, scope.engine->currentContext()); if (d()->index == DestroyMethod) return method_destroy(context, callData->args, callData->argc); else if (d()->index == ToStringMethod) @@ -1836,8 +1840,6 @@ ReturnedValue QObjectMethod::callInternal(CallData *callData) return Encode::undefined(); QV8Engine *v8Engine = context->d()->engine->v8Engine; - QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine); - QV4::Scope scope(v4); QQmlPropertyData method; diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index ff78cf3e13..6a1d86522d 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -246,8 +246,8 @@ void Heap::RegExpCtor::clearLastMatch() ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) { - ExecutionContext *ctx = m->engine()->currentContext(); - Scope scope(ctx); + Scope scope(m->engine()); + ScopedContext ctx(scope, scope.engine->currentContext()); ScopedValue r(scope, callData->argument(0)); ScopedValue f(scope, callData->argument(1)); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index a4340a3fab..8044161b81 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -266,9 +266,10 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) ReturnedValue Runtime::closure(ExecutionEngine *engine, int functionId) { - QV4::Function *clos = engine->currentContext()->d()->compilationUnit->runtimeFunctions[functionId]; + QV4::Function *clos = engine->currentContext()->compilationUnit->runtimeFunctions[functionId]; Q_ASSERT(clos); - return FunctionObject::createScriptFunction(engine->currentContext(), clos)->asReturnedValue(); + Scope scope(engine); + return FunctionObject::createScriptFunction(ScopedContext(scope, engine->currentContext()), clos)->asReturnedValue(); } ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index) @@ -289,7 +290,7 @@ ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const ValueRef bas ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const ValueRef base, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); return deleteMemberString(engine, base, name); } @@ -305,8 +306,9 @@ ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const ValueRe ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - return Encode(engine->currentContext()->deleteProperty(name)); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + return Encode(ctx->deleteProperty(name)); } QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right) @@ -559,7 +561,7 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const QV4::ValueR void Runtime::setProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex, const ValueRef value) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); ScopedObject o(scope, object->toObject(engine)); if (!o) return; @@ -656,14 +658,15 @@ ReturnedValue Runtime::foreachNextPropertyName(const ValueRef foreach_iterator) void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const ValueRef value) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - engine->currentContext()->setProperty(name, value); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + ctx->setProperty(name, value); } ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); Scoped<Object> o(scope, object); if (o) @@ -683,8 +686,9 @@ ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const ValueRef objec ReturnedValue Runtime::getActivationProperty(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - return engine->currentContext()->getProperty(name); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + return ctx->getProperty(name); } #endif // V4_BOOTSTRAP @@ -900,12 +904,12 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, Cal Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); - Lookup *l = engine->currentContext()->d()->lookups + index; + Lookup *l = engine->currentContext()->lookups + index; Scoped<FunctionObject> o(scope, l->globalGetter(l, engine)); if (!o) return engine->throwTypeError(); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); if (o.getPointer() == scope.engine->evalFunction && name->equals(scope.engine->id_eval)) return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true); @@ -917,11 +921,12 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI { Q_ASSERT(callData->thisObject.isUndefined()); Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); ScopedObject base(scope); Object *baseObj = 0; - ScopedValue func(scope, engine->currentContext()->getPropertyAndBase(name, baseObj)); + ScopedContext ctx(scope, engine->currentContext()); + ScopedValue func(scope, ctx->getPropertyAndBase(name, baseObj)); base.ptr->m = baseObj ? &baseObj->data : 0; if (scope.engine->hasException) return Encode::undefined(); @@ -948,7 +953,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); Scoped<Object> baseObject(scope, callData->thisObject); if (!baseObject) { Q_ASSERT(!callData->thisObject.isEmpty()); @@ -974,7 +979,7 @@ ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, Call ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { - Lookup *l = engine->currentContext()->d()->lookups + index; + Lookup *l = engine->currentContext()->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); if (!v.isObject()) @@ -1014,7 +1019,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); - Lookup *l = engine->currentContext()->d()->lookups + index; + Lookup *l = engine->currentContext()->lookups + index; Scoped<Object> f(scope, l->globalGetter(l, engine)); if (!f) return engine->throwTypeError(); @@ -1026,8 +1031,9 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - ScopedValue func(scope, engine->currentContext()->getProperty(name)); + ScopedContext ctx(scope, engine->currentContext()); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedValue func(scope, ctx->getProperty(name)); if (scope.engine->hasException) return Encode::undefined(); @@ -1051,7 +1057,7 @@ ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, { Scope scope(engine); ScopedObject thisObject(scope, callData->thisObject.toObject(engine)); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); if (scope.engine->hasException) return Encode::undefined(); @@ -1064,7 +1070,7 @@ ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { - Lookup *l = engine->currentContext()->d()->lookups + index; + Lookup *l = engine->currentContext()->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); if (!v.isObject()) @@ -1112,8 +1118,9 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const ValueRef value QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - ScopedValue prop(scope, engine->currentContext()->getProperty(name)); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + ScopedValue prop(scope, ctx->getProperty(name)); // typeof doesn't throw. clear any possible exception scope.engine->hasException = false; return Runtime::typeofValue(engine, prop); @@ -1122,7 +1129,7 @@ QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex) QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const ValueRef base, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); ScopedObject obj(scope, base->toObject(engine)); if (scope.engine->hasException) return Encode::undefined(); @@ -1145,7 +1152,8 @@ void Runtime::pushWithScope(const ValueRef o, ExecutionEngine *engine) { Scope scope(engine); ScopedObject obj(scope, o->toObject(engine)); - engine->currentContext()->newWithContext(obj); + ScopedContext ctx(scope, engine->currentContext()); + ctx->newWithContext(obj); } ReturnedValue Runtime::unwindException(ExecutionEngine *engine) @@ -1159,8 +1167,9 @@ void Runtime::pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex) { Scope scope(engine); ScopedValue v(scope, engine->catchException(0)); - ScopedString exceptionVarName(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex]); - engine->currentContext()->newCatchContext(exceptionVarName, v); + ScopedString exceptionVarName(scope, engine->currentContext()->compilationUnit->runtimeStrings[exceptionVarNameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + ctx->newCatchContext(exceptionVarName, v); } void Runtime::popScope(ExecutionEngine *engine) @@ -1171,8 +1180,9 @@ void Runtime::popScope(ExecutionEngine *engine) void Runtime::declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); - engine->currentContext()->createMutableBinding(name, deletable); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); + ScopedContext ctx(scope, engine->currentContext()); + ctx->createMutableBinding(name, deletable); } ReturnedValue Runtime::arrayLiteral(ExecutionEngine *engine, Value *values, uint length) @@ -1191,7 +1201,7 @@ ReturnedValue Runtime::arrayLiteral(ExecutionEngine *engine, Value *values, uint ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) { Scope scope(engine); - QV4::InternalClass *klass = engine->currentContext()->d()->compilationUnit->runtimeClasses[classId]; + QV4::InternalClass *klass = engine->currentContext()->compilationUnit->runtimeClasses[classId]; Scoped<Object> o(scope, engine->newObject(klass, engine->objectPrototype.asObject())); { @@ -1232,8 +1242,9 @@ ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value * QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) { - Q_ASSERT(engine->currentContext()->d()->type >= Heap::ExecutionContext::Type_CallContext); - CallContext *c = static_cast<CallContext *>(engine->currentContext()); + Q_ASSERT(engine->currentContext()->type >= Heap::ExecutionContext::Type_CallContext); + Scope scope(engine); + Scoped<CallContext> c(scope, static_cast<Heap::CallContext *>(engine->currentContext())); return (engine->memoryManager->alloc<ArgumentsObject>(c))->asReturnedValue(); } @@ -1320,7 +1331,7 @@ unsigned Runtime::doubleToUInt(const double &d) ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id) { - return engine->currentContext()->d()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); + return engine->currentContext()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); } ReturnedValue Runtime::getQmlIdArray(NoThrowEngine *engine) @@ -1354,7 +1365,8 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Valu engine->throwTypeError(QStringLiteral("Cannot read property of null")); return Encode::undefined(); } - return QV4::QObjectWrapper::getProperty(wrapper->object(), engine->currentContext(), propertyIndex, captureRequired); + ScopedContext ctx(scope, engine->currentContext()); + return QV4::QObjectWrapper::getProperty(wrapper->object(), ctx, propertyIndex, captureRequired); } QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex) @@ -1366,7 +1378,8 @@ QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int QQmlEngine *qmlEngine = engine->v8Engine->engine(); QQmlData::ensurePropertyCache(qmlEngine, attachedObject); - return QV4::QObjectWrapper::getProperty(attachedObject, engine->currentContext(), propertyIndex, /*captureRequired*/true); + ScopedContext ctx(scope, engine->currentContext()); + return QV4::QObjectWrapper::getProperty(attachedObject, ctx, propertyIndex, /*captureRequired*/true); } ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired) @@ -1377,7 +1390,8 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, c scope.engine->throwTypeError(QStringLiteral("Cannot read property of null")); return Encode::undefined(); } - return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), engine->currentContext(), propertyIndex, captureRequired); + ScopedContext ctx(scope, engine->currentContext()); + return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), ctx, propertyIndex, captureRequired); } void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, const ValueRef value) @@ -1388,7 +1402,8 @@ void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const ValueRef obje engine->throwTypeError(QStringLiteral("Cannot write property of null")); return; } - wrapper->setProperty(engine->currentContext(), propertyIndex, value); + ScopedContext ctx(scope, engine->currentContext()); + wrapper->setProperty(ctx, propertyIndex, value); } ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) @@ -1402,14 +1417,14 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex) { Scope scope(engine); - ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]); + ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]); Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject()); return wrapper->qmlSingletonWrapper(engine->v8Engine, name); } void Runtime::convertThisToObject(ExecutionEngine *engine) { - Value *t = &engine->currentContext()->d()->callData->thisObject; + Value *t = &engine->currentContext()->callData->thisObject; if (t->isObject()) return; if (t->isNullOrUndefined()) { diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 6805fc80be..9a76ffcaa4 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -516,9 +516,18 @@ struct ExecutionContextSaver savedContext->tag = QV4::Value::Managed_Type; #endif } + ExecutionContextSaver(Scope &scope, Heap::ExecutionContext *context) + : engine(context->engine) + , savedContext(scope.alloc(1)) + { + savedContext->m = context; +#if QT_POINTER_SIZE == 4 + savedContext->tag = QV4::Value::Managed_Type; +#endif + } ~ExecutionContextSaver() { - engine->current = static_cast<ExecutionContext *>(savedContext->asManaged()); + engine->current = static_cast<Heap::ExecutionContext *>(savedContext->heapObject()); } }; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 203ef04240..0d41e52e3e 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -104,7 +104,8 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Functio o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); - o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml); + ScopedContext ctx(s, s.engine->currentContext()); + o->d()->qmlContext = ctx->newQmlContext(o, qml); s.engine->popContext(); } @@ -122,7 +123,8 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Ob o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); - o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml); + ScopedContext ctx(s, s.engine->currentContext()); + o->d()->qmlContext = ctx->newQmlContext(o, qml); s.engine->popContext(); } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 6d555d505d..dec361a09c 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -115,7 +115,7 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index) } if (index < static_cast<uint>(o->d()->value.stringValue()->toQString().length())) { - if (v4->currentContext()->d()->strictMode) + if (v4->currentContext()->strictMode) v4->throwTypeError(); return false; } diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index cc5ea2aad5..088c5e1bf8 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -379,7 +379,7 @@ void TypedArray::putIndexed(Managed *m, uint index, const ValueRef value) return; reject: - if (scope.engine->currentContext()->d()->strictMode) + if (scope.engine->currentContext()->strictMode) scope.engine->throwTypeError(); } diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 0ce141cde8..a5c1f67532 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -290,7 +290,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) if (wrapper && wrapper->d()->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - Scoped<String> e(scope, v4->currentContext()->d()->engine->newString(error)); + Scoped<String> e(scope, v4->currentContext()->engine->newString(error)); v4->throwError(e); return; } diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 80ef41acca..1002f8c888 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -364,7 +364,7 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant) case QMetaType::Double: return QV4::Encode(*reinterpret_cast<const double*>(ptr)); case QMetaType::QString: - return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue(); + return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue(); case QMetaType::Float: return QV4::Encode(*reinterpret_cast<const float*>(ptr)); case QMetaType::Short: @@ -657,7 +657,7 @@ QV4::ReturnedValue QV8Engine::metaTypeToJS(int type, const void *data) case QMetaType::Double: return QV4::Encode(*reinterpret_cast<const double*>(data)); case QMetaType::QString: - return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue(); + return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue(); case QMetaType::Float: return QV4::Encode(*reinterpret_cast<const float*>(data)); case QMetaType::Short: |