From 13edffa303c0a4514035857b4a61b2665ede7b2c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 28 Aug 2015 13:33:10 +0200 Subject: Move remaining objects to new constructor syntax Also disable the old way of constructing objects. Change-Id: Ib4e69087cd563ae1481da116d6caf97876239798 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4dataview.cpp | 11 +------- src/qml/jsruntime/qv4dataview_p.h | 3 ++- src/qml/jsruntime/qv4engine.cpp | 4 +-- src/qml/jsruntime/qv4object.cpp | 10 ------- src/qml/jsruntime/qv4object_p.h | 8 ------ src/qml/jsruntime/qv4objectiterator_p.h | 7 +++-- src/qml/jsruntime/qv4qobjectwrapper.cpp | 14 +++++----- src/qml/jsruntime/qv4qobjectwrapper_p.h | 4 +-- src/qml/jsruntime/qv4script.cpp | 11 ++++---- src/qml/jsruntime/qv4sequenceobject.cpp | 23 ++++++++-------- src/qml/jsruntime/qv4typedarray_p.h | 7 +++-- src/qml/qml/qqmlcomponent.cpp | 9 +++---- src/qml/qml/qqmlcontextwrapper.cpp | 9 +++---- src/qml/qml/qqmlcontextwrapper_p.h | 2 +- src/qml/qml/qqmllistwrapper.cpp | 9 +++---- src/qml/qml/qqmllistwrapper_p.h | 2 +- src/qml/qml/qqmllocale.cpp | 2 +- src/qml/qml/qqmllocale_p.h | 7 +---- src/qml/qml/qqmltypewrapper.cpp | 12 +++------ src/qml/qml/qqmltypewrapper_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 16 +++-------- src/qml/qml/qqmlvaluetypewrapper_p.h | 2 +- src/qml/qml/qqmlxmlhttprequest.cpp | 47 +++++++++++++++------------------ src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 20 +++++++------- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 4 +-- src/qml/types/qqmldelegatemodel.cpp | 22 ++++++--------- src/qml/types/qqmldelegatemodel_p_p.h | 7 +++-- src/qml/types/qqmllistmodel.cpp | 2 +- src/qml/types/qqmllistmodel_p_p.h | 4 +-- src/qml/util/qqmladaptormodel.cpp | 4 +-- 30 files changed, 108 insertions(+), 176 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index e5ac32283e..8901834e76 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -62,7 +62,7 @@ ReturnedValue DataViewCtor::construct(const Managed *m, CallData *callData) if (bo != byteOffset || bl != byteLength || byteOffset + byteLength > bufferLength) return scope.engine->throwRangeError(QStringLiteral("DataView: constructor arguments out of range")); - Scoped a(scope, scope.engine->memoryManager->alloc(scope.engine)); + Scoped a(scope, scope.engine->memoryManager->allocObject()); a->d()->buffer = buffer->d(); a->d()->byteLength = byteLength; a->d()->byteOffset = byteOffset; @@ -76,15 +76,6 @@ ReturnedValue DataViewCtor::call(const Managed *that, CallData *callData) } -Heap::DataView::DataView(ExecutionEngine *e) - : Heap::Object(e->emptyClass, e->dataViewPrototype()), - buffer(0), - byteLength(0), - byteOffset(0) -{ -} - - void DataView::markObjects(Heap::Base *that, ExecutionEngine *e) { DataView::Data *v = static_cast(that); diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h index e98239396a..37a8363645 100644 --- a/src/qml/jsruntime/qv4dataview_p.h +++ b/src/qml/jsruntime/qv4dataview_p.h @@ -47,7 +47,7 @@ struct DataViewCtor : FunctionObject { }; struct DataView : Object { - DataView(ExecutionEngine *e); + DataView() {} Pointer buffer; uint byteLength; uint byteOffset; @@ -66,6 +66,7 @@ struct DataViewCtor: FunctionObject struct DataView : Object { V4_OBJECT2(DataView, Object) + V4_PROTOTYPE(dataViewPrototype) static void markObjects(Heap::Base *that, ExecutionEngine *e); }; diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b3017e694d..9bd296166f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -428,7 +428,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) for (int i = 0; i < Heap::TypedArray::NTypes; ++i) { static_cast(typedArrayCtors[i]) = memoryManager->allocObject(global, Heap::TypedArray::Type(i)); - static_cast(typedArrayPrototype[i]) = memoryManager->alloc(this, Heap::TypedArray::Type(i)); + static_cast(typedArrayPrototype[i]) = memoryManager->allocObject(Heap::TypedArray::Type(i)); typedArrayPrototype[i].as()->init(this, static_cast(typedArrayCtors[i].as())); } @@ -742,7 +742,7 @@ Heap::Object *ExecutionEngine::newVariantObject(const QVariant &v) Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o) { Scope scope(this); - ScopedObject obj(scope, memoryManager->alloc(this, o)); + ScopedObject obj(scope, memoryManager->allocObject(o)); return obj->d(); } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 2245e1de61..42cc3c7df4 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -51,16 +51,6 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(Object); -Heap::Object::Object(InternalClass *internalClass, QV4::Object *prototype) - : prototype(prototype ? prototype->d() : 0) -{ - if (internalClass) { - Scope scope(internalClass->engine); - ScopedObject o(scope, this); - o->setInternalClass(internalClass); - } -} - void Object::setInternalClass(InternalClass *ic) { d()->internalClass = ic; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index cd54e6c83d..58dab9691f 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -49,8 +49,6 @@ namespace Heap { struct Object : Base { inline Object() {} - inline Object(ExecutionEngine *engine); - Object(InternalClass *internal, QV4::Object *prototype); const Value *propertyData(uint index) const { if (index < inlineMemberSize) return reinterpret_cast(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } Value *propertyData(uint index) { if (index < inlineMemberSize) return reinterpret_cast(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } @@ -343,12 +341,6 @@ private: namespace Heap { -inline Object::Object(ExecutionEngine *engine) - : internalClass(engine->emptyClass), - prototype(static_cast(engine->objectPrototype()->m())) -{ -} - struct BooleanObject : Object { BooleanObject() {} BooleanObject(bool b) diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index bfe04b33aa..e34b641be9 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -67,7 +67,7 @@ struct Q_QML_EXPORT ObjectIterator namespace Heap { struct ForEachIteratorObject : Object { - ForEachIteratorObject(QV4::ExecutionEngine *engine, QV4::Object *o); + ForEachIteratorObject(QV4::Object *o); ObjectIterator it; Value workArea[2]; }; @@ -85,9 +85,8 @@ protected: }; inline -Heap::ForEachIteratorObject::ForEachIteratorObject(QV4::ExecutionEngine *engine, QV4::Object *o) - : Heap::Object(engine) - , it(engine, workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) +Heap::ForEachIteratorObject::ForEachIteratorObject(QV4::Object *o) + : it(internalClass->engine, workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index b9d8180a26..6b0abc60de 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -228,9 +228,8 @@ static QV4::ReturnedValue LoadProperty(QV4::ExecutionEngine *v4, QObject *object } } -Heap::QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object) - : Heap::Object(engine) - , object(object) +Heap::QObjectWrapper::QObjectWrapper(QObject *object) + : object(object) { } @@ -336,7 +335,7 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje ScopedContext global(scope, scope.engine->qmlContext()); return QV4::QObjectMethod::create(global, object, property->coreIndex); } else if (property->isSignalHandler()) { - QV4::Scoped handler(scope, scope.engine->memoryManager->alloc(engine, object, property->coreIndex)); + QV4::Scoped handler(scope, scope.engine->memoryManager->allocObject(object, property->coreIndex)); QV4::ScopedString connect(scope, engine->newIdentifier(QStringLiteral("connect"))); QV4::ScopedString disconnect(scope, engine->newIdentifier(QStringLiteral("disconnect"))); @@ -684,7 +683,7 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object) { if (engine->jsEngine()) QQmlData::ensurePropertyCache(engine->jsEngine(), object); - return (engine->memoryManager->alloc(engine, object))->asReturnedValue(); + return (engine->memoryManager->allocObject(object))->asReturnedValue(); } QV4::ReturnedValue QObjectWrapper::get(const Managed *m, String *name, bool *hasProperty) @@ -1884,9 +1883,8 @@ void QObjectMethod::markObjects(Heap::Base *that, ExecutionEngine *e) DEFINE_OBJECT_VTABLE(QObjectMethod); -Heap::QmlSignalHandler::QmlSignalHandler(QV4::ExecutionEngine *engine, QObject *object, int signalIndex) - : Heap::Object(engine) - , object(object) +Heap::QmlSignalHandler::QmlSignalHandler(QObject *object, int signalIndex) + : object(object) , signalIndex(signalIndex) { } diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index da24c81f40..bf591dc9b1 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -70,7 +70,7 @@ struct QObjectSlotDispatcher; namespace Heap { struct QObjectWrapper : Object { - QObjectWrapper(QV4::ExecutionEngine *engine, QObject *object); + QObjectWrapper(QObject *object); QPointer object; }; @@ -86,7 +86,7 @@ struct QObjectMethod : FunctionObject { }; struct QmlSignalHandler : Object { - QmlSignalHandler(QV4::ExecutionEngine *engine, QObject *object, int signalIndex); + QmlSignalHandler(QObject *object, int signalIndex); QPointer object; int signalIndex; }; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 9bb3b2b605..7f2f22780e 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -59,7 +59,7 @@ namespace QV4 { namespace Heap { struct CompilationUnitHolder : Object { - inline CompilationUnitHolder(ExecutionEngine *engine, CompiledData::CompilationUnit *unit); + inline CompilationUnitHolder(CompiledData::CompilationUnit *unit); QQmlRefPointer unit; }; @@ -77,9 +77,8 @@ struct CompilationUnitHolder : public Object }; inline -Heap::CompilationUnitHolder::CompilationUnitHolder(ExecutionEngine *engine, CompiledData::CompilationUnit *unit) - : Heap::Object(engine) - , unit(unit) +Heap::CompilationUnitHolder::CompilationUnitHolder(CompiledData::CompilationUnit *unit) + : unit(unit) { } @@ -143,7 +142,7 @@ Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUn vmFunction = compilationUnit ? compilationUnit->linkToEngine(v4) : 0; if (vmFunction) { Scope valueScope(v4); - ScopedObject holder(valueScope, v4->memoryManager->alloc(v4, compilationUnit)); + ScopedObject holder(valueScope, v4->memoryManager->allocObject(compilationUnit)); compilationUnitHolder.set(v4, holder); } } @@ -214,7 +213,7 @@ void Script::parse() isel->setUseFastLookups(false); QQmlRefPointer compilationUnit = isel->compile(); vmFunction = compilationUnit->linkToEngine(v4); - ScopedObject holder(valueScope, v4->memoryManager->alloc(v4, compilationUnit)); + ScopedObject holder(valueScope, v4->memoryManager->allocObject(compilationUnit)); compilationUnitHolder.set(v4, holder); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 23bbcc60e1..36ee848d00 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -207,8 +207,8 @@ namespace Heap { template struct QQmlSequence : Object { - QQmlSequence(QV4::ExecutionEngine *engine, const Container &container); - QQmlSequence(QV4::ExecutionEngine *engine, QObject *object, int propertyIndex); + QQmlSequence(const Container &container); + QQmlSequence(QObject *object, int propertyIndex); mutable Container container; QPointer object; @@ -223,6 +223,7 @@ struct QQmlSequence : public QV4::Object { V4_OBJECT2(QQmlSequence, QV4::Object) Q_MANAGED_TYPE(QmlSequence) + V4_PROTOTYPE(sequencePrototype) V4_NEEDS_DESTROY public: @@ -543,26 +544,24 @@ public: template -Heap::QQmlSequence::QQmlSequence(QV4::ExecutionEngine *engine, const Container &container) - : Heap::Object(engine->emptyClass, engine->sequencePrototype()) - , container(container) +Heap::QQmlSequence::QQmlSequence(const Container &container) + : container(container) , propertyIndex(-1) , isReference(false) { - QV4::Scope scope(engine); + QV4::Scope scope(internalClass->engine); QV4::Scoped > o(scope, this); o->setArrayType(Heap::ArrayData::Custom); o->init(); } template -Heap::QQmlSequence::QQmlSequence(QV4::ExecutionEngine *engine, QObject *object, int propertyIndex) - : Heap::Object(engine->emptyClass, engine->sequencePrototype()) - , object(object) +Heap::QQmlSequence::QQmlSequence(QObject *object, int propertyIndex) + : object(object) , propertyIndex(propertyIndex) , isReference(true) { - QV4::Scope scope(engine); + QV4::Scope scope(internalClass->engine); QV4::Scoped > o(scope, this); o->setArrayType(Heap::ArrayData::Custom); o->loadReference(); @@ -644,7 +643,7 @@ bool SequencePrototype::isSequenceType(int sequenceTypeId) #define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::ScopedObject obj(scope, engine->memoryManager->alloc(engine, object, propertyIndex)); \ + QV4::ScopedObject obj(scope, engine->memoryManager->allocObject(object, propertyIndex)); \ return obj.asReturnedValue(); \ } else @@ -662,7 +661,7 @@ ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int s #define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::ScopedObject obj(scope, engine->memoryManager->alloc(engine, v.value())); \ + QV4::ScopedObject obj(scope, engine->memoryManager->allocObject(v.value())); \ return obj.asReturnedValue(); \ } else diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index b07fccba09..74ee285da4 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -85,7 +85,7 @@ struct TypedArrayCtor : FunctionObject { }; struct TypedArrayPrototype : Object { - inline TypedArrayPrototype(ExecutionEngine *e, TypedArray::Type t); + inline TypedArrayPrototype(TypedArray::Type t); TypedArray::Type type; }; @@ -144,9 +144,8 @@ struct TypedArrayPrototype : Object }; inline -Heap::TypedArrayPrototype::TypedArrayPrototype(ExecutionEngine *e, TypedArray::Type t) - : Heap::Object(e) - , type(t) +Heap::TypedArrayPrototype::TypedArrayPrototype(TypedArray::Type t) + : type(t) { } diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 5eabd43d53..be482b4639 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1059,7 +1059,7 @@ namespace QV4 { namespace Heap { struct QmlIncubatorObject : Object { - QmlIncubatorObject(QV4::ExecutionEngine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous); + QmlIncubatorObject(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous); QScopedPointer incubator; QPointer parent; QV4::Value valuemap; @@ -1374,7 +1374,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) QQmlComponentExtension *e = componentExtension(args->v4engine()); - QV4::Scoped r(scope, v4->memoryManager->alloc(args->v4engine(), mode)); + QV4::Scoped r(scope, v4->memoryManager->allocObject(mode)); QV4::ScopedObject p(scope, e->incubationProto.value()); r->setPrototype(p); @@ -1477,9 +1477,8 @@ QQmlComponentExtension::~QQmlComponentExtension() { } -QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(ExecutionEngine *engine, QQmlIncubator::IncubationMode m) - : QV4::Heap::Object(engine) - , valuemap(QV4::Primitive::undefinedValue()) +QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(QQmlIncubator::IncubationMode m) + : valuemap(QV4::Primitive::undefinedValue()) , statusChanged(QV4::Primitive::undefinedValue()) { incubator.reset(new QQmlComponentIncubator(this, m)); diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 997bc1be4d..0d84c3bb64 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -54,9 +54,8 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(QmlContextWrapper); -Heap::QmlContextWrapper::QmlContextWrapper(QV4::ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext) - : Heap::Object(engine) - , readOnly(true) +Heap::QmlContextWrapper::QmlContextWrapper(QQmlContextData *context, QObject *scopeObject, bool ownsContext) + : readOnly(true) , ownsContext(ownsContext) , isNullWrapper(false) , context(context) @@ -74,7 +73,7 @@ ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData * { Scope valueScope(v4); - Scoped w(valueScope, v4->memoryManager->alloc(v4, ctxt, scope)); + Scoped w(valueScope, v4->memoryManager->allocObject(ctxt, scope)); return w.asReturnedValue(); } @@ -88,7 +87,7 @@ ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url) context->isInternal = true; context->isJSContext = true; - Scoped w(scope, v4->memoryManager->alloc(v4, context, (QObject*)0, true)); + Scoped w(scope, v4->memoryManager->allocObject(context, (QObject*)0, true)); w->d()->isNullWrapper = true; return w.asReturnedValue(); } diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h index 192df9aed6..9dd71b708f 100644 --- a/src/qml/qml/qqmlcontextwrapper_p.h +++ b/src/qml/qml/qqmlcontextwrapper_p.h @@ -66,7 +66,7 @@ struct QmlContextWrapper; namespace Heap { struct QmlContextWrapper : Object { - QmlContextWrapper(ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false); + QmlContextWrapper(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false); ~QmlContextWrapper(); bool readOnly; bool ownsContext; diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index d09f4df54c..942f4f79e7 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -45,10 +45,9 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(QmlListWrapper); -Heap::QmlListWrapper::QmlListWrapper(ExecutionEngine *engine) - : Heap::Object(engine) +Heap::QmlListWrapper::QmlListWrapper() { - QV4::Scope scope(engine); + QV4::Scope scope(internalClass->engine); QV4::ScopedObject o(scope, this); o->setArrayType(Heap::ArrayData::Custom); } @@ -64,7 +63,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, i Scope scope(engine); - Scoped r(scope, engine->memoryManager->alloc(engine)); + Scoped r(scope, engine->memoryManager->allocObject()); r->d()->object = object; r->d()->propertyType = propType; void *args[] = { &r->d()->property, 0 }; @@ -76,7 +75,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, const QQmlListProp { Scope scope(engine); - Scoped r(scope, engine->memoryManager->alloc(engine)); + Scoped r(scope, engine->memoryManager->allocObject()); r->d()->object = prop.object; r->d()->property = prop; r->d()->propertyType = propType; diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index ff006d4302..6df3d83b2e 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -62,7 +62,7 @@ namespace QV4 { namespace Heap { struct QmlListWrapper : Object { - QmlListWrapper(ExecutionEngine *engine); + QmlListWrapper(); ~QmlListWrapper(); QPointer object; QQmlListProperty property; diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 7f49798da6..af7b394a1b 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -806,7 +806,7 @@ QV4::ReturnedValue QQmlLocale::wrap(ExecutionEngine *v4, const QLocale &locale) { QV4::Scope scope(v4); QV4LocaleDataDeletable *d = localeV4Data(scope.engine); - QV4::Scoped wrapper(scope, v4->memoryManager->alloc(v4)); + QV4::Scoped wrapper(scope, v4->memoryManager->allocObject()); wrapper->d()->locale = locale; QV4::ScopedObject p(scope, d->prototype.value()); wrapper->setPrototype(p); diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index cb9fe9bbef..3d2ed307d1 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -125,7 +125,7 @@ namespace QV4 { namespace Heap { struct QQmlLocaleData : Object { - inline QQmlLocaleData(ExecutionEngine *engine); + inline QQmlLocaleData() {} QLocale locale; }; @@ -175,11 +175,6 @@ struct QQmlLocaleData : public QV4::Object static QV4::ReturnedValue method_get_pmText(QV4::CallContext *ctx); }; -Heap::QQmlLocaleData::QQmlLocaleData(ExecutionEngine *engine) - : Heap::Object(engine) -{ -} - } QT_END_NAMESPACE diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 1145f1b64f..d70a4019b2 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -48,12 +48,8 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(QmlTypeWrapper); -Heap::QmlTypeWrapper::QmlTypeWrapper(ExecutionEngine *engine) - : Heap::Object(engine) - , mode(IncludeEnums) - , type(Q_NULLPTR) - , typeNamespace(Q_NULLPTR) - , importNamespace(Q_NULLPTR) +Heap::QmlTypeWrapper::QmlTypeWrapper() + : mode(IncludeEnums) { } @@ -103,7 +99,7 @@ ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, Q Q_ASSERT(t); Scope scope(engine); - Scoped w(scope, engine->memoryManager->alloc(engine)); + Scoped w(scope, engine->memoryManager->allocObject()); w->d()->mode = mode; w->d()->object = o; w->d()->type = t; return w.asReturnedValue(); } @@ -117,7 +113,7 @@ ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, Q Q_ASSERT(importNamespace); Scope scope(engine); - Scoped w(scope, engine->memoryManager->alloc(engine)); + Scoped w(scope, engine->memoryManager->allocObject()); w->d()->mode = mode; w->d()->object = o; w->d()->typeNamespace = t; w->d()->importNamespace = importNamespace; t->addref(); return w.asReturnedValue(); diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h index 14741a5bad..e67b457c59 100644 --- a/src/qml/qml/qqmltypewrapper_p.h +++ b/src/qml/qml/qqmltypewrapper_p.h @@ -66,7 +66,7 @@ struct QmlTypeWrapper : Object { ExcludeEnums }; - QmlTypeWrapper(QV4::ExecutionEngine *engine); + QmlTypeWrapper(); ~QmlTypeWrapper(); TypeNameMode mode; QPointer object; diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index f9dab64856..004797a10c 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -55,7 +55,7 @@ namespace Heap { struct QQmlValueTypeReference : QQmlValueTypeWrapper { - QQmlValueTypeReference(ExecutionEngine *engine); + QQmlValueTypeReference() {} QPointer object; int property; }; @@ -77,11 +77,6 @@ DEFINE_OBJECT_VTABLE(QV4::QQmlValueTypeReference); using namespace QV4; -Heap::QQmlValueTypeWrapper::QQmlValueTypeWrapper(ExecutionEngine *engine) - : Heap::Object(engine) -{ -} - Heap::QQmlValueTypeWrapper::~QQmlValueTypeWrapper() { if (gadgetPtr) { @@ -107,11 +102,6 @@ QVariant Heap::QQmlValueTypeWrapper::toVariant() const } -Heap::QQmlValueTypeReference::QQmlValueTypeReference(ExecutionEngine *engine) - : Heap::QQmlValueTypeWrapper(engine) -{ -} - bool QQmlValueTypeReference::readReferenceValue() const { if (!d()->object) @@ -178,7 +168,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj Scope scope(engine); initProto(engine); - Scoped r(scope, engine->memoryManager->alloc(engine)); + Scoped r(scope, engine->memoryManager->allocObject()); ScopedObject proto(scope, engine->valueTypeWrapperPrototype()); r->setPrototype(proto); r->d()->object = object; r->d()->property = property; @@ -193,7 +183,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria Scope scope(engine); initProto(engine); - Scoped r(scope, engine->memoryManager->alloc(engine)); + Scoped r(scope, engine->memoryManager->allocObject()); ScopedObject proto(scope, engine->valueTypeWrapperPrototype()); r->setPrototype(proto); r->d()->propertyCache = QJSEnginePrivate::get(engine)->cache(metaObject); diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index 5f0edfb71d..3db5493234 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -61,7 +61,7 @@ namespace QV4 { namespace Heap { struct QQmlValueTypeWrapper : Object { - QQmlValueTypeWrapper(ExecutionEngine *engine); + QQmlValueTypeWrapper() {} ~QQmlValueTypeWrapper(); QQmlRefPointer propertyCache; mutable void *gadgetPtr; diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index c131daab32..8666c0db01 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -170,7 +170,7 @@ public: namespace Heap { struct NamedNodeMap : Object { - NamedNodeMap(ExecutionEngine *engine, NodeImpl *data, const QList &list); + NamedNodeMap(NodeImpl *data, const QList &list); ~NamedNodeMap() { if (d) d->release(); @@ -180,7 +180,7 @@ struct NamedNodeMap : Object { }; struct NodeList : Object { - NodeList(ExecutionEngine *engine, NodeImpl *data); + NodeList(NodeImpl *data); ~NodeList() { if (d) d->release(); @@ -189,11 +189,11 @@ struct NodeList : Object { }; struct NodePrototype : Object { - NodePrototype(ExecutionEngine *engine); + NodePrototype(); }; struct Node : Object { - Node(ExecutionEngine *engine, NodeImpl *data); + Node(NodeImpl *data); ~Node() { if (d) d->release(); @@ -217,9 +217,8 @@ public: static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty); }; -Heap::NamedNodeMap::NamedNodeMap(ExecutionEngine *engine, NodeImpl *data, const QList &list) - : Heap::Object(engine) - , list(list) +Heap::NamedNodeMap::NamedNodeMap(NodeImpl *data, const QList &list) + : list(list) , d(data) { if (d) @@ -243,9 +242,8 @@ public: }; -Heap::NodeList::NodeList(ExecutionEngine *engine, NodeImpl *data) - : Heap::Object(engine) - , d(data) +Heap::NodeList::NodeList(NodeImpl *data) + : d(data) { if (d) d->addref(); @@ -285,10 +283,9 @@ public: }; -Heap::NodePrototype::NodePrototype(ExecutionEngine *engine) - : Heap::Object(engine) +Heap::NodePrototype::NodePrototype() { - Scope scope(engine); + Scope scope(internalClass->engine); ScopedObject o(scope, this); o->defineAccessorProperty(QStringLiteral("nodeName"), QV4::NodePrototype::method_get_nodeName, 0); @@ -323,9 +320,8 @@ private: Node(const Node &o); }; -Heap::Node::Node(ExecutionEngine *engine, NodeImpl *data) - : Heap::Object(engine) - , d(data) +Heap::Node::Node(NodeImpl *data) + : d(data) { if (d) d->addref(); @@ -584,7 +580,7 @@ ReturnedValue NodePrototype::getProto(ExecutionEngine *v4) Scope scope(v4); QQmlXMLHttpRequestData *d = xhrdata(v4); if (d->nodePrototype.isUndefined()) { - ScopedObject p(scope, v4->memoryManager->alloc(v4)); + ScopedObject p(scope, v4->memoryManager->allocObject()); d->nodePrototype.set(v4, p); v4->v8Engine->freezeObject(p); } @@ -595,7 +591,7 @@ ReturnedValue Node::create(ExecutionEngine *v4, NodeImpl *data) { Scope scope(v4); - Scoped instance(scope, v4->memoryManager->alloc(v4, data)); + Scoped instance(scope, v4->memoryManager->allocObject(data)); ScopedObject p(scope); switch (data->type) { @@ -863,7 +859,7 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data) return Encode::null(); } - ScopedObject instance(scope, v4->memoryManager->alloc(v4, document)); + ScopedObject instance(scope, v4->memoryManager->allocObject(document)); ScopedObject p(scope); instance->setPrototype((p = Document::prototype(v4))); return instance.asReturnedValue(); @@ -916,7 +912,7 @@ ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasPropert ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QList &list) { - return (v4->memoryManager->alloc(v4, data, list))->asReturnedValue(); + return (v4->memoryManager->allocObject(data, list))->asReturnedValue(); } ReturnedValue NodeList::getIndexed(const Managed *m, uint index, bool *hasProperty) @@ -950,7 +946,7 @@ ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty) ReturnedValue NodeList::create(ExecutionEngine *v4, NodeImpl *data) { - return (v4->memoryManager->alloc(v4, data))->asReturnedValue(); + return (v4->memoryManager->allocObject(data))->asReturnedValue(); } ReturnedValue Document::method_documentElement(CallContext *ctx) @@ -1588,7 +1584,7 @@ namespace QV4 { namespace Heap { struct QQmlXMLHttpRequestWrapper : Object { - QQmlXMLHttpRequestWrapper(ExecutionEngine *engine, QQmlXMLHttpRequest *request); + QQmlXMLHttpRequestWrapper(QQmlXMLHttpRequest *request); ~QQmlXMLHttpRequestWrapper() { delete request; } @@ -1609,9 +1605,8 @@ struct QQmlXMLHttpRequestWrapper : public Object V4_NEEDS_DESTROY }; -Heap::QQmlXMLHttpRequestWrapper::QQmlXMLHttpRequestWrapper(ExecutionEngine *engine, QQmlXMLHttpRequest *request) - : Heap::Object(engine) - , request(request) +Heap::QQmlXMLHttpRequestWrapper::QQmlXMLHttpRequestWrapper(QQmlXMLHttpRequest *request) + : request(request) { } @@ -1632,7 +1627,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject return scope.engine->throwTypeError(); QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(scope.engine->v8Engine->networkAccessManager()); - Scoped w(scope, scope.engine->memoryManager->alloc(scope.engine, r)); + Scoped w(scope, scope.engine->memoryManager->allocObject(r)); ScopedObject proto(scope, ctor->d()->proto); w->setPrototype(proto); return w.asReturnedValue(); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 2d174975ec..3242833e22 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -80,10 +80,9 @@ struct StaticQtMetaObject : public QObject { return &staticQtMetaObject; } }; -Heap::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) - : Heap::Object(v4) +Heap::QtObject::QtObject(QQmlEngine *qmlEngine) { - Scope scope(v4); + Scope scope(internalClass->engine); ScopedObject o(scope, this); // Set all the enums from the "Qt" namespace @@ -93,11 +92,11 @@ Heap::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) { QMetaEnum enumerator = qtMetaObject->enumerator(ii); for (int jj = 0; jj < enumerator.keyCount(); ++jj) { - o->put((str = v4->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); + o->put((str = scope.engine->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj)))); } } - o->put((str = v4->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0))); - o->put((str = v4->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1))); + o->put((str = scope.engine->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0))); + o->put((str = scope.engine->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1))); o->defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include); o->defineDefaultProperty(QStringLiteral("isQtObject"), QV4::QtObject::method_isQtObject); @@ -1315,10 +1314,9 @@ ReturnedValue QtObject::method_get_styleHints(CallContext *ctx) } -QV4::Heap::ConsoleObject::ConsoleObject(ExecutionEngine *v4) - : Heap::Object(v4) +QV4::Heap::ConsoleObject::ConsoleObject() { - QV4::Scope scope(v4); + QV4::Scope scope(internalClass->engine); QV4::ScopedObject o(scope, this); o->defineDefaultProperty(QStringLiteral("debug"), QV4::ConsoleObject::method_log); @@ -1609,10 +1607,10 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) globalObject->defineDefaultProperty(QStringLiteral("print"), ConsoleObject::method_log); globalObject->defineDefaultProperty(QStringLiteral("gc"), method_gc); - ScopedObject console(scope, v4->memoryManager->alloc(v4)); + ScopedObject console(scope, v4->memoryManager->allocObject()); globalObject->defineDefaultProperty(QStringLiteral("console"), console); - ScopedObject qt(scope, v4->memoryManager->alloc(v4, qmlEngine)); + ScopedObject qt(scope, v4->memoryManager->allocObject(qmlEngine)); globalObject->defineDefaultProperty(QStringLiteral("Qt"), qt); // string prototype extension diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index bdd53fe601..bb05376fc0 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -58,13 +58,13 @@ namespace QV4 { namespace Heap { struct QtObject : Object { - QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine); + QtObject(QQmlEngine *qmlEngine); QObject *platform; QObject *application; }; struct ConsoleObject : Object { - ConsoleObject(ExecutionEngine *engine); + ConsoleObject(); }; struct QQmlBindingFunction : FunctionObject { diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index d384a11034..f2de911725 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -64,13 +64,13 @@ struct DelegateModelGroupFunction : FunctionObject { }; struct QQmlDelegateModelGroupChange : Object { - QQmlDelegateModelGroupChange(QV4::ExecutionEngine *engine); + QQmlDelegateModelGroupChange() {} QQmlChangeSet::Change change; }; struct QQmlDelegateModelGroupChangeArray : Object { - QQmlDelegateModelGroupChangeArray(QV4::ExecutionEngine *engine, const QVector &changes); + QQmlDelegateModelGroupChangeArray(const QVector &changes); QVector changes; }; @@ -2488,7 +2488,7 @@ QQmlV4Handle QQmlDelegateModelGroup::get(int index) QV8Engine *v8 = model->m_cacheMetaType->v8Engine; QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8); QV4::Scope scope(v4); - QV4::ScopedObject o(scope, v4->memoryManager->alloc(v4, cacheItem)); + QV4::ScopedObject o(scope, v4->memoryManager->allocObject(cacheItem)); QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value()); o->setPrototype(p); ++cacheItem->scriptRef; @@ -3233,7 +3233,7 @@ struct QQmlDelegateModelGroupChange : QV4::Object V4_OBJECT2(QQmlDelegateModelGroupChange, QV4::Object) static QV4::Heap::QQmlDelegateModelGroupChange *create(QV4::ExecutionEngine *e) { - return e->memoryManager->alloc(e); + return e->memoryManager->allocObject(); } static QV4::ReturnedValue method_get_index(QV4::CallContext *ctx) { @@ -3261,11 +3261,6 @@ struct QQmlDelegateModelGroupChange : QV4::Object } }; -QV4::Heap::QQmlDelegateModelGroupChange::QQmlDelegateModelGroupChange(QV4::ExecutionEngine *engine) - : QV4::Heap::Object(engine) -{ -} - DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChange); struct QQmlDelegateModelGroupChangeArray : public QV4::Object @@ -3275,7 +3270,7 @@ struct QQmlDelegateModelGroupChangeArray : public QV4::Object public: static QV4::Heap::QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector &changes) { - return engine->memoryManager->alloc(engine, changes); + return engine->memoryManager->allocObject(changes); } quint32 count() const { return d()->changes.count(); } @@ -3321,11 +3316,10 @@ public: } }; -QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(QV4::ExecutionEngine *engine, const QVector &changes) - : QV4::Heap::Object(engine) - , changes(changes) +QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(const QVector &changes) + : changes(changes) { - QV4::Scope scope(engine); + QV4::Scope scope(internalClass->engine); QV4::ScopedObject o(scope, this); o->setArrayType(QV4::Heap::ArrayData::Custom); } diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 5c28021c0e..3a19163cbd 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -154,7 +154,7 @@ protected: namespace QV4 { namespace Heap { struct QQmlDelegateModelItemObject : Object { - inline QQmlDelegateModelItemObject(QV4::ExecutionEngine *engine, QQmlDelegateModelItem *item); + inline QQmlDelegateModelItemObject(QQmlDelegateModelItem *item); ~QQmlDelegateModelItemObject(); QQmlDelegateModelItem *item; }; @@ -168,9 +168,8 @@ struct QQmlDelegateModelItemObject : QV4::Object V4_NEEDS_DESTROY }; -QV4::Heap::QQmlDelegateModelItemObject::QQmlDelegateModelItemObject(QV4::ExecutionEngine *engine, QQmlDelegateModelItem *item) - : QV4::Heap::Object(engine) - , item(item) +QV4::Heap::QQmlDelegateModelItemObject::QQmlDelegateModelItemObject(QQmlDelegateModelItem *item) + : item(item) { } diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index da7adf4e0e..a4c0f7043f 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -2276,7 +2276,7 @@ QQmlV4Handle QQmlListModel::get(int index) const result = QV4::QObjectWrapper::wrap(scope.engine, object); } else { QObject *object = m_listModel->getOrCreateModelObject(const_cast(this), index); - result = scope.engine->memoryManager->alloc(scope.engine, object, const_cast(this), index); + result = scope.engine->memoryManager->allocObject(object, const_cast(this), index); } } diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index bd0f028e7a..d7e0defaec 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -155,8 +155,8 @@ namespace QV4 { namespace Heap { struct ModelObject : public QObjectWrapper { - ModelObject(QV4::ExecutionEngine *engine, QObject *object, QQmlListModel *model, int elementIndex) - : QObjectWrapper(engine, object) + ModelObject(QObject *object, QQmlListModel *model, int elementIndex) + : QObjectWrapper(object) , m_model(model) , m_elementIndex(elementIndex) {} diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 68f0871486..29398ff98c 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -428,7 +428,7 @@ public: } QV4::Scope scope(v4); QV4::ScopedObject proto(scope, type->prototype.value()); - QV4::ScopedObject o(scope, proto->engine()->memoryManager->alloc(proto->engine(), this)); + QV4::ScopedObject o(scope, proto->engine()->memoryManager->allocObject(this)); o->setPrototype(proto); ++scriptRef; return o.asReturnedValue(); @@ -606,7 +606,7 @@ public: { QQmlAdaptorModelEngineData *data = engineData(v4); QV4::Scope scope(v4); - QV4::ScopedObject o(scope, v4->memoryManager->alloc(v4, this)); + QV4::ScopedObject o(scope, v4->memoryManager->allocObject(this)); QV4::ScopedObject p(scope, data->listItemProto.value()); o->setPrototype(p); ++scriptRef; -- cgit v1.2.3