diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-05-19 15:50:22 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-05-19 18:54:54 +0000 |
commit | 8bc243f569e3feb1005fbca426bf24f59c38af2e (patch) | |
tree | 3e69253b161432e4a02c3daa2de4ffbd2d9293f4 /src/qml | |
parent | 5bc38a50308665bdc185eb96dbcc9ba7948ab4e0 (diff) |
Move the engine() accessor from Object to Managed
We can easily do this now that Managed has a pointer to an
internal class (which always has a back pointer to the
ExecutionEngine).
Remove the extra engine pointer from ExecutionContext, and clean
up tow methods in String.
Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 21 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 47 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 17 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.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/qv4managed_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 18 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 2 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 4 |
18 files changed, 71 insertions, 89 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index bab2e633a7..3a3cf46ddb 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -1019,7 +1019,7 @@ QJSValue QJSValue::property(const QString& name) const if (idx < UINT_MAX) return property(idx); - s->makeIdentifier(engine); + s->makeIdentifier(); QV4::ScopedValue result(scope, o->get(s)); if (engine->hasException) result = engine->catchException(); @@ -1090,7 +1090,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value) return; } - s->makeIdentifier(scope.engine); + s->makeIdentifier(); QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value)); o->put(s, v); if (engine->hasException) diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 9354bcb1a3..6ab838c387 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -53,13 +53,13 @@ void Heap::ArgumentsObject::init(QV4::CallContext *context) this->context = context->d(); Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable()); - ExecutionEngine *v4 = context->d()->engine; + ExecutionEngine *v4 = context->engine(); Scope scope(v4); Scoped<QV4::ArgumentsObject> args(scope, this); if (context->d()->strictMode) { - Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee())); - Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller())); + Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(v4->id_callee())); + Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(v4->id_caller())); *args->propertyData(CalleePropertyIndex + QV4::Object::GetterOffset) = v4->thrower(); *args->propertyData(CalleePropertyIndex + QV4::Object::SetterOffset) = v4->thrower(); *args->propertyData(CallerPropertyIndex + QV4::Object::GetterOffset) = v4->thrower(); @@ -69,10 +69,10 @@ void Heap::ArgumentsObject::init(QV4::CallContext *context) args->arrayPut(0, context->args(), context->argc()); args->d()->fullyCreated = true; } else { - Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee())); + Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(v4->id_callee())); *args->propertyData(CalleePropertyIndex) = context->d()->function->asReturnedValue(); } - Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(context->d()->engine->id_length())); + Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(v4->id_length())); *args->propertyData(LengthPropertyIndex) = Primitive::fromInt32(context->d()->callData->argc); } @@ -81,18 +81,19 @@ void ArgumentsObject::fullyCreate() if (fullyCreated()) return; + Scope scope(engine()); + uint argCount = context()->callData->argc; uint numAccessors = qMin(context()->formalParameterCount(), argCount); ArrayData::realloc(this, Heap::ArrayData::Sparse, argCount, true); - context()->engine->requireArgumentsAccessors(numAccessors); + scope.engine->requireArgumentsAccessors(numAccessors); - Scope scope(engine()); Scoped<MemberData> md(scope, d()->mappedArguments); if (numAccessors) { - d()->mappedArguments = md->allocate(engine(), numAccessors); + d()->mappedArguments = md->allocate(scope.engine, numAccessors); for (uint i = 0; i < numAccessors; ++i) { d()->mappedArguments->data[i] = context()->callData->args[i]; - arraySet(i, context()->engine->argumentsAccessors + i, Attr_Accessor); + arraySet(i, scope.engine->argumentsAccessors + i, Attr_Accessor); } } arrayPut(numAccessors, context()->callData->args + numAccessors, argCount - numAccessors); @@ -114,7 +115,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con uint numAccessors = qMin((int)context()->formalParameterCount(), context()->callData->argc); if (pd && index < (uint)numAccessors) isMapped = arrayData()->attributes(index).isAccessor() && - pd->getter() == context()->engine->argumentsAccessors[index].getter(); + pd->getter() == scope.engine->argumentsAccessors[index].getter(); if (isMapped) { Q_ASSERT(arrayData()); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 03595aa59d..3ff864d7b9 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -66,9 +66,9 @@ DEFINE_MANAGED_VTABLE(GlobalContext); Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData) { - Heap::CallContext *c = d()->engine->memoryManager->allocManaged<CallContext>( + Heap::CallContext *c = engine()->memoryManager->allocManaged<CallContext>( requiredMemoryForExecutionContect(function, callData->argc)); - c->init(d()->engine, Heap::ExecutionContext::Type_CallContext); + c->init(Heap::ExecutionContext::Type_CallContext); c->v4Function = function; @@ -95,27 +95,16 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData return c; } -Heap::CallContext *Heap::CallContext::createSimpleContext(ExecutionEngine *v4) -{ - Heap::CallContext *ctxt = v4->memoryManager->allocSimpleCallContext(v4); - return ctxt; -} - -void Heap::CallContext::freeSimpleCallContext() -{ - engine->memoryManager->freeSimpleCallContext(); -} - Heap::WithContext *ExecutionContext::newWithContext(Heap::Object *with) { - return d()->engine->memoryManager->alloc<WithContext>(d(), with); + return engine()->memoryManager->alloc<WithContext>(d(), with); } Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue) { Scope scope(this); ScopedValue e(scope, exceptionValue); - return d()->engine->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e); + return engine()->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e); } void ExecutionContext::createMutableBinding(String *name, bool deletable) @@ -165,14 +154,14 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) void Heap::GlobalContext::init(ExecutionEngine *eng) { - Heap::ExecutionContext::init(eng, Heap::ExecutionContext::Type_GlobalContext); + Heap::ExecutionContext::init(Heap::ExecutionContext::Type_GlobalContext); global = eng->globalObject->d(); } void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue) { - Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_CatchContext); + Heap::ExecutionContext::init(Heap::ExecutionContext::Type_CatchContext); outer = outerContext; strictMode = outer->strictMode; callData = outer->callData; @@ -209,7 +198,7 @@ unsigned int CallContext::variableCount() const bool ExecutionContext::deleteProperty(String *name) { - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); Scope scope(this); @@ -339,7 +328,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio ExecutionContextSaver ctxSaver(scope); - CallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(scope.engine); + CallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(); ctx->strictMode = function->isStrict(); ctx->callData = callData; @@ -364,7 +353,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio void ExecutionContext::setProperty(String *name, const Value &value) { - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); Scope scope(this); @@ -428,21 +417,21 @@ void ExecutionContext::setProperty(String *name, const Value &value) } } - if (d()->strictMode || name->equals(d()->engine->id_this())) { + if (d()->strictMode || name->equals(engine()->id_this())) { ScopedValue n(scope, name->asReturnedValue()); engine()->throwReferenceError(n); return; } - d()->engine->globalObject->put(name, value); + engine()->globalObject->put(name, value); } ReturnedValue ExecutionContext::getProperty(String *name) { Scope scope(this); ScopedValue v(scope); - name->makeIdentifier(scope.engine); + name->makeIdentifier(); - if (name->equals(d()->engine->id_this())) + if (name->equals(engine()->id_this())) return thisObject().asReturnedValue(); bool hasWith = false; @@ -479,7 +468,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d()); if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) { - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); uint index = c->v4Function->internalClass->find(id); @@ -520,9 +509,9 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) Scope scope(this); ScopedValue v(scope); base->setM(0); - name->makeIdentifier(scope.engine); + name->makeIdentifier(); - if (name->equals(d()->engine->id_this())) + if (name->equals(engine()->id_this())) return thisObject().asReturnedValue(); bool hasWith = false; @@ -560,7 +549,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d()); if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) { - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); uint index = c->v4Function->internalClass->find(id); @@ -600,7 +589,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) Function *ExecutionContext::getFunction() const { - Scope scope(d()->engine); + Scope scope(engine()); ScopedContext it(scope, this->d()); for (; it; it = it->d()->outer) { if (const CallContext *callCtx = it->asCallContext()) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 89ff6dc957..0b63922a4b 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -105,7 +105,6 @@ struct QmlContext; // can use the Members macro struct ExecutionContextData { CallData *callData; - ExecutionEngine *engine; ExecutionContext *outer; Lookup *lookups; const QV4::Value *constantTable; @@ -120,8 +119,7 @@ struct ExecutionContextData { Q_STATIC_ASSERT(std::is_standard_layout<ExecutionContextData>::value); Q_STATIC_ASSERT(offsetof(ExecutionContextData, callData) == 0); -Q_STATIC_ASSERT(offsetof(ExecutionContextData, engine) == offsetof(ExecutionContextData, callData) + QT_POINTER_SIZE); -Q_STATIC_ASSERT(offsetof(ExecutionContextData, outer) == offsetof(ExecutionContextData, engine) + QT_POINTER_SIZE); +Q_STATIC_ASSERT(offsetof(ExecutionContextData, outer) == offsetof(ExecutionContextData, callData) + QT_POINTER_SIZE); Q_STATIC_ASSERT(offsetof(ExecutionContextData, lookups) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE); Q_STATIC_ASSERT(offsetof(ExecutionContextData, constantTable) == offsetof(ExecutionContextData, lookups) + QT_POINTER_SIZE); Q_STATIC_ASSERT(offsetof(ExecutionContextData, compilationUnit) == offsetof(ExecutionContextData, constantTable) + QT_POINTER_SIZE); @@ -141,11 +139,10 @@ struct ExecutionContext : Base, public ExecutionContextData { Type_CallContext = 0x6 }; - void init(ExecutionEngine *engine, ContextType t) + void init(ContextType t) { Base::init(); - this->engine = engine; type = t; lineNumber = -1; } @@ -172,12 +169,10 @@ struct CallContextSizeStruct : public ExecutionContext, public CallContextData { struct CallContext : ExecutionContext, public CallContextData { static Q_CONSTEXPR size_t baseOffset = sizeof(CallContextSizeStruct) - sizeof(CallContextData); - static CallContext *createSimpleContext(ExecutionEngine *v4); - void freeSimpleCallContext(); - void init(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext) + void init(ContextType t = Type_SimpleCallContext) { - ExecutionContext::init(engine, t); + ExecutionContext::init(t); } inline unsigned int formalParameterCount() const; @@ -204,7 +199,7 @@ V4_ASSERT_IS_TRIVIAL(CatchContext) struct WithContext : ExecutionContext { void init(ExecutionContext *outerContext, Object *with) { - Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_WithContext); + Heap::ExecutionContext::init(Heap::ExecutionContext::Type_WithContext); outer = outerContext; callData = outer->callData; lookups = outer->lookups; @@ -230,8 +225,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed Q_MANAGED_TYPE(ExecutionContext) V4_INTERNALCLASS(ExecutionContext) - ExecutionEngine *engine() const { return d()->engine; } - Heap::CallContext *newCallContext(Function *f, CallData *callData); Heap::WithContext *newWithContext(Heap::Object *with); Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index cb666451bb..0cb1b1ee13 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -868,8 +868,8 @@ static inline char *v4StackTrace(const ExecutionContext *context) QString result; QTextStream str(&result); str << "stack=["; - if (context && context->d()->engine) { - const QVector<StackFrame> stackTrace = context->d()->engine->stackTrace(20); + if (context && context->engine()) { + const QVector<StackFrame> stackTrace = context->engine()->stackTrace(20); for (int i = 0; i < stackTrace.size(); ++i) { if (i) str << ','; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index bd6eb17bb4..9eb9d2ad36 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -122,7 +122,7 @@ void FunctionObject::init(String *n, bool createProto) Q_ASSERT(internalClass() && internalClass()->find(s.engine->id_prototype()) == Heap::FunctionObject::Index_Prototype); if (createProto) { - ScopedObject proto(s, scope()->engine->newObject(s.engine->internalClasses[EngineBase::Class_ObjectProto], s.engine->objectPrototype())); + ScopedObject proto(s, s.engine->newObject(s.engine->internalClasses[EngineBase::Class_ObjectProto], s.engine->objectPrototype())); Q_ASSERT(s.engine->internalClasses[EngineBase::Class_ObjectProto]->find(s.engine->id_constructor()) == Heap::FunctionObject::Index_ProtoConstructor); *proto->propertyData(Heap::FunctionObject::Index_ProtoConstructor) = this->asReturnedValue(); *propertyData(Heap::FunctionObject::Index_Prototype) = proto.asReturnedValue(); @@ -136,7 +136,7 @@ void FunctionObject::init(String *n, bool createProto) ReturnedValue FunctionObject::name() const { - return get(scope()->engine->id_name()); + return get(scope()->internalClass->engine->id_name()); } void FunctionObject::construct(const Managed *that, Scope &scope, CallData *) @@ -160,7 +160,7 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e) Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function) { - return scope->d()->engine->memoryManager->allocObject<ScriptFunction>(scope, function); + return scope->engine()->memoryManager->allocObject<ScriptFunction>(scope, function); } bool FunctionObject::isBinding() const @@ -439,8 +439,8 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function ScopedProperty pd(s); pd->value = s.engine->thrower(); pd->set = s.engine->thrower(); - f->insertMember(scope->d()->engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - f->insertMember(scope->d()->engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + f->insertMember(s.engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); } } @@ -497,7 +497,7 @@ void IndexedBuiltinFunction::call(const Managed *that, Scope &scope, CallData *c ExecutionContextSaver ctxSaver(scope); - CallContext::Data *ctx = v4->memoryManager->allocSimpleCallContext(v4); + CallContext::Data *ctx = v4->memoryManager->allocSimpleCallContext(); ctx->strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx->callData = callData; v4->pushContext(ctx); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index f0630660d4..0916e8e110 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -332,8 +332,8 @@ DEFINE_OBJECT_VTABLE(EvalFunction); void Heap::EvalFunction::init(QV4::ExecutionContext *scope) { - Heap::FunctionObject::init(scope, scope->d()->engine->id_eval()); Scope s(scope); + Heap::FunctionObject::init(scope, s.engine->id_eval()); ScopedFunctionObject f(s, this); f->defineReadonlyProperty(s.engine->id_length(), Primitive::fromInt32(1)); } diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 4c387a7fe7..6859334797 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -199,6 +199,7 @@ public: Q_MANAGED_TYPE(Invalid) InternalClass *internalClass() const { return d()->internalClass; } + inline ExecutionEngine *engine() const { return internalClass()->engine; } bool isListType() const { return d()->vtable()->type == Type_QmlSequence; } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 04336d4f88..98f5c7464f 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -254,7 +254,7 @@ void Object::getOwnProperty(String *name, PropertyAttributes *attrs, Property *p if (idx != UINT_MAX) return getOwnProperty(idx, attrs, p); - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); uint member = internalClass()->find(id); @@ -299,7 +299,7 @@ Value *Object::getValueOrSetter(String *name, PropertyAttributes *attrs) { Q_ASSERT(name->asArrayIndex() == UINT_MAX); - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); Heap::Object *o = d(); @@ -377,7 +377,7 @@ bool Object::hasOwnProperty(String *name) const if (idx != UINT_MAX) return hasOwnProperty(idx); - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); if (internalClass()->find(id) < UINT_MAX) @@ -437,7 +437,7 @@ PropertyAttributes Object::query(const Managed *m, String *name) if (idx != UINT_MAX) return queryIndexed(m, idx); - name->makeIdentifier(m->internalClass()->engine); + name->makeIdentifier(); Identifier *id = name->identifier(); const Object *o = static_cast<const Object *>(m); @@ -640,10 +640,10 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty) const if (idx != UINT_MAX) return getIndexed(idx, hasProperty); - Scope scope(engine()); - name->makeIdentifier(scope.engine); + name->makeIdentifier(); Identifier *id = name->identifier(); + Scope scope(engine()); ScopedObject o(scope, this); while (o) { uint idx = o->internalClass()->find(id); @@ -708,7 +708,7 @@ void Object::internalPut(String *name, const Value &value) if (idx != UINT_MAX) return putIndexed(idx, value); - name->makeIdentifier(engine()); + name->makeIdentifier(); Identifier *id = name->identifier(); uint member = internalClass()->find(id); @@ -862,7 +862,7 @@ bool Object::internalDeleteProperty(String *name) if (idx != UINT_MAX) return deleteIndexedProperty(idx); - name->makeIdentifier(engine()); + name->makeIdentifier(); uint memberIdx = internalClass()->find(name->identifier()); if (memberIdx != UINT_MAX) { @@ -901,7 +901,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const return __defineOwnProperty__(engine, idx, p, attrs); Scope scope(engine); - name->makeIdentifier(scope.engine); + name->makeIdentifier(); uint memberIndex; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index a9afe14129..9592ff5d1b 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -273,8 +273,6 @@ struct Q_QML_EXPORT Object: Managed { } void insertMember(String *s, const Property *p, PropertyAttributes attributes); - inline ExecutionEngine *engine() const { return internalClass()->engine; } - bool isExtensible() const { return d()->internalClass->extensible; } // Array handling diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index ef1a1c11ed..91d65a70c9 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -300,7 +300,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value) void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml) { - Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext); + Heap::ExecutionContext::init(Heap::ExecutionContext::Type_QmlContext); outer = outerContext->d(); strictMode = false; callData = outer->callData; @@ -330,7 +330,7 @@ Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, cons qml->QV4::Object::put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api); qml->setReadOnly(true); - Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc<QmlContext>(parent, qml); + Heap::QmlContext *c = scope.engine->memoryManager->alloc<QmlContext>(parent, qml); Q_ASSERT(c->vtable() == staticVTable()); return c; } @@ -340,7 +340,7 @@ Heap::QmlContext *QmlContext::create(ExecutionContext *parent, QQmlContextData * Scope scope(parent); Scoped<QmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QmlContextWrapper>(context, scopeObject)); - Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc<QmlContext>(parent, qml); + Heap::QmlContext *c = scope.engine->memoryManager->alloc<QmlContext>(parent, qml); Q_ASSERT(c->vtable() == staticVTable()); return c; } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index f484d56040..d7978cc212 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1688,7 +1688,7 @@ QV4::ReturnedValue CallArgument::toValue(QV4::ExecutionEngine *engine) ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index) { Scope valueScope(scope); - Scoped<QObjectMethod> method(valueScope, scope->d()->engine->memoryManager->allocObject<QObjectMethod>(scope)); + Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope)); method->d()->setObject(object); if (QQmlData *ddata = QQmlData::get(object)) @@ -1739,7 +1739,7 @@ QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) co result = QLatin1String("null"); } - return ctx->d()->engine->newString(result)->asReturnedValue(); + return ctx->engine()->newString(result)->asReturnedValue(); } QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const Value *args, int argc) const diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index bc882bbd95..04a0c74133 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -102,7 +102,7 @@ struct ScopedValue; struct Scope { inline Scope(ExecutionContext *ctx) - : engine(ctx->d()->engine) + : engine(ctx->engine()) , mark(engine->jsStackTop) , result(*engine->jsAlloca(1)) { diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index cde2131aab..1404ab6d9b 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -141,12 +141,12 @@ uint String::toUInt(bool *ok) const return UINT_MAX; } -void String::makeIdentifierImpl(ExecutionEngine *e) const +void String::makeIdentifierImpl() const { if (d()->largestSubLength) d()->simplifyString(); Q_ASSERT(!d()->largestSubLength); - e->identifierTable->identifier(this); + engine()->identifierTable->identifier(this); } void Heap::String::simplifyString() const diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index ad30165ce5..458a9edae6 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -176,13 +176,13 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { } uint toUInt(bool *ok) const; - void makeIdentifier(ExecutionEngine *e) const { + void makeIdentifier() const { if (d()->identifier) return; - makeIdentifierImpl(e); + makeIdentifierImpl(); } - void makeIdentifierImpl(ExecutionEngine *e) const; + void makeIdentifierImpl() const; static uint createHashValue(const QChar *ch, int length, uint *subtype) { diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index d662b1738d..9d65f67f0f 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -172,7 +172,7 @@ static QV4::Function *qt_v4ExtractFunction(QV4::ExecutionContext *context) if (QV4::Function *function = context->getFunction()) return function; else - return context->d()->engine->globalCode; + return context->engine()->globalCode; } static void qt_v4TriggerBreakpoint(const Breakpoint &bp, QV4::Function *function) diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index 69d3eeb93c..c5334a0dde 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -206,13 +206,13 @@ public: Q_DECL_CONSTEXPR static inline std::size_t align(std::size_t size) { return (size + Chunk::SlotSize - 1) & ~(Chunk::SlotSize - 1); } - QV4::Heap::CallContext *allocSimpleCallContext(QV4::ExecutionEngine *v4) + QV4::Heap::CallContext *allocSimpleCallContext() { Heap::CallContext *ctxt = stackAllocator.allocate(); memset(ctxt, 0, sizeof(Heap::CallContext)); ctxt->internalClass = CallContext::defaultInternalClass(engine); Q_ASSERT(ctxt->internalClass && ctxt->internalClass->vtable); - ctxt->init(v4); + ctxt->init(); return ctxt; } diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index d0d9f080da..f3a39313c1 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -895,7 +895,7 @@ ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasPropert const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m); QV4::ExecutionEngine *v4 = r->engine(); - name->makeIdentifier(v4); + name->makeIdentifier(); if (name->equals(v4->id_length())) return Primitive::fromInt32(r->d()->list().count()).asReturnedValue(); @@ -940,7 +940,7 @@ ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty) const NodeList *r = static_cast<const NodeList *>(m); QV4::ExecutionEngine *v4 = r->engine(); - name->makeIdentifier(v4); + name->makeIdentifier(); if (name->equals(v4->id_length())) return Primitive::fromInt32(r->d()->d->children.count()).asReturnedValue(); |