From 84aae25c0b3003fb846568cf26a2c7150db14d9d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 1 Nov 2014 23:24:13 +0100 Subject: Refactor ExecutionContexts Move the Data class out into the Heap namespace. Change-Id: I2b798deb53812a08155c92a0e6ef2dcd2ea137b8 Reviewed-by: Simon Hausmann --- src/qml/debugger/qv4debugservice.cpp | 18 ++-- src/qml/jit/qv4assembler.cpp | 4 +- src/qml/jit/qv4assembler_p.h | 6 +- src/qml/jsruntime/qv4context.cpp | 70 ++++++++-------- src/qml/jsruntime/qv4context_p.h | 151 ++++++++++++++++++---------------- src/qml/jsruntime/qv4debugging.cpp | 8 +- src/qml/jsruntime/qv4debugging_p.h | 2 +- src/qml/jsruntime/qv4engine.cpp | 6 +- src/qml/jsruntime/qv4engine_p.h | 1 + src/qml/jsruntime/qv4global_p.h | 3 + src/qml/jsruntime/qv4globalobject.cpp | 2 +- src/qml/jsruntime/qv4managed_p.h | 7 +- src/qml/jsruntime/qv4runtime.cpp | 2 +- src/qml/jsruntime/qv4vme_moth.cpp | 2 +- 14 files changed, 150 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/qml/debugger/qv4debugservice.cpp b/src/qml/debugger/qv4debugservice.cpp index b0cac272aa..30d9557383 100644 --- a/src/qml/debugger/qv4debugservice.cpp +++ b/src/qml/debugger/qv4debugservice.cpp @@ -422,7 +422,7 @@ public: QJsonArray scopes; // Only type and index are used by Qt Creator, so we keep it easy: - QVector scopeTypes = debugger->getScopeTypes(frameNr); + QVector scopeTypes = debugger->getScopeTypes(frameNr); for (int i = 0, ei = scopeTypes.count(); i != ei; ++i) { int type = encodeScopeType(scopeTypes[i]); if (type == -1) @@ -438,23 +438,23 @@ public: return frame; } - int encodeScopeType(QV4::ExecutionContext::ContextType scopeType) + int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType) { switch (scopeType) { - case QV4::ExecutionContext::Type_GlobalContext: + case QV4::Heap::ExecutionContext::Type_GlobalContext: return 0; break; - case QV4::ExecutionContext::Type_CatchContext: + case QV4::Heap::ExecutionContext::Type_CatchContext: return 4; break; - case QV4::ExecutionContext::Type_WithContext: + case QV4::Heap::ExecutionContext::Type_WithContext: return 2; break; - case QV4::ExecutionContext::Type_SimpleCallContext: - case QV4::ExecutionContext::Type_CallContext: + case QV4::Heap::ExecutionContext::Type_SimpleCallContext: + case QV4::Heap::ExecutionContext::Type_CallContext: return 1; break; - case QV4::ExecutionContext::Type_QmlContext: + case QV4::Heap::ExecutionContext::Type_QmlContext: default: return -1; } @@ -470,7 +470,7 @@ public: QJsonObject anonymous; anonymous[QLatin1String("properties")] = properties; - QVector scopeTypes = debugger->getScopeTypes(frameNr); + QVector scopeTypes = debugger->getScopeTypes(frameNr); scope[QLatin1String("type")] = encodeScopeType(scopeTypes[scopeNr]); scope[QLatin1String("index")] = scopeNr; scope[QLatin1String("frameIndex")] = frameNr; diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp index 300f4b0fb2..6e864efa38 100644 --- a/src/qml/jit/qv4assembler.cpp +++ b/src/qml/jit/qv4assembler.cpp @@ -211,7 +211,7 @@ Assembler::Pointer Assembler::loadArgLocalAddress(RegisterID baseReg, IR::ArgLoc Assembler::Pointer Assembler::loadStringAddress(RegisterID reg, const QString &string) { - loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), Assembler::ScratchRegister); + loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::Heap::ExecutionContext, compilationUnit)), Assembler::ScratchRegister); loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg); const int id = _isel->registerString(string); return Pointer(reg, id * sizeof(QV4::String*)); @@ -219,7 +219,7 @@ Assembler::Pointer Assembler::loadStringAddress(RegisterID reg, const QString &s void Assembler::loadStringRef(RegisterID reg, const QString &string) { - loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), reg); + loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::Heap::ExecutionContext, compilationUnit)), reg); loadPtr(Address(reg, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg); const int id = _isel->registerString(string); loadPtr(Address(reg, id * sizeof(QV4::String*)), reg); diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h index 87875f1120..1de7da37b4 100644 --- a/src/qml/jit/qv4assembler_p.h +++ b/src/qml/jit/qv4assembler_p.h @@ -797,7 +797,7 @@ public: const RegisterInformation &fpRegistersToSave); void checkException() { - loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, engine)), ScratchRegister); + loadPtr(Address(ContextRegister, qOffsetOf(QV4::Heap::ExecutionContext, engine)), ScratchRegister); load32(Address(ScratchRegister, qOffsetOf(QV4::ExecutionEngine, hasException)), ScratchRegister); Jump exceptionThrown = branch32(NotEqual, ScratchRegister, TrustedImm32(0)); if (catchBlock) @@ -1226,7 +1226,7 @@ template inline bool prepareCall(T &, Assembler *) template <> inline bool prepareCall(RelativeCall &relativeCall, Assembler *as) { - as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lookups)), + as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::Heap::ExecutionContext, lookups)), relativeCall.addr.base); return true; } @@ -1236,7 +1236,7 @@ template <> inline bool prepareCall(LookupCall &lookupCall, Assembler *as) // IMPORTANT! See generateLookupCall in qv4isel_masm_p.h for details! // same as prepareCall(RelativeCall ....) : load the table from the context - as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lookups)), + as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::Heap::ExecutionContext, lookups)), lookupCall.addr.base); // pre-calculate the indirect address for the lookupCall table: if (lookupCall.addr.offset) diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 2863068d41..72bf041d84 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -52,8 +52,8 @@ Returned *ExecutionContext::newCallContext(FunctionObject *function { Q_ASSERT(function->function()); - CallContext::Data *c = reinterpret_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc))); - new (c) CallContext::Data(d()->engine, Type_CallContext); + Heap::CallContext *c = reinterpret_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc))); + new (c) Heap::CallContext(d()->engine, Heap::ExecutionContext::Type_CallContext); c->function = function; c->realArgumentCount = callData->argc; @@ -95,7 +95,7 @@ Returned *ExecutionContext::newQmlContext(FunctionObject *f, Object { Scope scope(this); Scoped c(scope, static_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0)))); - new (c->d()) CallContext::Data(d()->engine, qml, f); + new (c->d()) Heap::CallContext(d()->engine, qml, f); return c.asReturned(); } @@ -109,7 +109,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) ScopedObject activation(scope, d()->engine->globalObject); ExecutionContext *ctx = this; while (ctx) { - if (ctx->d()->type >= Type_CallContext) { + if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { CallContext *c = static_cast(ctx); if (!c->d()->activation) c->d()->activation = d()->engine->newObject()->getPointer(); @@ -128,14 +128,14 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) } -GlobalContext::Data::Data(ExecutionEngine *eng) - : ExecutionContext::Data(eng, Type_GlobalContext) +Heap::GlobalContext::GlobalContext(ExecutionEngine *eng) + : Heap::ExecutionContext(eng, Heap::ExecutionContext::Type_GlobalContext) { global = eng->globalObject; } -WithContext::Data::Data(ExecutionEngine *engine, Object *with) - : ExecutionContext::Data(engine, Type_WithContext) +Heap::WithContext::WithContext(ExecutionEngine *engine, Object *with) + : Heap::ExecutionContext(engine, Heap::ExecutionContext::Type_WithContext) { callData = parent->d()->callData; outer = parent; @@ -145,8 +145,8 @@ WithContext::Data::Data(ExecutionEngine *engine, Object *with) withObject = with; } -CatchContext::Data::Data(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue) - : ExecutionContext::Data(engine, Type_CatchContext) +Heap::CatchContext::CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue) + : Heap::ExecutionContext(engine, Heap::ExecutionContext::Type_CatchContext) { strictMode = parent->d()->strictMode; callData = parent->d()->callData; @@ -158,8 +158,8 @@ CatchContext::Data::Data(ExecutionEngine *engine, String *exceptionVarName, cons this->exceptionValue = exceptionValue; } -CallContext::Data::Data(ExecutionEngine *engine, Object *qml, FunctionObject *function) - : ExecutionContext::Data(engine, Type_QmlContext) +Heap::CallContext::CallContext(ExecutionEngine *engine, Object *qml, FunctionObject *function) + : Heap::ExecutionContext(engine, Heap::ExecutionContext::Type_QmlContext) { this->function = function; callData = reinterpret_cast(this + 1); @@ -209,16 +209,16 @@ bool ExecutionContext::deleteProperty(String *name) Scope scope(this); bool hasWith = false; for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { - if (ctx->d()->type == Type_WithContext) { + if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { hasWith = true; WithContext *w = static_cast(ctx); if (w->d()->withObject->hasProperty(name)) return w->d()->withObject->deleteProperty(name); - } else if (ctx->d()->type == Type_CatchContext) { + } else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext) { CatchContext *c = static_cast(ctx); if (c->d()->exceptionVarName->isEqualTo(name)) return false; - } else if (ctx->d()->type >= Type_CallContext) { + } else if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { CallContext *c = static_cast(ctx); FunctionObject *f = c->d()->function; if (f->needsActivation() || hasWith) { @@ -229,7 +229,7 @@ bool ExecutionContext::deleteProperty(String *name) } if (c->d()->activation && c->d()->activation->hasProperty(name)) return c->d()->activation->deleteProperty(name); - } else if (ctx->d()->type == Type_GlobalContext) { + } else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { GlobalContext *g = static_cast(ctx); if (g->d()->global->hasProperty(name)) return g->d()->global->deleteProperty(name); @@ -258,21 +258,21 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) for (int arg = 0; arg < ctx->callData->argc; ++arg) ctx->callData->args[arg].mark(engine); - if (ctx->type >= Type_CallContext) { - QV4::CallContext::Data *c = static_cast(ctx); + if (ctx->type >= Heap::ExecutionContext::Type_CallContext) { + QV4::Heap::CallContext *c = static_cast(ctx); for (unsigned local = 0, lastLocal = c->function->varCount(); local < lastLocal; ++local) c->locals[local].mark(engine); if (c->activation) c->activation->mark(engine); c->function->mark(engine); - } else if (ctx->type == Type_WithContext) { + } else if (ctx->type == Heap::ExecutionContext::Type_WithContext) { WithContext::Data *w = static_cast(ctx); w->withObject->mark(engine); - } else if (ctx->type == Type_CatchContext) { + } else if (ctx->type == Heap::ExecutionContext::Type_CatchContext) { CatchContext::Data *c = static_cast(ctx); c->exceptionVarName->mark(engine); c->exceptionValue.mark(engine); - } else if (ctx->type == Type_GlobalContext) { + } else if (ctx->type == Heap::ExecutionContext::Type_GlobalContext) { GlobalContext::Data *g = static_cast(ctx); g->global->mark(engine); } @@ -282,18 +282,18 @@ void ExecutionContext::setProperty(String *name, const ValueRef value) { Scope scope(this); for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { - if (ctx->d()->type == Type_WithContext) { + if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { ScopedObject w(scope, static_cast(ctx)->d()->withObject); if (w->hasProperty(name)) { w->put(name, value); return; } - } else if (ctx->d()->type == Type_CatchContext && static_cast(ctx)->d()->exceptionVarName->isEqualTo(name)) { + } else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext && static_cast(ctx)->d()->exceptionVarName->isEqualTo(name)) { static_cast(ctx)->d()->exceptionValue = *value; return; } else { ScopedObject activation(scope, (Object *)0); - if (ctx->d()->type >= Type_CallContext) { + if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { CallContext *c = static_cast(ctx); if (c->d()->function->function()) { uint index = c->d()->function->function()->internalClass->find(name); @@ -308,12 +308,12 @@ void ExecutionContext::setProperty(String *name, const ValueRef value) } } activation = c->d()->activation; - } else if (ctx->d()->type == Type_GlobalContext) { + } else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { activation = static_cast(ctx)->d()->global; } if (activation) { - if (ctx->d()->type == Type_QmlContext) { + if (ctx->d()->type == Heap::ExecutionContext::Type_QmlContext) { activation->put(name, value); return; } else { @@ -346,7 +346,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) bool hasWith = false; bool hasCatchScope = false; for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { - if (ctx->d()->type == Type_WithContext) { + if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { ScopedObject w(scope, static_cast(ctx)->d()->withObject); hasWith = true; bool hasProperty = false; @@ -357,14 +357,14 @@ ReturnedValue ExecutionContext::getProperty(String *name) continue; } - else if (ctx->d()->type == Type_CatchContext) { + else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext) { hasCatchScope = true; CatchContext *c = static_cast(ctx); if (c->d()->exceptionVarName->isEqualTo(name)) return c->d()->exceptionValue.asReturnedValue(); } - else if (ctx->d()->type >= Type_CallContext) { + else if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { QV4::CallContext *c = static_cast(ctx); ScopedFunctionObject f(scope, c->d()->function); if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { @@ -386,7 +386,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) return f.asReturnedValue(); } - else if (ctx->d()->type == Type_GlobalContext) { + else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { GlobalContext *g = static_cast(ctx); bool hasProperty = false; v = g->d()->global->get(name, &hasProperty); @@ -411,7 +411,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) bool hasWith = false; bool hasCatchScope = false; for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { - if (ctx->d()->type == Type_WithContext) { + if (ctx->d()->type == Heap::ExecutionContext::Type_WithContext) { Object *w = static_cast(ctx)->d()->withObject; hasWith = true; bool hasProperty = false; @@ -423,14 +423,14 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) continue; } - else if (ctx->d()->type == Type_CatchContext) { + else if (ctx->d()->type == Heap::ExecutionContext::Type_CatchContext) { hasCatchScope = true; CatchContext *c = static_cast(ctx); if (c->d()->exceptionVarName->isEqualTo(name)) return c->d()->exceptionValue.asReturnedValue(); } - else if (ctx->d()->type >= Type_CallContext) { + else if (ctx->d()->type >= Heap::ExecutionContext::Type_CallContext) { QV4::CallContext *c = static_cast(ctx); FunctionObject *f = c->d()->function; if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { @@ -445,7 +445,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) bool hasProperty = false; v = c->d()->activation->get(name, &hasProperty); if (hasProperty) { - if (ctx->d()->type == Type_QmlContext) + if (ctx->d()->type == Heap::ExecutionContext::Type_QmlContext) base = c->d()->activation; return v.asReturnedValue(); } @@ -455,7 +455,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base) return c->d()->function->asReturnedValue(); } - else if (ctx->d()->type == Type_GlobalContext) { + else if (ctx->d()->type == Heap::ExecutionContext::Type_GlobalContext) { GlobalContext *g = static_cast(ctx); bool hasProperty = false; v = g->d()->global->get(name, &hasProperty); diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index e45e82fda2..310fa6c576 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -51,12 +51,9 @@ struct CallContext; struct CatchContext; struct WithContext; -struct Q_QML_EXPORT ExecutionContext : public Managed -{ - enum { - IsExecutionContext = true - }; +namespace Heap { +struct ExecutionContext : Base { enum ContextType { Type_GlobalContext = 0x1, Type_CatchContext = 0x2, @@ -71,40 +68,84 @@ struct Q_QML_EXPORT ExecutionContext : public Managed EvalCode *next; }; - struct Data : Heap::Base { - Data(ExecutionEngine *engine, ContextType t) - : Heap::Base(engine->executionContextClass) - , type(t) - , strictMode(false) - , engine(engine) - , parent(engine->currentContext()) - , outer(0) - , lookups(0) - , compilationUnit(0) - , currentEvalCode(0) - , lineNumber(-1) - { - engine->current = reinterpret_cast(this); - } - ContextType type; - bool strictMode; - - CallData *callData; - - ExecutionEngine *engine; - ExecutionContext *parent; - ExecutionContext *outer; - Lookup *lookups; - CompiledData::CompilationUnit *compilationUnit; - EvalCode *currentEvalCode; - - int lineNumber; + ExecutionContext(ExecutionEngine *engine, ContextType t) + : Base(engine->executionContextClass) + , type(t) + , strictMode(false) + , engine(engine) + , parent(engine->currentContext()) + , outer(0) + , lookups(0) + , compilationUnit(0) + , currentEvalCode(0) + , lineNumber(-1) + { + // ### GC + engine->current = reinterpret_cast(this); + } + + ContextType type; + bool strictMode; + + CallData *callData; + + ExecutionEngine *engine; + // ### GC + QV4::ExecutionContext *parent; + QV4::ExecutionContext *outer; + Lookup *lookups; + CompiledData::CompilationUnit *compilationUnit; + EvalCode *currentEvalCode; + + int lineNumber; + +}; + +struct CallContext : ExecutionContext { + CallContext(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext) + : ExecutionContext(engine, t) + { + function = 0; + locals = 0; + activation = 0; + } + CallContext(ExecutionEngine *engine, Object *qml, QV4::FunctionObject *function); + + FunctionObject *function; + int realArgumentCount; + Value *locals; + Object *activation; +}; +struct GlobalContext : ExecutionContext { + GlobalContext(ExecutionEngine *engine); + Object *global; +}; + +struct CatchContext : ExecutionContext { + CatchContext(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue); + StringValue exceptionVarName; + Value exceptionValue; +}; + +struct WithContext : ExecutionContext { + WithContext(ExecutionEngine *engine, Object *with); + Object *withObject; +}; + + +} + +struct Q_QML_EXPORT ExecutionContext : public Managed +{ + enum { + IsExecutionContext = true }; - V4_MANAGED(Managed) + + V4_MANAGED2(ExecutionContext, Managed) Q_MANAGED_TYPE(ExecutionContext) - ExecutionContext(ExecutionEngine *engine, ContextType t) + ExecutionContext(ExecutionEngine *engine, Heap::ExecutionContext::ContextType t) : Managed(engine->executionContextClass) { d()->type = t; @@ -142,22 +183,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed struct CallContext : public ExecutionContext { - struct Data : ExecutionContext::Data { - Data(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext) - : ExecutionContext::Data(engine, t) - { - function = 0; - locals = 0; - activation = 0; - } - Data(ExecutionEngine *engine, Object *qml, QV4::FunctionObject *function); - - FunctionObject *function; - int realArgumentCount; - Value *locals; - Object *activation; - }; - V4_MANAGED(ExecutionContext) + V4_MANAGED2(CallContext, ExecutionContext) // formals are in reverse order String * const *formals() const; @@ -175,41 +201,28 @@ inline ReturnedValue CallContext::argument(int i) { struct GlobalContext : public ExecutionContext { - struct Data : ExecutionContext::Data { - Data(ExecutionEngine *engine); - Object *global; - }; - V4_MANAGED(ExecutionContext) + V4_MANAGED2(GlobalContext, ExecutionContext) }; struct CatchContext : public ExecutionContext { - struct Data : ExecutionContext::Data { - Data(ExecutionEngine *engine, String *exceptionVarName, const ValueRef exceptionValue); - StringValue exceptionVarName; - Value exceptionValue; - }; - V4_MANAGED(ExecutionContext) + V4_MANAGED2(CatchContext, ExecutionContext) }; struct WithContext : public ExecutionContext { - struct Data : ExecutionContext::Data { - Data(ExecutionEngine *engine, Object *with); - Object *withObject; - }; - V4_MANAGED(ExecutionContext) + V4_MANAGED2(WithContext, ExecutionContext) }; inline CallContext *ExecutionContext::asCallContext() { - return d()->type >= Type_SimpleCallContext ? static_cast(this) : 0; + return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast(this) : 0; } inline const CallContext *ExecutionContext::asCallContext() const { - return d()->type >= Type_SimpleCallContext ? static_cast(this) : 0; + return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast(this) : 0; } diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index c001b60295..64027ff6e4 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -465,15 +465,15 @@ void Debugger::collectReturnedValue(Collector *collector) const collector->collect(o); } -QVector Debugger::getScopeTypes(int frame) const +QVector Debugger::getScopeTypes(int frame) const { - QVector types; + QVector types; if (state() != Paused) return types; CallContext *sctxt = findContext(m_engine->currentContext(), frame); - if (!sctxt || sctxt->d()->type < ExecutionContext::Type_SimpleCallContext) + if (!sctxt || sctxt->d()->type < Heap::ExecutionContext::Type_SimpleCallContext) return types; CallContext *ctxt = static_cast(sctxt); @@ -575,7 +575,7 @@ Function *Debugger::getFunction() const if (CallContext *callCtx = context->asCallContext()) return callCtx->d()->function->function(); else { - Q_ASSERT(context->d()->type == QV4::ExecutionContext::Type_GlobalContext); + Q_ASSERT(context->d()->type == QV4::Heap::ExecutionContext::Type_GlobalContext); return context->d()->engine->globalCode; } } diff --git a/src/qml/jsruntime/qv4debugging_p.h b/src/qml/jsruntime/qv4debugging_p.h index 0e115f0de6..7ba95b83b8 100644 --- a/src/qml/jsruntime/qv4debugging_p.h +++ b/src/qml/jsruntime/qv4debugging_p.h @@ -171,7 +171,7 @@ public: bool collectThisInContext(Collector *collector, int frame = 0); void collectThrownValue(Collector *collector); void collectReturnedValue(Collector *collector) const; - QVector getScopeTypes(int frame = 0) const; + QVector getScopeTypes(int frame = 0) const; void evaluateExpression(int frameNr, const QString &expression, Collector *resultsCollector); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index c47420583c..865574425c 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -711,17 +711,17 @@ Returned *ExecutionEngine::qmlContextObject() const { ExecutionContext *ctx = currentContext(); - if (ctx->d()->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->d()->outer) + if (ctx->d()->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->d()->outer) ctx = ctx->d()->parent; if (!ctx->d()->outer) return 0; - while (ctx->d()->outer && ctx->d()->outer->d()->type != ExecutionContext::Type_GlobalContext) + while (ctx->d()->outer && ctx->d()->outer->d()->type != Heap::ExecutionContext::Type_GlobalContext) ctx = ctx->d()->outer; Q_ASSERT(ctx); - if (ctx->d()->type != ExecutionContext::Type_QmlContext) + if (ctx->d()->type != Heap::ExecutionContext::Type_QmlContext) return 0; return static_cast(ctx)->d()->activation->asReturned(); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index fea731ae48..4778a1742d 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -119,6 +119,7 @@ struct Q_QML_EXPORT ExecutionEngine private: friend struct ExecutionContextSaver; friend struct ExecutionContext; + friend struct Heap::ExecutionContext; ExecutionContext *current; public: ExecutionContext *currentContext() const { return current; } diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index b1e1f3ada6..58437bea62 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -116,6 +116,9 @@ namespace QV4 { namespace Heap { struct Base; + struct MemberData; + struct ArrayData; + struct ExecutionContext; } class MemoryManager; diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index e194460bfd..bc97e17a83 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -395,7 +395,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ContextStateSaver stateSaver(ctx); - ExecutionContext::EvalCode evalCode; + Heap::ExecutionContext::EvalCode evalCode; evalCode.function = function; evalCode.next = ctx->d()->currentEvalCode; ctx->d()->currentEvalCode = &evalCode; diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index cc7ce9d6b9..1cf90cba48 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -69,17 +69,18 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} const Data *d() const { return &static_cast(Managed::data); } \ Data *d() { return &static_cast(Managed::data); } -#define V4_MANAGED2(Data, superClass) \ +#define V4_MANAGED2(DataClass, superClass) \ public: \ Q_MANAGED_CHECK \ + typedef QV4::Heap::DataClass Data; \ typedef superClass SuperClass; \ static const QV4::ManagedVTable static_vtbl; \ static inline const QV4::ManagedVTable *staticVTable() { return &static_vtbl; } \ template \ QV4::Returned<_T> *asReturned() { return QV4::Returned<_T>::create(this); } \ V4_MANAGED_SIZE_TEST \ - const QV4::Heap::Data *d() const { return &static_cast(Managed::data); } \ - QV4::Heap::Data *d() { return &static_cast(Managed::data); } + const QV4::Heap::DataClass *d() const { return &static_cast(Managed::data); } \ + QV4::Heap::DataClass *d() { return &static_cast(Managed::data); } #define V4_OBJECT(superClass) \ public: \ diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 5c02555a66..6511e4c2f5 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1203,7 +1203,7 @@ ReturnedValue Runtime::objectLiteral(QV4::ExecutionContext *ctx, const QV4::Valu QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionContext *ctx) { - Q_ASSERT(ctx->d()->type >= ExecutionContext::Type_CallContext); + Q_ASSERT(ctx->d()->type >= Heap::ExecutionContext::Type_CallContext); CallContext *c = static_cast(ctx); return (c->engine()->memoryManager->alloc(c))->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 35ac5eac5f..af538474b1 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -204,7 +204,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code QV4::ExecutionContext *scope = context; int i = 0; while (scope) { - if (scope->d()->type >= QV4::ExecutionContext::Type_SimpleCallContext) { + if (scope->d()->type >= QV4::Heap::ExecutionContext::Type_SimpleCallContext) { QV4::CallContext *cc = static_cast(scope); scopes[2*i + 2] = cc->d()->callData->args; scopes[2*i + 3] = cc->d()->locals; -- cgit v1.2.3