diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-07-04 22:04:49 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-07-05 09:06:46 +0000 |
commit | 493edae038338320fb29a3eb252f76c2ff24b74f (patch) | |
tree | ffefca70b2221aa7e8a145f8334fbaf1e5f8d268 /src/qml | |
parent | cfb17c44cf3ae1268d066ba414759068059a7bbd (diff) |
Get rid of the GlobalContext and WithContext classes
They are just ExecutionContext's.
Change-Id: Id543934740b0e54172e469935513847224b19e79
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 38 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 44 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 2 |
5 files changed, 20 insertions, 73 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 7c0a872a3b..dd05539864 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -56,9 +56,7 @@ using namespace QV4; DEFINE_MANAGED_VTABLE(ExecutionContext); DEFINE_MANAGED_VTABLE(SimpleCallContext); DEFINE_MANAGED_VTABLE(CallContext); -DEFINE_MANAGED_VTABLE(WithContext); DEFINE_MANAGED_VTABLE(CatchContext); -DEFINE_MANAGED_VTABLE(GlobalContext); Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData) { @@ -98,9 +96,18 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData return c; } -Heap::WithContext *ExecutionContext::newWithContext(Heap::Object *with) +Heap::ExecutionContext *ExecutionContext::newWithContext(Heap::Object *with) { - return engine()->memoryManager->alloc<WithContext>(d(), with); + Heap::ExecutionContext *c = engine()->memoryManager->alloc<ExecutionContext>(Heap::ExecutionContext::Type_WithContext); + c->outer.set(engine(), d()); + c->activation.set(engine(), with); + + c->callData = d()->callData; + c->lookups = d()->lookups; + c->constantTable = d()->constantTable; + c->compilationUnit = d()->compilationUnit; + + return c; } Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue) @@ -154,12 +161,6 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) activation->__defineOwnProperty__(scope.engine, name, desc, attrs); } -void Heap::GlobalContext::init(ExecutionEngine *eng) -{ - Heap::ExecutionContext::init(Heap::ExecutionContext::Type_GlobalContext); - activation.set(eng, eng->globalObject->d()); -} - void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue) { @@ -175,18 +176,6 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV this->exceptionValue.set(internalClass->engine, exceptionValue); } -void Heap::WithContext::init(ExecutionContext *outerContext, Object *with) -{ - Heap::ExecutionContext::init(Heap::ExecutionContext::Type_WithContext); - outer.set(internalClass->engine, outerContext); - callData = outer->callData; - lookups = outer->lookups; - constantTable = outer->constantTable; - compilationUnit = outer->compilationUnit; - - activation.set(internalClass->engine, with); -} - Identifier * const *SimpleCallContext::formals() const { return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() : 0; @@ -318,7 +307,7 @@ void ExecutionContext::setProperty(String *name, const Value &value) } case Heap::ExecutionContext::Type_WithContext: { // the semantics are different from the setProperty calls of other activations - ScopedObject w(scope, static_cast<Heap::WithContext *>(ctx->d())->activation); + ScopedObject w(scope, ctx->d()->activation); if (w->hasProperty(name)) { w->put(name, value); return; @@ -496,7 +485,8 @@ Function *ExecutionContext::getFunction() const for (; it; it = it->d()->outer) { if (const SimpleCallContext *callCtx = it->asSimpleCallContext()) return callCtx->d()->v4Function; - else if (it->asCatchContext() || it->asWithContext()) + else if (it->d()->type == Heap::ExecutionContext::Type_CatchContext || + it->d()->type == Heap::ExecutionContext::Type_WithContext) continue; // look in the parent context for a FunctionObject else break; diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 3ecdc594b6..e6405350dd 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -70,7 +70,6 @@ struct Identifier; struct CallContext; struct SimpleCallContext; struct CatchContext; -struct WithContext; struct QmlContext; struct QQmlContextWrapper; @@ -198,15 +197,6 @@ Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0); // example it is not. Therefore we have a padding in place and always have a distance of 8 bytes. Q_STATIC_ASSERT(offsetof(CallContextData, locals) == offsetof(CallContextData, function) + 8); -#define GlobalContextMembers(class, Member) - -DECLARE_HEAP_OBJECT(GlobalContext, ExecutionContext) { - DECLARE_MARK_TABLE(GlobalContext); - - void init(ExecutionEngine *engine); -}; -V4_ASSERT_IS_TRIVIAL(GlobalContext) - #define CatchContextMembers(class, Member) \ Member(class, Pointer, String *, exceptionVarName) \ Member(class, HeapValue, HeapValue, exceptionValue) @@ -218,15 +208,6 @@ DECLARE_HEAP_OBJECT(CatchContext, ExecutionContext) { }; V4_ASSERT_IS_TRIVIAL(CatchContext) -#define WithContextMembers(class, Member) - -DECLARE_HEAP_OBJECT(WithContext, ExecutionContext) { - DECLARE_MARK_TABLE(WithContext); - - void init(ExecutionContext *outerContext, Object *with); -}; -V4_ASSERT_IS_TRIVIAL(WithContext) - } struct Q_QML_EXPORT ExecutionContext : public Managed @@ -240,7 +221,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed V4_INTERNALCLASS(ExecutionContext) Heap::CallContext *newCallContext(Function *f, CallData *callData); - Heap::WithContext *newWithContext(Heap::Object *with); + Heap::ExecutionContext *newWithContext(Heap::Object *with); Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue); void createMutableBinding(String *name, bool deletable); @@ -252,8 +233,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed inline SimpleCallContext *asSimpleCallContext(); inline const SimpleCallContext *asSimpleCallContext() const; - inline const CatchContext *asCatchContext() const; - inline const WithContext *asWithContext() const; Function *getFunction() const; @@ -297,22 +276,11 @@ struct Q_QML_EXPORT CallContext : public SimpleCallContext V4_MANAGED(CallContext, SimpleCallContext) }; -struct GlobalContext : public ExecutionContext -{ - V4_MANAGED(GlobalContext, ExecutionContext) - -}; - struct CatchContext : public ExecutionContext { V4_MANAGED(CatchContext, ExecutionContext) }; -struct WithContext : public ExecutionContext -{ - V4_MANAGED(WithContext, ExecutionContext) -}; - inline SimpleCallContext *ExecutionContext::asSimpleCallContext() { return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<SimpleCallContext *>(this) : 0; @@ -323,16 +291,6 @@ inline const SimpleCallContext *ExecutionContext::asSimpleCallContext() const return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<const SimpleCallContext *>(this) : 0; } -inline const CatchContext *ExecutionContext::asCatchContext() const -{ - return d()->type == Heap::ExecutionContext::Type_CatchContext ? static_cast<const CatchContext *>(this) : 0; -} - -inline const WithContext *ExecutionContext::asWithContext() const -{ - return d()->type == Heap::ExecutionContext::Type_WithContext ? static_cast<const WithContext *>(this) : 0; -} - } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d17af43ca4..f2f032df51 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -516,9 +516,10 @@ void ExecutionEngine::setProfiler(Profiling::Profiler *profiler) void ExecutionEngine::initRootContext() { Scope scope(this); - Scoped<GlobalContext> r(scope, memoryManager->allocManaged<GlobalContext>( - sizeof(GlobalContext::Data) + sizeof(CallData))); - r->d_unchecked()->init(this); + Scoped<ExecutionContext> r(scope, memoryManager->allocManaged<ExecutionContext>( + sizeof(ExecutionContext::Data) + sizeof(CallData))); + r->d_unchecked()->init(Heap::ExecutionContext::Type_GlobalContext); + r->d()->activation.set(this, globalObject->d()); r->d()->callData = reinterpret_cast<CallData *>(r->d() + 1); r->d()->callData->tag = quint32(Value::ValueTypeInternal::Integer); r->d()->callData->argc = 0; diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 5929d3df11..0bb460243c 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -180,7 +180,7 @@ public: Value *jsObjects; enum { NTypedArrayTypes = 9 }; // == TypedArray::NValues, avoid header dependency - GlobalContext *rootContext() const { return reinterpret_cast<GlobalContext *>(jsObjects + RootContext); } + ExecutionContext *rootContext() const { return reinterpret_cast<ExecutionContext *>(jsObjects + RootContext); } FunctionObject *objectCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Object_Ctor); } FunctionObject *stringCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + String_Ctor); } FunctionObject *numberCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Number_Ctor); } diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 549cf66e24..8e091fd80e 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -166,7 +166,6 @@ namespace Heap { struct ObjectPrototype; struct ExecutionContext; - struct GlobalContext; struct CallContext; struct ScriptFunction; @@ -197,7 +196,6 @@ struct Object; struct ObjectPrototype; struct ObjectIterator; struct ExecutionContext; -struct GlobalContext; struct CallContext; struct ScriptFunction; struct InternalClass; |