From: Simon Hausmann Date: Fri, 13 Jun 2014 12:30:03 +0000 (+0200) Subject: Change the object allocation scheme X-Git-Tag: v5.3.99+beta1~260 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b393c405b7568e80628bc99501a9c53bbd0e678d;p=platform%2Fupstream%2Fqtdeclarative.git Change the object allocation scheme Instead of allocating the data directly, centralize the object and its ::Data allocation in one place in the memory manager. This is in preparation for additional pointer indirection later. Change-Id: I7880e1e7354b3258b6a8965be378cd09c9467d25 Reviewed-by: Lars Knoll --- diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 651b8d4..d7ef00b 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -137,10 +137,10 @@ public: V4_OBJECT - static Data *create(QV8Engine *engine) + static QQmlSqlDatabaseWrapper *create(QV8Engine *engine) { QV4::ExecutionEngine *e = QV8Engine::getV4(engine); - return new (e) Data(e); + return e->memoryManager->alloc(e); } ~QQmlSqlDatabaseWrapper() { diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp index cfe99af..4046c9d 100644 --- a/src/particles/qquickv4particledata.cpp +++ b/src/particles/qquickv4particledata.cpp @@ -520,7 +520,7 @@ QQuickV4ParticleData::QQuickV4ParticleData(QV8Engine* engine, QQuickParticleData QV8ParticleDataDeletable *d = particleV8Data(engine); QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); - QV4::ScopedObject o(scope, new (v4) QV4ParticleData::Data(v4, datum)); + QV4::ScopedObject o(scope, v4->memoryManager->alloc(v4, datum)); QV4::ScopedObject p(scope, d->proto.value()); o->setPrototype(p.getPointer()); m_v4Value = o; diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 48bf0b8..62d5859 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -89,20 +89,20 @@ HeapObject *ExecutionContext::newCallContext(FunctionObject *function, CallData return c; } -HeapObject *ExecutionContext::newWithContext(Object *with) +WithContext *ExecutionContext::newWithContext(Object *with) { - return new (d()->engine) WithContext::Data(d()->engine, with); + return d()->engine->memoryManager->alloc(d()->engine, with); } -HeapObject *ExecutionContext::newCatchContext(String *exceptionVarName, const ValueRef exceptionValue) +CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const ValueRef exceptionValue) { - return new (d()->engine) CatchContext::Data(d()->engine, exceptionVarName, exceptionValue); + return d()->engine->memoryManager->alloc(d()->engine, exceptionVarName, exceptionValue); } -HeapObject *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml) +CallContext *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml) { - CallContext::Data *c = reinterpret_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0))); - new (c) CallContext::Data(d()->engine, qml, f); + CallContext *c = reinterpret_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0))); + new (c->d()) CallContext::Data(d()->engine, qml, f); return c; } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index fe05774..10a86dd 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -152,9 +152,9 @@ struct Q_QML_EXPORT ExecutionContext : public Managed } HeapObject *newCallContext(FunctionObject *f, CallData *callData); - HeapObject *newWithContext(Object *with); - HeapObject *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue); - HeapObject *newQmlContext(FunctionObject *f, Object *qml); + WithContext *newWithContext(Object *with); + CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue); + CallContext *newQmlContext(FunctionObject *f, Object *qml); void createMutableBinding(String *name, bool deletable); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index f0e52f7..ea31241 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -71,6 +71,7 @@ #include "qv4memberdata_p.h" #include +#include #ifdef V4_ENABLE_JIT #include "qv4isel_masm_p.h" @@ -258,13 +259,13 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) memberDataClass = InternalClass::create(this, MemberData::staticVTable(), 0); - ScopedObject objectPrototype(scope, new (this) ObjectPrototype::Data(InternalClass::create(this, ObjectPrototype::staticVTable(), 0))); + ScopedObject objectPrototype(scope, memoryManager->alloc(InternalClass::create(this, ObjectPrototype::staticVTable(), 0))); objectClass = InternalClass::create(this, Object::staticVTable(), objectPrototype); Q_ASSERT(objectClass->vtable == Object::staticVTable()); arrayClass = InternalClass::create(this, ArrayObject::staticVTable(), objectPrototype); arrayClass = arrayClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable); - ScopedObject arrayPrototype(scope, new (this) ArrayPrototype::Data(arrayClass)); + ScopedObject arrayPrototype(scope, memoryManager->alloc(arrayClass)); arrayClass = arrayClass->changePrototype(arrayPrototype); simpleArrayDataClass = InternalClass::create(this, SimpleArrayData::staticVTable(), 0); @@ -279,73 +280,73 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) initRootContext(); - ScopedObject stringPrototype(scope, new (this) StringPrototype::Data(InternalClass::create(this, StringPrototype::staticVTable(), objectPrototype))); + ScopedObject stringPrototype(scope, memoryManager->alloc(InternalClass::create(this, StringPrototype::staticVTable(), objectPrototype))); stringObjectClass = InternalClass::create(this, String::staticVTable(), stringPrototype); - ScopedObject numberPrototype(scope, new (this) NumberPrototype::Data(InternalClass::create(this, NumberPrototype::staticVTable(), objectPrototype))); + ScopedObject numberPrototype(scope, memoryManager->alloc(InternalClass::create(this, NumberPrototype::staticVTable(), objectPrototype))); numberClass = InternalClass::create(this, NumberObject::staticVTable(), numberPrototype); - ScopedObject booleanPrototype(scope, new (this) BooleanPrototype::Data(InternalClass::create(this, BooleanPrototype::staticVTable(), objectPrototype))); + ScopedObject booleanPrototype(scope, memoryManager->alloc(InternalClass::create(this, BooleanPrototype::staticVTable(), objectPrototype))); booleanClass = InternalClass::create(this, BooleanObject::staticVTable(), booleanPrototype); - ScopedObject datePrototype(scope, new (this) DatePrototype::Data(InternalClass::create(this, DatePrototype::staticVTable(), objectPrototype))); + ScopedObject datePrototype(scope, memoryManager->alloc(InternalClass::create(this, DatePrototype::staticVTable(), objectPrototype))); dateClass = InternalClass::create(this, DateObject::staticVTable(), datePrototype); InternalClass *functionProtoClass = InternalClass::create(this, FunctionObject::staticVTable(), objectPrototype); uint index; functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index); Q_ASSERT(index == FunctionObject::Index_Prototype); - ScopedObject functionPrototype(scope, new (this) FunctionPrototype::Data(functionProtoClass)); + ScopedObject functionPrototype(scope, memoryManager->alloc(functionProtoClass)); functionClass = InternalClass::create(this, FunctionObject::staticVTable(), functionPrototype); functionClass = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index); Q_ASSERT(index == FunctionObject::Index_Prototype); protoClass = objectClass->addMember(id_constructor, Attr_NotEnumerable, &index); Q_ASSERT(index == FunctionObject::Index_ProtoConstructor); - Scoped regExpPrototype(scope, new (this) RegExpPrototype::Data(InternalClass::create(this, RegExpPrototype::staticVTable(), objectPrototype))); + Scoped regExpPrototype(scope, memoryManager->alloc(InternalClass::create(this, RegExpPrototype::staticVTable(), objectPrototype))); regExpClass = InternalClass::create(this, RegExpObject::staticVTable(), regExpPrototype.getPointer()); regExpExecArrayClass = arrayClass->addMember(id_index, Attr_Data, &index); Q_ASSERT(index == RegExpObject::Index_ArrayIndex); regExpExecArrayClass = regExpExecArrayClass->addMember(id_input, Attr_Data, &index); Q_ASSERT(index == RegExpObject::Index_ArrayInput); - ScopedObject errorPrototype(scope, new (this) ErrorPrototype::Data(InternalClass::create(this, ErrorObject::staticVTable(), objectPrototype))); + ScopedObject errorPrototype(scope, memoryManager->alloc(InternalClass::create(this, ErrorObject::staticVTable(), objectPrototype))); errorClass = InternalClass::create(this, ErrorObject::staticVTable(), errorPrototype); - ScopedObject evalErrorPrototype(scope, new (this) EvalErrorPrototype::Data(errorClass)); + ScopedObject evalErrorPrototype(scope, memoryManager->alloc(errorClass)); evalErrorClass = InternalClass::create(this, EvalErrorObject::staticVTable(), evalErrorPrototype); - ScopedObject rangeErrorPrototype(scope, new (this) RangeErrorPrototype::Data(errorClass)); + ScopedObject rangeErrorPrototype(scope, memoryManager->alloc(errorClass)); rangeErrorClass = InternalClass::create(this, RangeErrorObject::staticVTable(), rangeErrorPrototype); - ScopedObject referenceErrorPrototype(scope, new (this) ReferenceErrorPrototype::Data(errorClass)); + ScopedObject referenceErrorPrototype(scope, memoryManager->alloc(errorClass)); referenceErrorClass = InternalClass::create(this, ReferenceErrorObject::staticVTable(), referenceErrorPrototype); - ScopedObject syntaxErrorPrototype(scope, new (this) SyntaxErrorPrototype::Data(errorClass)); + ScopedObject syntaxErrorPrototype(scope, memoryManager->alloc(errorClass)); syntaxErrorClass = InternalClass::create(this, SyntaxErrorObject::staticVTable(), syntaxErrorPrototype); - ScopedObject typeErrorPrototype(scope, new (this) TypeErrorPrototype::Data(errorClass)); + ScopedObject typeErrorPrototype(scope, memoryManager->alloc(errorClass)); typeErrorClass = InternalClass::create(this, TypeErrorObject::staticVTable(), typeErrorPrototype); - ScopedObject uRIErrorPrototype(scope, new (this) URIErrorPrototype::Data(errorClass)); + ScopedObject uRIErrorPrototype(scope, memoryManager->alloc(errorClass)); uriErrorClass = InternalClass::create(this, URIErrorObject::staticVTable(), uRIErrorPrototype); - ScopedObject variantPrototype(scope, new (this) VariantPrototype::Data(InternalClass::create(this, VariantPrototype::staticVTable(), objectPrototype))); + ScopedObject variantPrototype(scope, memoryManager->alloc(InternalClass::create(this, VariantPrototype::staticVTable(), objectPrototype))); variantClass = InternalClass::create(this, VariantObject::staticVTable(), variantPrototype); Q_ASSERT(variantClass->prototype == variantPrototype); Q_ASSERT(variantPrototype->internalClass()->prototype == objectPrototype); - sequencePrototype = ScopedValue(scope, new (this) SequencePrototype::Data(arrayClass)); - - objectCtor = static_cast(new (this) ObjectCtor::Data(rootContext)); - stringCtor = static_cast(new (this) StringCtor::Data(rootContext)); - numberCtor = static_cast(new (this) NumberCtor::Data(rootContext)); - booleanCtor = static_cast(new (this) BooleanCtor::Data(rootContext)); - arrayCtor = static_cast(new (this) ArrayCtor::Data(rootContext)); - functionCtor = static_cast(new (this) FunctionCtor::Data(rootContext)); - dateCtor = static_cast(new (this) DateCtor::Data(rootContext)); - regExpCtor = static_cast(new (this) RegExpCtor::Data(rootContext)); - errorCtor = static_cast(new (this) ErrorCtor::Data(rootContext)); - evalErrorCtor = static_cast(new (this) EvalErrorCtor::Data(rootContext)); - rangeErrorCtor = static_cast(new (this) RangeErrorCtor::Data(rootContext)); - referenceErrorCtor = static_cast(new (this) ReferenceErrorCtor::Data(rootContext)); - syntaxErrorCtor = static_cast(new (this) SyntaxErrorCtor::Data(rootContext)); - typeErrorCtor = static_cast(new (this) TypeErrorCtor::Data(rootContext)); - uRIErrorCtor = static_cast(new (this) URIErrorCtor::Data(rootContext)); + sequencePrototype = ScopedValue(scope, memoryManager->alloc(arrayClass)); + + objectCtor = memoryManager->alloc(rootContext); + stringCtor = memoryManager->alloc(rootContext); + numberCtor = memoryManager->alloc(rootContext); + booleanCtor = memoryManager->alloc(rootContext); + arrayCtor = memoryManager->alloc(rootContext); + functionCtor = memoryManager->alloc(rootContext); + dateCtor = memoryManager->alloc(rootContext); + regExpCtor = memoryManager->alloc(rootContext); + errorCtor = memoryManager->alloc(rootContext); + evalErrorCtor = memoryManager->alloc(rootContext); + rangeErrorCtor = memoryManager->alloc(rootContext); + referenceErrorCtor = memoryManager->alloc(rootContext); + syntaxErrorCtor = memoryManager->alloc(rootContext); + typeErrorCtor = memoryManager->alloc(rootContext); + uRIErrorCtor = memoryManager->alloc(rootContext); static_cast(objectPrototype.getPointer())->init(this, objectCtor.asObject()); static_cast(stringPrototype.getPointer())->init(this, stringCtor.asObject()); @@ -390,15 +391,15 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) globalObject->defineDefaultProperty(QStringLiteral("TypeError"), typeErrorCtor); globalObject->defineDefaultProperty(QStringLiteral("URIError"), uRIErrorCtor); ScopedObject o(scope); - globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = new (this) MathObject::Data(QV4::InternalClass::create(this, MathObject::staticVTable(), objectPrototype)))); - globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = new (this) JsonObject::Data(QV4::InternalClass::create(this, JsonObject::staticVTable(), objectPrototype)))); + globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = memoryManager->alloc(QV4::InternalClass::create(this, MathObject::staticVTable(), objectPrototype)))); + globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = memoryManager->alloc(QV4::InternalClass::create(this, JsonObject::staticVTable(), objectPrototype)))); globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Primitive::undefinedValue()); globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits::quiet_NaN())); globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY)); - evalFunction = Scoped(scope, new (this) EvalFunction::Data(rootContext)); + evalFunction = Scoped(scope, memoryManager->alloc(rootContext)); globalObject->defineDefaultProperty(QStringLiteral("eval"), (o = evalFunction)); globalObject->defineDefaultProperty(QStringLiteral("parseInt"), GlobalFunctions::method_parseInt, 2); @@ -477,32 +478,32 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other) ExecutionContext *ExecutionEngine::pushGlobalContext() { - GlobalContext::Data *g = new (this) GlobalContext::Data(this); - g->callData = rootContext->d()->callData; + GlobalContext *g = memoryManager->alloc(this); + g->d()->callData = rootContext->d()->callData; - Q_ASSERT(currentContext() == reinterpret_cast(g)); - return reinterpret_cast(g); + Q_ASSERT(currentContext() == g); + return g; } Returned *ExecutionEngine::newObject() { Scope scope(this); - ScopedObject object(scope, new (this) Object::Data(this)); + ScopedObject object(scope, memoryManager->alloc(this)); return object->asReturned(); } Returned *ExecutionEngine::newObject(InternalClass *internalClass) { Scope scope(this); - ScopedObject object(scope, new (this) Object::Data(internalClass)); + ScopedObject object(scope, memoryManager->alloc(internalClass)); return object->asReturned(); } Returned *ExecutionEngine::newString(const QString &s) { Scope scope(this); - return ScopedString(scope, new (this) String::Data(this, s))->asReturned(); + return ScopedString(scope, memoryManager->alloc(this, s))->asReturned(); } String *ExecutionEngine::newIdentifier(const QString &text) @@ -513,28 +514,28 @@ String *ExecutionEngine::newIdentifier(const QString &text) Returned *ExecutionEngine::newStringObject(const ValueRef value) { Scope scope(this); - Scoped object(scope, new (this) StringObject::Data(this, value)); + Scoped object(scope, memoryManager->alloc(this, value)); return object->asReturned(); } Returned *ExecutionEngine::newNumberObject(const ValueRef value) { Scope scope(this); - Scoped object(scope, new (this) NumberObject::Data(this, value)); + Scoped object(scope, memoryManager->alloc(this, value)); return object->asReturned(); } Returned *ExecutionEngine::newBooleanObject(const ValueRef value) { Scope scope(this); - ScopedObject object(scope, new (this) BooleanObject::Data(this, value)); + ScopedObject object(scope, memoryManager->alloc(this, value)); return object->asReturned(); } Returned *ExecutionEngine::newArrayObject(int count) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(this)); + ScopedArrayObject object(scope, memoryManager->alloc(this)); if (count) { if (count < 0x1000) @@ -547,14 +548,14 @@ Returned *ExecutionEngine::newArrayObject(int count) Returned *ExecutionEngine::newArrayObject(const QStringList &list) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(this, list)); + ScopedArrayObject object(scope, memoryManager->alloc(this, list)); return object->asReturned(); } Returned *ExecutionEngine::newArrayObject(InternalClass *ic) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(ic)); + ScopedArrayObject object(scope, memoryManager->alloc(ic)); return object->asReturned(); } @@ -562,14 +563,14 @@ Returned *ExecutionEngine::newArrayObject(InternalClass *ic) Returned *ExecutionEngine::newDateObject(const ValueRef value) { Scope scope(this); - Scoped object(scope, new (this) DateObject::Data(this, value)); + Scoped object(scope, memoryManager->alloc(this, value)); return object->asReturned(); } Returned *ExecutionEngine::newDateObject(const QDateTime &dt) { Scope scope(this); - Scoped object(scope, new (this) DateObject::Data(this, dt)); + Scoped object(scope, memoryManager->alloc(this, dt)); return object->asReturned(); } @@ -591,21 +592,21 @@ Returned *ExecutionEngine::newRegExpObject(const QString &pattern, Returned *ExecutionEngine::newRegExpObject(RegExp *re, bool global) { Scope scope(this); - Scoped object(scope, new (this) RegExpObject::Data(this, re, global)); + Scoped object(scope, memoryManager->alloc(this, re, global)); return object->asReturned(); } Returned *ExecutionEngine::newRegExpObject(const QRegExp &re) { Scope scope(this); - Scoped object(scope, new (this) RegExpObject::Data(this, re)); + Scoped object(scope, memoryManager->alloc(this, re)); return object->asReturned(); } Returned *ExecutionEngine::newErrorObject(const ValueRef value) { Scope scope(this); - ScopedObject object(scope, new (this) ErrorObject::Data(errorClass, value)); + ScopedObject object(scope, memoryManager->alloc(errorClass, value)); return object->asReturned(); } @@ -613,14 +614,14 @@ Returned *ExecutionEngine::newSyntaxErrorObject(const QString &message) { Scope scope(this); ScopedString s(scope, newString(message)); - ScopedObject error(scope, new (this) SyntaxErrorObject::Data(this, s)); + ScopedObject error(scope, memoryManager->alloc(this, s)); return error->asReturned(); } Returned *ExecutionEngine::newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column) { Scope scope(this); - ScopedObject error(scope, new (this) SyntaxErrorObject::Data(this, message, fileName, line, column)); + ScopedObject error(scope, memoryManager->alloc(this, message, fileName, line, column)); return error->asReturned(); } @@ -628,14 +629,14 @@ Returned *ExecutionEngine::newSyntaxErrorObject(const QString &message, Returned *ExecutionEngine::newReferenceErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) ReferenceErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc(this, message)); return o->asReturned(); } Returned *ExecutionEngine::newReferenceErrorObject(const QString &message, const QString &fileName, int lineNumber, int columnNumber) { Scope scope(this); - ScopedObject o(scope, new (this) ReferenceErrorObject::Data(this, message, fileName, lineNumber, columnNumber)); + ScopedObject o(scope, memoryManager->alloc(this, message, fileName, lineNumber, columnNumber)); return o->asReturned(); } @@ -643,35 +644,35 @@ Returned *ExecutionEngine::newReferenceErrorObject(const QString &messag Returned *ExecutionEngine::newTypeErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) TypeErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc(this, message)); return o->asReturned(); } Returned *ExecutionEngine::newRangeErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) RangeErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc(this, message)); return o->asReturned(); } Returned *ExecutionEngine::newURIErrorObject(const ValueRef message) { Scope scope(this); - ScopedObject o(scope, new (this) URIErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc(this, message)); return o->asReturned(); } Returned *ExecutionEngine::newVariantObject(const QVariant &v) { Scope scope(this); - ScopedObject o(scope, new (this) VariantObject::Data(this, v)); + ScopedObject o(scope, memoryManager->alloc(this, v)); return o->asReturned(); } Returned *ExecutionEngine::newForEachIteratorObject(ExecutionContext *ctx, Object *o) { Scope scope(this); - ScopedObject obj(scope, new (this) ForEachIteratorObject::Data(ctx, o)); + ScopedObject obj(scope, memoryManager->alloc(ctx, o)); return obj->asReturned(); } @@ -828,8 +829,8 @@ void ExecutionEngine::requireArgumentsAccessors(int n) delete [] oldAccessors; } for (int i = oldSize; i < nArgumentsAccessors; ++i) { - argumentsAccessors[i].value = ScopedValue(scope, new (scope.engine) ArgumentsGetterFunction::Data(rootContext, i)); - argumentsAccessors[i].set = ScopedValue(scope, new (scope.engine) ArgumentsSetterFunction::Data(rootContext, i)); + argumentsAccessors[i].value = ScopedValue(scope, memoryManager->alloc(rootContext, i)); + argumentsAccessors[i].set = ScopedValue(scope, memoryManager->alloc(rootContext, i)); } } } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 6849acc..a3f83de 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -170,7 +170,6 @@ public: return jsStackTop->managed(); } - IdentifierTable *identifierTable; QV4::Debugging::Debugger *debugger; diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 83ef60e..b99a82a 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -287,7 +287,7 @@ ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) EvalErrorObject::Data(m->engine(), v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(m->engine(), v))->asReturnedValue(); } RangeErrorCtor::Data::Data(ExecutionContext *scope) @@ -300,7 +300,7 @@ ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) RangeErrorObject::Data(scope.engine, v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } ReferenceErrorCtor::Data::Data(ExecutionContext *scope) @@ -313,7 +313,7 @@ ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) ReferenceErrorObject::Data(scope.engine, v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } SyntaxErrorCtor::Data::Data(ExecutionContext *scope) @@ -326,7 +326,7 @@ ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) SyntaxErrorObject::Data(scope.engine, v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } TypeErrorCtor::Data::Data(ExecutionContext *scope) @@ -339,7 +339,7 @@ ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) TypeErrorObject::Data(scope.engine, v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } URIErrorCtor::Data::Data(ExecutionContext *scope) @@ -352,7 +352,7 @@ ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData) { Scope scope(m->engine()); ScopedValue v(scope, callData->argument(0)); - return (new (m->engine()) URIErrorObject::Data(scope.engine, v))->asReturnedValue(); + return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj) diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 89646ec..bf77b44 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -45,6 +45,7 @@ #include "qv4value_inl_p.h" #include "qv4engine_p.h" #include "qv4lookup_p.h" +#include "qv4mm_p.h" QT_BEGIN_NAMESPACE @@ -73,7 +74,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, break; } // duplicate arguments, need some trick to store them - arg = (s = new (engine) String::Data(engine, arg, engine->newString(QString(0xfffe))->getPointer())).getPointer(); + arg = (s = engine->memoryManager->alloc(engine, arg, engine->newString(QString(0xfffe))->getPointer())).getPointer(); } } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index efc2b17..1097478 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -173,14 +173,14 @@ void FunctionObject::markObjects(Managed *that, ExecutionEngine *e) Object::markObjects(that, e); } -FunctionObject::Data *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) +FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) { if (function->needsActivation() || function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith || function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || function->isNamedExpression()) - return new (scope->d()->engine) ScriptFunction::Data(scope, function); - return new (scope->d()->engine) SimpleScriptFunction::Data(scope, function, createProto); + return scope->d()->engine->memoryManager->alloc(scope, function); + return scope->d()->engine->memoryManager->alloc(scope, function, createProto); } DEFINE_OBJECT_VTABLE(FunctionCtor); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 16377aa..eff65f7 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -51,6 +51,7 @@ #include "qv4property_p.h" #include "qv4function_p.h" #include "qv4objectiterator_p.h" +#include "qv4mm_p.h" #include #include @@ -150,7 +151,7 @@ struct Q_QML_EXPORT FunctionObject: Object { return v.asFunctionObject(); } - static Data *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true); + static FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true); ReturnedValue protoProperty() { return memberData()[Index_Prototype].asReturnedValue(); } @@ -193,7 +194,7 @@ struct FunctionPrototype: FunctionObject static ReturnedValue method_bind(CallContext *ctx); }; -struct BuiltinFunction: FunctionObject { +struct Q_QML_EXPORT BuiltinFunction: FunctionObject { struct Data : FunctionObject::Data { Data(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)); ReturnedValue (*code)(CallContext *); @@ -203,9 +204,9 @@ struct BuiltinFunction: FunctionObject { } __data; V4_OBJECT - static BuiltinFunction::Data *create(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) + static BuiltinFunction *create(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *)) { - return new (scope->engine()) Data(scope, name, code); + return scope->engine()->memoryManager->alloc(scope, name, code); } static ReturnedValue construct(Managed *, CallData *); @@ -277,9 +278,9 @@ struct BoundFunction: FunctionObject { } __data; V4_OBJECT - static BoundFunction::Data *create(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const QV4::Members &boundArgs) + static BoundFunction *create(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, const QV4::Members &boundArgs) { - return new (scope->engine()) Data(scope, target, boundThis, boundArgs); + return scope->engine()->memoryManager->alloc(scope, target, boundThis, boundArgs); } FunctionObject *target() { return d()->target; } diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index 5613e65..e3e8bb6 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -175,11 +175,3 @@ bool Managed::isEqualTo(Managed *, Managed *) { return false; } - - -void *Managed::Data::operator new(size_t size, ExecutionEngine *e) -{ - assert(e); - - return e->memoryManager->allocManaged(size); -} diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 04449f0..fc0a87d 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -208,7 +208,6 @@ struct Q_QML_PRIVATE_EXPORT Managed return reinterpret_cast(const_cast(this))->asReturnedValue(); } - void *operator new(size_t size, ExecutionEngine *e); void *operator new(size_t, Managed *m) { return m; } void *operator new(size_t, Managed::Data *m) { return m; } }; diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index 34a7c17..3e7ac17 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -178,7 +178,7 @@ MemoryManager::MemoryManager() #endif } -Managed *MemoryManager::alloc(std::size_t size) +Managed *MemoryManager::allocData(std::size_t size) { if (m_d->aggressiveGC) runGC(); diff --git a/src/qml/jsruntime/qv4mm_p.h b/src/qml/jsruntime/qv4mm_p.h index 10579d6..f0025dc 100644 --- a/src/qml/jsruntime/qv4mm_p.h +++ b/src/qml/jsruntime/qv4mm_p.h @@ -99,10 +99,58 @@ public: inline Managed *allocManaged(std::size_t size) { size = align(size); - Managed *o = alloc(size); + Managed *o = allocData(size); return o; } + template + ManagedType *alloc() + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(); + return t; + } + + template + ManagedType *alloc(Arg1 arg1) + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1); + return t; + } + + template + ManagedType *alloc(Arg1 arg1, Arg2 arg2) + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2); + return t; + } + + template + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3) + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3); + return t; + } + + template + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3, arg4); + return t; + } + + template + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) + { + ManagedType *t = static_cast(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3, arg4, arg5); + return t; + } + bool isGCBlocked() const; void setGCBlocked(bool blockGC); void runGC(); @@ -120,7 +168,7 @@ public: protected: /// expects size to be aligned // TODO: try to inline - Managed *alloc(std::size_t size); + Managed *allocData(std::size_t size); #ifdef DETAILED_MM_STATS void willAllocate(std::size_t size); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index f3f11e5..e12b8f1 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -345,7 +345,7 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx QV4::Scoped qmlcontextobject(scope, ctx->d()->engine->qmlContextObject()); return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex, qmlcontextobject); } else if (property->isSignalHandler()) { - QV4::Scoped handler(scope, new (scope.engine) QV4::QmlSignalHandler::Data(ctx->d()->engine, object, property->coreIndex)); + QV4::Scoped handler(scope, scope.engine->memoryManager->alloc(ctx->d()->engine, object, property->coreIndex)); QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect"))); QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect"))); @@ -658,7 +658,7 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object) QQmlEngine *qmlEngine = engine->v8Engine->engine(); if (qmlEngine) QQmlData::ensurePropertyCache(qmlEngine, object); - return (new (engine) QV4::QObjectWrapper::Data(engine, object))->asReturnedValue(); + return (engine->memoryManager->alloc(engine, object))->asReturnedValue(); } QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty) @@ -1747,7 +1747,7 @@ QV4::ReturnedValue CallArgument::toValue(QV8Engine *engine) ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal) { - return (new (scope->d()->engine) QObjectMethod::Data(scope, object, index, qmlGlobal))->asReturnedValue(); + return (scope->d()->engine->memoryManager->alloc(scope, object, index, qmlGlobal))->asReturnedValue(); } QObjectMethod::Data::Data(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal) diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 08025e0..e2de584 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -42,6 +42,7 @@ #include "qv4regexp_p.h" #include "qv4engine_p.h" #include "qv4scopedvalue_p.h" +#include "qv4mm_p.h" using namespace QV4; @@ -49,7 +50,7 @@ RegExpCache::~RegExpCache() { for (RegExpCache::Iterator it = begin(), e = end(); it != e; ++it) - it.value()->cache = 0; + it.value()->d()->cache = 0; clear(); } @@ -70,22 +71,22 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets) return JSC::Yarr::interpret(byteCode().get(), s.characters16(), string.length(), start, matchOffsets); } -RegExp::Data* RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline) +RegExp* RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline) { RegExpCacheKey key(pattern, ignoreCase, multiline); RegExpCache *cache = engine->regExpCache; if (cache) { - if (RegExp::Data *result = cache->value(key)) + if (RegExp *result = cache->value(key)) return result; } - RegExp::Data *result = new (engine) RegExp::Data(engine, pattern, ignoreCase, multiline); + RegExp *result = engine->memoryManager->alloc(engine, pattern, ignoreCase, multiline); if (!cache) cache = engine->regExpCache = new RegExpCache; - result->cache = cache; + result->d()->cache = cache; cache->insert(key, result); return result; diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index 29f759f..4c94197 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -104,7 +104,7 @@ struct RegExp : public Managed bool ignoreCase() const { return d()->ignoreCase; } bool multiLine() const { return d()->multiLine; } - static RegExp::Data* create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); + static RegExp* create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); bool isValid() const { return d()->byteCode.get(); } @@ -146,7 +146,7 @@ inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re) inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.pattern, seed); } -class RegExpCache : public QHash +class RegExpCache : public QHash { public: ~RegExpCache(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 4ec1a7b..7ea8dbd 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -514,7 +514,7 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionContext *ctx, const ValueR return pright->asReturnedValue(); if (!pright->stringValue()->d()->length()) return pleft->asReturnedValue(); - return (new (ctx->engine()) String::Data(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); + return (ctx->engine()->memoryManager->alloc(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); } double x = RuntimeHelpers::toNumber(pleft); double y = RuntimeHelpers::toNumber(pright); @@ -530,7 +530,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val return right->asReturnedValue(); if (!right->stringValue()->d()->length()) return left->asReturnedValue(); - return (new (ctx->engine()) String::Data(ctx->d()->engine, left->stringValue(), right->stringValue()))->asReturnedValue(); + return (ctx->engine()->memoryManager->alloc(ctx->d()->engine, left->stringValue(), right->stringValue()))->asReturnedValue(); } Scope scope(ctx); @@ -547,7 +547,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val return pright->asReturnedValue(); if (!pright->stringValue()->d()->length()) return pleft->asReturnedValue(); - return (new (ctx->engine()) String::Data(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); + return (ctx->engine()->memoryManager->alloc(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); } void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value) @@ -1192,7 +1192,7 @@ QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionContext *ctx) { Q_ASSERT(ctx->d()->type >= ExecutionContext::Type_CallContext); CallContext *c = static_cast(ctx); - return (new (c->engine()) ArgumentsObject::Data(c))->asReturnedValue(); + return (c->engine()->memoryManager->alloc(c))->asReturnedValue(); } #endif // V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index cdc8622..638cf3c 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -141,7 +141,7 @@ Returned *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine); QV4::Scope valueScope(engine); QV4::ScopedObject qmlScopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(engine->v8Engine, qmlContext, scopeObject)); - QV4::Scoped wrapper(valueScope, new (engine) QV4::QmlBindingWrapper::Data(engine->rootContext, qmlScopeObject)); + QV4::Scoped wrapper(valueScope, engine->memoryManager->alloc(engine->rootContext, qmlScopeObject)); if (!signalParameters.isEmpty()) { if (error) @@ -150,7 +150,7 @@ Returned *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo QV4::ScopedString s(valueScope); int index = 0; foreach (const QByteArray ¶m, signalParameters) { - QV4::ScopedFunctionObject g(valueScope, new (engine) QV4::IndexedBuiltinFunction::Data(wrapper->context(), index++, signalParameterGetter)); + QV4::ScopedFunctionObject g(valueScope, engine->memoryManager->alloc(wrapper->context(), index++, signalParameterGetter)); p->setGetter(g); p->setSetter(0); s = engine->newString(QString::fromUtf8(param)); @@ -206,7 +206,7 @@ Script::Script(ExecutionEngine *v4, Object *qml, CompiledData::CompilationUnit * vmFunction = compilationUnit->linkToEngine(v4); Q_ASSERT(vmFunction); Scope valueScope(v4); - ScopedObject holder(valueScope, new (v4) CompilationUnitHolder::Data(v4, compilationUnit)); + ScopedObject holder(valueScope, v4->memoryManager->alloc(v4, compilationUnit)); compilationUnitHolder = holder.asReturnedValue(); } else vmFunction = 0; @@ -278,7 +278,7 @@ void Script::parse() isel->setUseFastLookups(false); QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile(); vmFunction = compilationUnit->linkToEngine(v4); - ScopedObject holder(valueScope, new (v4) CompilationUnitHolder::Data(v4, compilationUnit)); + ScopedObject holder(valueScope, v4->memoryManager->alloc(v4, compilationUnit)); compilationUnitHolder = holder.asReturnedValue(); } @@ -332,7 +332,7 @@ ReturnedValue Script::run() return vmFunction->code(scope, vmFunction->codeData); } else { ScopedObject qmlObj(valueScope, qml.value()); - ScopedFunctionObject f(valueScope, new (engine) QmlBindingWrapper::Data(scope, vmFunction, qmlObj)); + ScopedFunctionObject f(valueScope, engine->memoryManager->alloc(scope, vmFunction, qmlObj)); ScopedCallData callData(valueScope, 0); callData->thisObject = Primitive::undefinedValue(); return f->call(callData); @@ -408,7 +408,7 @@ ReturnedValue Script::qmlBinding() ExecutionEngine *v4 = scope->d()->engine; Scope valueScope(v4); ScopedObject qmlObj(valueScope, qml.value()); - ScopedObject v(valueScope, new (v4) QmlBindingWrapper::Data(scope, vmFunction, qmlObj)); + ScopedObject v(valueScope, v4->memoryManager->alloc(scope, vmFunction, qmlObj)); return v.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index ed6e490..a45d047 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -587,7 +587,7 @@ bool SequencePrototype::isSequenceType(int sequenceTypeId) #define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::Scoped obj(scope, new (engine) QQml##ElementTypeName##List::Data(engine, object, propertyIndex)); \ + QV4::Scoped obj(scope, engine->memoryManager->alloc(engine, object, propertyIndex)); \ return obj.asReturnedValue(); \ } else @@ -605,7 +605,7 @@ ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int s #define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::Scoped obj(scope, new (engine) QQml##ElementTypeName##List::Data(engine, v.value())); \ + QV4::Scoped obj(scope, engine->memoryManager->alloc(engine, v.value())); \ return obj.asReturnedValue(); \ } else diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 716aa31..3cf39bd 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1367,7 +1367,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) QQmlComponentExtension *e = componentExtension(args->engine()); - QV4::Scoped r(scope, new (v4) QmlIncubatorObject::Data(args->engine(), mode)); + QV4::Scoped r(scope, v4->memoryManager->alloc(args->engine(), mode)); QV4::ScopedObject p(scope, e->incubationProto.value()); r->setPrototype(p.getPointer()); diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 53353f6..83ef8c6 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -83,7 +83,7 @@ ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt, ExecutionEngine *v4 = QV8Engine::getV4(v8); Scope valueScope(v4); - Scoped w(valueScope, new (v4) QmlContextWrapper::Data(v8, ctxt, scope)); + Scoped w(valueScope, v4->memoryManager->alloc(v8, ctxt, scope)); return w.asReturnedValue(); } @@ -97,7 +97,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url) context->isInternal = true; context->isJSContext = true; - Scoped w(scope, new (v4) QmlContextWrapper::Data(v8, context, 0, true)); + Scoped w(scope, v4->memoryManager->alloc(v8, context, (QObject*)0, true)); w->d()->isNullWrapper = true; return w.asReturnedValue(); } @@ -415,7 +415,7 @@ ReturnedValue QmlContextWrapper::idObjectsArray() if (!d()->idObjectsWrapper) { ExecutionEngine *v4 = engine(); Scope scope(v4); - Scoped a(scope, new (v4) QQmlIdObjectsArray::Data(v4, this)); + Scoped a(scope, v4->memoryManager->alloc(v4, this)); d()->idObjectsWrapper = a.getPointer(); } return d()->idObjectsWrapper->asReturnedValue(); diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 6897b04..b847525 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -75,7 +75,7 @@ ReturnedValue QmlListWrapper::create(QV8Engine *v8, QObject *object, int propId, ExecutionEngine *v4 = QV8Engine::getV4(v8); Scope scope(v4); - Scoped r(scope, new (v4) QmlListWrapper::Data(v8)); + Scoped r(scope, v4->memoryManager->alloc(v8)); r->d()->object = object; r->d()->propertyType = propType; void *args[] = { &r->d()->property, 0 }; @@ -88,7 +88,7 @@ ReturnedValue QmlListWrapper::create(QV8Engine *v8, const QQmlListProperty r(scope, new (v4) QmlListWrapper::Data(v8)); + Scoped r(scope, v4->memoryManager->alloc(v8)); r->d()->object = prop.object; r->d()->property = prop; r->d()->propertyType = propType; diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 0d67b3a..b1ce0da 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -814,7 +814,7 @@ QV4::ReturnedValue QQmlLocale::wrap(QV8Engine *engine, const QLocale &locale) QV8LocaleDataDeletable *d = localeV8Data(engine); QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); - QV4::Scoped wrapper(scope, new (v4) QQmlLocaleData::Data(v4)); + QV4::Scoped wrapper(scope, v4->memoryManager->alloc(v4)); wrapper->d()->locale = locale; QV4::ScopedObject p(scope, d->prototype.value()); wrapper->setPrototype(p.getPointer()); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 8162777..9501b70 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -261,7 +261,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance) QV4::ScopedValue scopeObjectProtector(valueScope, declarativeData->jsWrapper.value()); Q_UNUSED(scopeObjectProtector); QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject)); - QV4::Scoped qmlBindingWrapper(valueScope, new (v4) QV4::QmlBindingWrapper::Data(v4->rootContext, qmlScope)); + QV4::Scoped qmlBindingWrapper(valueScope, v4->memoryManager->alloc(v4->rootContext, qmlScope)); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); qSwap(_qmlContext, qmlContext); @@ -1163,7 +1163,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo QV4::ScopedValue scopeObjectProtector(valueScope, ddata ? ddata->jsWrapper.value() : 0); Q_UNUSED(scopeObjectProtector); QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject)); - QV4::Scoped qmlBindingWrapper(valueScope, new (v4) QV4::QmlBindingWrapper::Data(v4->rootContext, qmlScope)); + QV4::Scoped qmlBindingWrapper(valueScope, v4->memoryManager->alloc(v4->rootContext, qmlScope)); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); qSwap(_qmlContext, qmlContext); diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 958c511..53afd36 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -99,7 +99,7 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlType *t, Typ ExecutionEngine *v4 = QV8Engine::getV4(v8); Scope scope(v4); - Scoped w(scope, new (v4) QmlTypeWrapper::Data(v8)); + Scoped w(scope, v4->memoryManager->alloc(v8)); w->d()->mode = mode; w->d()->object = o; w->d()->type = t; return w.asReturnedValue(); } @@ -113,7 +113,7 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCach ExecutionEngine *v4 = QV8Engine::getV4(v8); Scope scope(v4); - Scoped w(scope, new (v4) QmlTypeWrapper::Data(v8)); + Scoped w(scope, v4->memoryManager->alloc(v8)); 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/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index f70daec..52b45bd 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -161,9 +161,9 @@ ReturnedValue QmlValueTypeWrapper::create(QV8Engine *v8, QObject *object, int pr Scope scope(v4); initProto(v4); - QmlValueTypeReference::Data *r = new (v4) QmlValueTypeReference::Data(v8); - r->internalClass = r->internalClass->changePrototype(v4->qmlExtensions()->valueTypeWrapperPrototype); - r->type = type; r->object = object; r->property = property; + QmlValueTypeReference *r = v4->memoryManager->alloc(v8); + r->d()->internalClass = r->d()->internalClass->changePrototype(v4->qmlExtensions()->valueTypeWrapperPrototype); + r->d()->type = type; r->d()->object = object; r->d()->property = property; return r->asReturnedValue(); } @@ -173,9 +173,9 @@ ReturnedValue QmlValueTypeWrapper::create(QV8Engine *v8, const QVariant &value, Scope scope(v4); initProto(v4); - QmlValueTypeCopy::Data *r = new (v4) QmlValueTypeCopy::Data(v8); - r->internalClass = r->internalClass->changePrototype(v4->qmlExtensions()->valueTypeWrapperPrototype); - r->type = type; r->value = value; + QmlValueTypeCopy *r = v4->memoryManager->alloc(v8); + r->d()->internalClass = r->d()->internalClass->changePrototype(v4->qmlExtensions()->valueTypeWrapperPrototype); + r->d()->type = type; r->d()->value = value; return r->asReturnedValue(); } diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index f5de4af..d864c1f 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -226,6 +226,7 @@ DEFINE_OBJECT_VTABLE(NamedNodeMap); class NodeList : public Object { +public: struct Data : Object::Data { Data(ExecutionEngine *engine, NodeImpl *data) : Object::Data(engine) @@ -247,7 +248,6 @@ class NodeList : public Object } __data; V4_OBJECT -public: // JS API static void destroy(Managed *that) { @@ -265,6 +265,7 @@ DEFINE_OBJECT_VTABLE(NodeList); class NodePrototype : public Object { +public: struct Data : Object::Data { Data(ExecutionEngine *engine) : Object::Data(engine) @@ -288,7 +289,6 @@ class NodePrototype : public Object } }; V4_OBJECT -public: static void initClass(ExecutionEngine *engine); @@ -614,7 +614,7 @@ ReturnedValue NodePrototype::getProto(ExecutionEngine *v4) Scope scope(v4); QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); if (d->nodePrototype.isUndefined()) { - ScopedObject p(scope, new (v4) NodePrototype::Data(v4)); + ScopedObject p(scope, v4->memoryManager->alloc(v4)); d->nodePrototype = p; v4->v8Engine->freezeObject(p); } @@ -626,7 +626,7 @@ ReturnedValue Node::create(QV8Engine *engine, NodeImpl *data) ExecutionEngine *v4 = QV8Engine::getV4(engine); Scope scope(v4); - Scoped instance(scope, new (v4) Node::Data(v4, data)); + Scoped instance(scope, v4->memoryManager->alloc(v4, data)); ScopedObject p(scope); switch (data->type) { @@ -901,7 +901,7 @@ ReturnedValue Document::load(QV8Engine *engine, const QByteArray &data) return Encode::null(); } - ScopedObject instance(scope, new (v4) Node::Data(v4, document)); + ScopedObject instance(scope, v4->memoryManager->alloc(v4, document)); ScopedObject p(scope); instance->setPrototype((p = Document::prototype(v4)).getPointer()); return instance.asReturnedValue(); @@ -964,7 +964,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty) ReturnedValue NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QList &list) { ExecutionEngine *v4 = QV8Engine::getV4(engine); - return (new (v4) NamedNodeMap::Data(v4, data, list))->asReturnedValue(); + return (v4->memoryManager->alloc(v4, data, list))->asReturnedValue(); } ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) @@ -1006,7 +1006,7 @@ ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty) ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data) { ExecutionEngine *v4 = QV8Engine::getV4(engine); - return (new (v4) NodeList::Data(v4, data))->asReturnedValue(); + return (v4->memoryManager->alloc(v4, data))->asReturnedValue(); } ReturnedValue Document::method_documentElement(CallContext *ctx) @@ -1680,7 +1680,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject QV8Engine *engine = that->engine()->v8Engine; QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager()); - Scoped w(scope, new (that->engine()) QQmlXMLHttpRequestWrapper::Data(that->engine(), r)); + Scoped w(scope, that->engine()->memoryManager->alloc(that->engine(), r)); w->setPrototype(ctor->d()->proto); return w.asReturnedValue(); } @@ -2007,7 +2007,7 @@ void *qt_add_qmlxmlhttprequest(QV8Engine *engine) ExecutionEngine *v4 = QV8Engine::getV4(engine); Scope scope(v4); - Scoped ctor(scope, new (v4) QQmlXMLHttpRequestCtor::Data(v4)); + Scoped ctor(scope, v4->memoryManager->alloc(v4)); ScopedString s(scope, v4->newString(QStringLiteral("XMLHttpRequest"))); v4->globalObject->defineReadonlyProperty(s.getPointer(), ctor); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 0d4ffaf..e07d97e 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1256,7 +1256,7 @@ ReturnedValue QtObject::method_binding(CallContext *ctx) if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); - return (new (ctx->d()->engine) QQmlBindingFunction::Data(f))->asReturnedValue(); + return (ctx->d()->engine->memoryManager->alloc(f))->asReturnedValue(); } @@ -1587,10 +1587,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, new (v4) QV4::ConsoleObject::Data(v4)); + ScopedObject console(scope, v4->memoryManager->alloc(v4)); globalObject->defineDefaultProperty(QStringLiteral("console"), console); - ScopedObject qt(scope, new (v4) QV4::QtObject::Data(v4, qmlEngine)); + ScopedObject qt(scope, v4->memoryManager->alloc(v4, qmlEngine)); globalObject->defineDefaultProperty(QStringLiteral("Qt"), qt); // string prototype extension diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index c86da03..7fd8806 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -80,9 +80,9 @@ struct DelegateModelGroupFunction: QV4::FunctionObject V4_OBJECT - static Data *create(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)) + static DelegateModelGroupFunction *create(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::ValueRef arg)) { - return new (scope->engine()) Data(scope, flag, code); + return scope->engine()->memoryManager->alloc(scope, flag, code); } static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *) @@ -2472,7 +2472,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, new (v4) QQmlDelegateModelItemObject::Data(v4, cacheItem)); + QV4::ScopedObject o(scope, v4->memoryManager->alloc(v4, cacheItem)); QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value()); o->setPrototype(p.getPointer()); ++cacheItem->scriptRef; @@ -3228,8 +3228,8 @@ struct QQmlDelegateModelGroupChange : QV4::Object V4_OBJECT - static Data *create(QV4::ExecutionEngine *e) { - return new (e) Data(e); + static QQmlDelegateModelGroupChange *create(QV4::ExecutionEngine *e) { + return e->memoryManager->alloc(e); } static QV4::ReturnedValue method_get_index(QV4::CallContext *ctx) { @@ -3278,9 +3278,9 @@ struct QQmlDelegateModelGroupChangeArray : public QV4::Object } __data; V4_OBJECT public: - static Data *create(QV4::ExecutionEngine *engine, const QVector &changes) + static QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector &changes) { - return new (engine) Data(engine, changes); + return engine->memoryManager->alloc(engine, changes); } quint32 count() const { return d()->changes.count(); } diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index d330005..6349c6f 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -227,8 +227,8 @@ public: const QByteArray &propertyName = it.key(); QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName))); - QV4::ScopedFunctionObject g(scope, new (v4) QV4::IndexedBuiltinFunction::Data(v4->rootContext, propertyId, QQmlDMCachedModelData::get_property)); - QV4::ScopedFunctionObject s(scope, new (v4) QV4::IndexedBuiltinFunction::Data(v4->rootContext, propertyId, QQmlDMCachedModelData::set_property)); + QV4::ScopedFunctionObject g(scope, v4->memoryManager->alloc(v4->rootContext, propertyId, QQmlDMCachedModelData::get_property)); + QV4::ScopedFunctionObject s(scope, v4->memoryManager->alloc(v4->rootContext, propertyId, QQmlDMCachedModelData::set_property)); p->setGetter(g); p->setSetter(s); proto->insertMember(name.getPointer(), p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); @@ -433,7 +433,7 @@ public: } QV4::Scope scope(v4); QV4::ScopedObject proto(scope, type->prototype.value()); - QV4::ScopedObject o(scope, new (proto->engine()) QQmlDelegateModelItemObject::Data(proto->engine(), this)); + QV4::ScopedObject o(scope, proto->engine()->memoryManager->alloc(proto->engine(), this)); o->setPrototype(proto.getPointer()); ++scriptRef; return o.asReturnedValue(); @@ -611,7 +611,7 @@ public: { QQmlAdaptorModelEngineData *data = engineData(v4->v8Engine); QV4::Scope scope(v4); - QV4::ScopedObject o(scope, new (v4) QQmlDelegateModelItemObject::Data(v4, this)); + QV4::ScopedObject o(scope, v4->memoryManager->alloc(v4, this)); QV4::ScopedObject p(scope, data->listItemProto.value()); o->setPrototype(p.getPointer()); ++scriptRef; diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 0280540..d71f1da 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -540,11 +540,10 @@ struct QQuickJSContext2DPrototype : public QV4::Object { V4_OBJECT public: - static Data *create(QV4::ExecutionEngine *engine) + static QQuickJSContext2DPrototype *create(QV4::ExecutionEngine *engine) { - Data *d = new (engine) Data(engine); QV4::Scope scope(engine); - QV4::ScopedObject o(scope, d); + QV4::ScopedObject o(scope, engine->memoryManager->alloc(engine)); o->defineDefaultProperty(QStringLiteral("quadraticCurveTo"), method_quadraticCurveTo, 0); o->defineDefaultProperty(QStringLiteral("restore"), method_restore, 0); @@ -591,7 +590,7 @@ public: o->defineDefaultProperty(QStringLiteral("closePath"), method_closePath, 0); o->defineAccessorProperty(QStringLiteral("canvas"), QQuickJSContext2DPrototype::method_get_canvas, 0); - return d; + return static_cast(o.getPointer()); } static QV4::ReturnedValue method_get_canvas(QV4::CallContext *ctx); @@ -941,7 +940,7 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engi QQuickContext2DEngineData *ed = engineData(engine); QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); - QV4::Scoped pixelData(scope, new (scope.engine) QQuickJSContext2DPixelData::Data(v4)); + QV4::Scoped pixelData(scope, scope.engine->memoryManager->alloc(v4)); QV4::ScopedObject p(scope, ed->pixelArrayProto.value()); pixelData->setPrototype(p.getPointer()); @@ -953,7 +952,7 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engi pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32); } - QV4::Scoped imageData(scope, new (scope.engine) QQuickJSContext2DImageData::Data(v4)); + QV4::Scoped imageData(scope, scope.engine->memoryManager->alloc(v4)); imageData->d()->pixelData = pixelData.asReturnedValue(); return imageData.asReturnedValue(); } @@ -1567,7 +1566,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4:: } QQuickContext2DEngineData *ed = engineData(engine); - QV4::Scoped gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine)); + QV4::Scoped gradient(scope, scope.engine->memoryManager->alloc(scope.engine)); QV4::ScopedObject p(scope, ed->gradientProto.value()); gradient->setPrototype(p.getPointer()); gradient->d()->brush = QLinearGradient(x0, y0, x1, y1); @@ -1621,7 +1620,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4:: QQuickContext2DEngineData *ed = engineData(engine); - QV4::Scoped gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine)); + QV4::Scoped gradient(scope, scope.engine->memoryManager->alloc(scope.engine)); QV4::ScopedObject p(scope, ed->gradientProto.value()); gradient->setPrototype(p.getPointer()); gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0)); @@ -1667,7 +1666,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4: QQuickContext2DEngineData *ed = engineData(engine); - QV4::Scoped gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine)); + QV4::Scoped gradient(scope, scope.engine->memoryManager->alloc(scope.engine)); QV4::ScopedObject p(scope, ed->gradientProto.value()); gradient->setPrototype(p.getPointer()); gradient->d()->brush = QConicalGradient(x, y, angle); @@ -1728,7 +1727,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon QV8Engine *engine = scope.engine->v8Engine; if (ctx->d()->callData->argc == 2) { - QV4::Scoped pattern(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine)); + QV4::Scoped pattern(scope, scope.engine->memoryManager->alloc(scope.engine)); QColor color = engine->toVariant(ctx->d()->callData->args[0], qMetaTypeId()).value(); if (color.isValid()) { @@ -4283,7 +4282,7 @@ void QQuickContext2D::setV8Engine(QV8Engine *engine) QQuickContext2DEngineData *ed = engineData(engine); QV4::ExecutionEngine *v4Engine = QV8Engine::getV4(engine); QV4::Scope scope(v4Engine); - QV4::Scoped wrapper(scope, new (v4Engine) QQuickJSContext2D::Data(v4Engine)); + QV4::Scoped wrapper(scope, v4Engine->memoryManager->alloc(v4Engine)); QV4::ScopedObject p(scope, ed->contextPrototype.value()); wrapper->setPrototype(p.getPointer()); wrapper->d()->context = this; diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index 5e26cbe..32fda33 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -58,10 +58,10 @@ QT_BEGIN_NAMESPACE DEFINE_OBJECT_VTABLE(QQuickRootItemMarker); -QQuickRootItemMarker::Data *QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window) +QQuickRootItemMarker *QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window) { QV4::ExecutionEngine *e = QQmlEnginePrivate::getV4Engine(engine); - return new (e) Data(e, window); + return e->memoryManager->alloc(e, window); } void QQuickRootItemMarker::markObjects(QV4::Managed *that, QV4::ExecutionEngine *e) diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 8b35500..4666ed4 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -120,7 +120,7 @@ struct QQuickRootItemMarker : public QV4::Object V4_OBJECT - static Data *create(QQmlEngine *engine, QQuickWindow *window); + static QQuickRootItemMarker *create(QQmlEngine *engine, QQuickWindow *window); static void markObjects(Managed *that, QV4::ExecutionEngine *e); diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index b7e5cf4..d7b1f2d 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -89,7 +89,7 @@ public: QV4::Scope scope(v4); QV4::Scoped name(scope, v4->newString(functionName)); - QV4::ScopedValue function(scope, v4->newBuiltinFunction(v4->rootContext, name, injectedFunction)); + QV4::ScopedValue function(scope, BuiltinFunction::create(v4->rootContext, name, injectedFunction)); v4->globalObject->put(name, function); } @@ -393,7 +393,7 @@ void tst_qv4debugger::addBreakPointWhilePaused() static QV4::ReturnedValue someCall(QV4::CallContext *ctx) { - ctx->engine->debugger->removeBreakPoint("removeBreakPointForNextInstruction", 2); + ctx->d()->engine->debugger->removeBreakPoint("removeBreakPointForNextInstruction", 2); return QV4::Encode::undefined(); } diff --git a/tools/qmljs/main.cpp b/tools/qmljs/main.cpp index 3fe3a0d..50bba82 100644 --- a/tools/qmljs/main.cpp +++ b/tools/qmljs/main.cpp @@ -197,9 +197,9 @@ int main(int argc, char *argv[]) QV4::Scope scope(ctx); QV4::ScopedObject globalObject(scope, vm.globalObject); - QV4::ScopedObject print(scope, new (scope.engine) builtins::Print::Data(ctx)); + QV4::ScopedObject print(scope, vm.memoryManager->alloc(ctx)); globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print); - QV4::ScopedObject gc(scope, new (scope.engine) builtins::GC::Data(ctx)); + QV4::ScopedObject gc(scope, vm.memoryManager->alloc(ctx)); globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc); foreach (const QString &fn, args) {