diff options
author | Simon Hausmann <[email protected]> | 2014-06-13 14:30:03 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2014-07-22 13:49:19 +0200 |
commit | b393c405b7568e80628bc99501a9c53bbd0e678d (patch) | |
tree | 51280658b1ec97947a66c6afc503b23ae48f0d8d /src/qml/jsruntime | |
parent | 00a46fa07bf87c6ffa0d60b4a98b51685fdc1ef5 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 131 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mm.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mm_p.h | 52 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 4 |
18 files changed, 168 insertions, 126 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 48bf0b8e3e..62d5859e87 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<WithContext>(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<CatchContext>(d()->engine, exceptionVarName, exceptionValue); } -HeapObject *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml) +CallContext *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml) { - CallContext::Data *c = reinterpret_cast<CallContext::Data *>(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0))); - new (c) CallContext::Data(d()->engine, qml, f); + CallContext *c = reinterpret_cast<CallContext*>(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 fe05774078..10a86dd898 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 f0e52f7eb0..ea31241c9c 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -71,6 +71,7 @@ #include "qv4memberdata_p.h" #include <QtCore/QTextStream> +#include <QDateTime> #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<ObjectPrototype>(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<ArrayPrototype>(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<StringPrototype>(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<NumberPrototype>(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<BooleanPrototype>(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<DatePrototype>(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<FunctionPrototype>(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> regExpPrototype(scope, new (this) RegExpPrototype::Data(InternalClass::create(this, RegExpPrototype::staticVTable(), objectPrototype))); + Scoped<RegExpPrototype> regExpPrototype(scope, memoryManager->alloc<RegExpPrototype>(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<ErrorPrototype>(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<EvalErrorPrototype>(errorClass)); evalErrorClass = InternalClass::create(this, EvalErrorObject::staticVTable(), evalErrorPrototype); - ScopedObject rangeErrorPrototype(scope, new (this) RangeErrorPrototype::Data(errorClass)); + ScopedObject rangeErrorPrototype(scope, memoryManager->alloc<RangeErrorPrototype>(errorClass)); rangeErrorClass = InternalClass::create(this, RangeErrorObject::staticVTable(), rangeErrorPrototype); - ScopedObject referenceErrorPrototype(scope, new (this) ReferenceErrorPrototype::Data(errorClass)); + ScopedObject referenceErrorPrototype(scope, memoryManager->alloc<ReferenceErrorPrototype>(errorClass)); referenceErrorClass = InternalClass::create(this, ReferenceErrorObject::staticVTable(), referenceErrorPrototype); - ScopedObject syntaxErrorPrototype(scope, new (this) SyntaxErrorPrototype::Data(errorClass)); + ScopedObject syntaxErrorPrototype(scope, memoryManager->alloc<SyntaxErrorPrototype>(errorClass)); syntaxErrorClass = InternalClass::create(this, SyntaxErrorObject::staticVTable(), syntaxErrorPrototype); - ScopedObject typeErrorPrototype(scope, new (this) TypeErrorPrototype::Data(errorClass)); + ScopedObject typeErrorPrototype(scope, memoryManager->alloc<TypeErrorPrototype>(errorClass)); typeErrorClass = InternalClass::create(this, TypeErrorObject::staticVTable(), typeErrorPrototype); - ScopedObject uRIErrorPrototype(scope, new (this) URIErrorPrototype::Data(errorClass)); + ScopedObject uRIErrorPrototype(scope, memoryManager->alloc<URIErrorPrototype>(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<VariantPrototype>(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<HeapObject *>(new (this) ObjectCtor::Data(rootContext)); - stringCtor = static_cast<HeapObject *>(new (this) StringCtor::Data(rootContext)); - numberCtor = static_cast<HeapObject *>(new (this) NumberCtor::Data(rootContext)); - booleanCtor = static_cast<HeapObject *>(new (this) BooleanCtor::Data(rootContext)); - arrayCtor = static_cast<HeapObject *>(new (this) ArrayCtor::Data(rootContext)); - functionCtor = static_cast<HeapObject *>(new (this) FunctionCtor::Data(rootContext)); - dateCtor = static_cast<HeapObject *>(new (this) DateCtor::Data(rootContext)); - regExpCtor = static_cast<HeapObject *>(new (this) RegExpCtor::Data(rootContext)); - errorCtor = static_cast<HeapObject *>(new (this) ErrorCtor::Data(rootContext)); - evalErrorCtor = static_cast<HeapObject *>(new (this) EvalErrorCtor::Data(rootContext)); - rangeErrorCtor = static_cast<HeapObject *>(new (this) RangeErrorCtor::Data(rootContext)); - referenceErrorCtor = static_cast<HeapObject *>(new (this) ReferenceErrorCtor::Data(rootContext)); - syntaxErrorCtor = static_cast<HeapObject *>(new (this) SyntaxErrorCtor::Data(rootContext)); - typeErrorCtor = static_cast<HeapObject *>(new (this) TypeErrorCtor::Data(rootContext)); - uRIErrorCtor = static_cast<HeapObject *>(new (this) URIErrorCtor::Data(rootContext)); + sequencePrototype = ScopedValue(scope, memoryManager->alloc<SequencePrototype>(arrayClass)); + + objectCtor = memoryManager->alloc<ObjectCtor>(rootContext); + stringCtor = memoryManager->alloc<StringCtor>(rootContext); + numberCtor = memoryManager->alloc<NumberCtor>(rootContext); + booleanCtor = memoryManager->alloc<BooleanCtor>(rootContext); + arrayCtor = memoryManager->alloc<ArrayCtor>(rootContext); + functionCtor = memoryManager->alloc<FunctionCtor>(rootContext); + dateCtor = memoryManager->alloc<DateCtor>(rootContext); + regExpCtor = memoryManager->alloc<RegExpCtor>(rootContext); + errorCtor = memoryManager->alloc<ErrorCtor>(rootContext); + evalErrorCtor = memoryManager->alloc<EvalErrorCtor>(rootContext); + rangeErrorCtor = memoryManager->alloc<RangeErrorCtor>(rootContext); + referenceErrorCtor = memoryManager->alloc<ReferenceErrorCtor>(rootContext); + syntaxErrorCtor = memoryManager->alloc<SyntaxErrorCtor>(rootContext); + typeErrorCtor = memoryManager->alloc<TypeErrorCtor>(rootContext); + uRIErrorCtor = memoryManager->alloc<URIErrorCtor>(rootContext); static_cast<ObjectPrototype *>(objectPrototype.getPointer())->init(this, objectCtor.asObject()); static_cast<StringPrototype *>(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<MathObject>(QV4::InternalClass::create(this, MathObject::staticVTable(), objectPrototype)))); + globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = memoryManager->alloc<JsonObject>(QV4::InternalClass::create(this, JsonObject::staticVTable(), objectPrototype)))); globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Primitive::undefinedValue()); globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN())); globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY)); - evalFunction = Scoped<EvalFunction>(scope, new (this) EvalFunction::Data(rootContext)); + evalFunction = Scoped<EvalFunction>(scope, memoryManager->alloc<EvalFunction>(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<GlobalContext>(this); + g->d()->callData = rootContext->d()->callData; - Q_ASSERT(currentContext() == reinterpret_cast<GlobalContext *>(g)); - return reinterpret_cast<GlobalContext *>(g); + Q_ASSERT(currentContext() == g); + return g; } Returned<Object> *ExecutionEngine::newObject() { Scope scope(this); - ScopedObject object(scope, new (this) Object::Data(this)); + ScopedObject object(scope, memoryManager->alloc<Object>(this)); return object->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newObject(InternalClass *internalClass) { Scope scope(this); - ScopedObject object(scope, new (this) Object::Data(internalClass)); + ScopedObject object(scope, memoryManager->alloc<Object>(internalClass)); return object->asReturned<Object>(); } Returned<String> *ExecutionEngine::newString(const QString &s) { Scope scope(this); - return ScopedString(scope, new (this) String::Data(this, s))->asReturned<String>(); + return ScopedString(scope, memoryManager->alloc<String>(this, s))->asReturned<String>(); } String *ExecutionEngine::newIdentifier(const QString &text) @@ -513,28 +514,28 @@ String *ExecutionEngine::newIdentifier(const QString &text) Returned<Object> *ExecutionEngine::newStringObject(const ValueRef value) { Scope scope(this); - Scoped<StringObject> object(scope, new (this) StringObject::Data(this, value)); + Scoped<StringObject> object(scope, memoryManager->alloc<StringObject>(this, value)); return object->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newNumberObject(const ValueRef value) { Scope scope(this); - Scoped<NumberObject> object(scope, new (this) NumberObject::Data(this, value)); + Scoped<NumberObject> object(scope, memoryManager->alloc<NumberObject>(this, value)); return object->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newBooleanObject(const ValueRef value) { Scope scope(this); - ScopedObject object(scope, new (this) BooleanObject::Data(this, value)); + ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, value)); return object->asReturned<Object>(); } Returned<ArrayObject> *ExecutionEngine::newArrayObject(int count) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(this)); + ScopedArrayObject object(scope, memoryManager->alloc<ArrayObject>(this)); if (count) { if (count < 0x1000) @@ -547,14 +548,14 @@ Returned<ArrayObject> *ExecutionEngine::newArrayObject(int count) Returned<ArrayObject> *ExecutionEngine::newArrayObject(const QStringList &list) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(this, list)); + ScopedArrayObject object(scope, memoryManager->alloc<ArrayObject>(this, list)); return object->asReturned<ArrayObject>(); } Returned<ArrayObject> *ExecutionEngine::newArrayObject(InternalClass *ic) { Scope scope(this); - ScopedArrayObject object(scope, new (this) ArrayObject::Data(ic)); + ScopedArrayObject object(scope, memoryManager->alloc<ArrayObject>(ic)); return object->asReturned<ArrayObject>(); } @@ -562,14 +563,14 @@ Returned<ArrayObject> *ExecutionEngine::newArrayObject(InternalClass *ic) Returned<DateObject> *ExecutionEngine::newDateObject(const ValueRef value) { Scope scope(this); - Scoped<DateObject> object(scope, new (this) DateObject::Data(this, value)); + Scoped<DateObject> object(scope, memoryManager->alloc<DateObject>(this, value)); return object->asReturned<DateObject>(); } Returned<DateObject> *ExecutionEngine::newDateObject(const QDateTime &dt) { Scope scope(this); - Scoped<DateObject> object(scope, new (this) DateObject::Data(this, dt)); + Scoped<DateObject> object(scope, memoryManager->alloc<DateObject>(this, dt)); return object->asReturned<DateObject>(); } @@ -591,21 +592,21 @@ Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QString &pattern, Returned<RegExpObject> *ExecutionEngine::newRegExpObject(RegExp *re, bool global) { Scope scope(this); - Scoped<RegExpObject> object(scope, new (this) RegExpObject::Data(this, re, global)); + Scoped<RegExpObject> object(scope, memoryManager->alloc<RegExpObject>(this, re, global)); return object->asReturned<RegExpObject>(); } Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QRegExp &re) { Scope scope(this); - Scoped<RegExpObject> object(scope, new (this) RegExpObject::Data(this, re)); + Scoped<RegExpObject> object(scope, memoryManager->alloc<RegExpObject>(this, re)); return object->asReturned<RegExpObject>(); } Returned<Object> *ExecutionEngine::newErrorObject(const ValueRef value) { Scope scope(this); - ScopedObject object(scope, new (this) ErrorObject::Data(errorClass, value)); + ScopedObject object(scope, memoryManager->alloc<ErrorObject>(errorClass, value)); return object->asReturned<Object>(); } @@ -613,14 +614,14 @@ Returned<Object> *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<SyntaxErrorObject>(this, s)); return error->asReturned<Object>(); } Returned<Object> *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<SyntaxErrorObject>(this, message, fileName, line, column)); return error->asReturned<Object>(); } @@ -628,14 +629,14 @@ Returned<Object> *ExecutionEngine::newSyntaxErrorObject(const QString &message, Returned<Object> *ExecutionEngine::newReferenceErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) ReferenceErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc<ReferenceErrorObject>(this, message)); return o->asReturned<Object>(); } Returned<Object> *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<ReferenceErrorObject>(this, message, fileName, lineNumber, columnNumber)); return o->asReturned<Object>(); } @@ -643,35 +644,35 @@ Returned<Object> *ExecutionEngine::newReferenceErrorObject(const QString &messag Returned<Object> *ExecutionEngine::newTypeErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) TypeErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc<TypeErrorObject>(this, message)); return o->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newRangeErrorObject(const QString &message) { Scope scope(this); - ScopedObject o(scope, new (this) RangeErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc<RangeErrorObject>(this, message)); return o->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newURIErrorObject(const ValueRef message) { Scope scope(this); - ScopedObject o(scope, new (this) URIErrorObject::Data(this, message)); + ScopedObject o(scope, memoryManager->alloc<URIErrorObject>(this, message)); return o->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newVariantObject(const QVariant &v) { Scope scope(this); - ScopedObject o(scope, new (this) VariantObject::Data(this, v)); + ScopedObject o(scope, memoryManager->alloc<VariantObject>(this, v)); return o->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newForEachIteratorObject(ExecutionContext *ctx, Object *o) { Scope scope(this); - ScopedObject obj(scope, new (this) ForEachIteratorObject::Data(ctx, o)); + ScopedObject obj(scope, memoryManager->alloc<ForEachIteratorObject>(ctx, o)); return obj->asReturned<Object>(); } @@ -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<ArgumentsGetterFunction>(rootContext, i)); + argumentsAccessors[i].set = ScopedValue(scope, memoryManager->alloc<ArgumentsSetterFunction>(rootContext, i)); } } } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 6849accfdc..a3f83de338 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 83ef60efc3..b99a82a1f5 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<EvalErrorObject>(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<RangeErrorObject>(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<ReferenceErrorObject>(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<SyntaxErrorObject>(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<TypeErrorObject>(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<URIErrorObject>(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 89646ec755..bf77b4434c 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<String>(engine, arg, engine->newString(QString(0xfffe))->getPointer())).getPointer(); } } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index efc2b172ef..10974780f3 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<ScriptFunction>(scope, function); + return scope->d()->engine->memoryManager->alloc<SimpleScriptFunction>(scope, function, createProto); } DEFINE_OBJECT_VTABLE(FunctionCtor); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 16377aaac5..eff65f7345 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 <QtCore/QString> #include <QtCore/QHash> @@ -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<BuiltinFunction>(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<BoundFunction>(scope, target, boundThis, boundArgs); } FunctionObject *target() { return d()->target; } diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index 5613e65446..e3e8bb6fd2 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 04449f0240..fc0a87da9e 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<Managed *>(const_cast<Data *>(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 34a7c17d7c..3e7ac17078 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 10579d6774..f0025dc70e 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 <typename ManagedType> + ManagedType *alloc() + { + ManagedType *t = static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(); + return t; + } + + template <typename ManagedType, typename Arg1> + ManagedType *alloc(Arg1 arg1) + { + ManagedType *t = static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1); + return t; + } + + template <typename ManagedType, typename Arg1, typename Arg2> + ManagedType *alloc(Arg1 arg1, Arg2 arg2) + { + ManagedType *t = static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2); + return t; + } + + template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3> + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3) + { + ManagedType *t = static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3); + return t; + } + + template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4> + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) + { + ManagedType *t = static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))); + (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3, arg4); + return t; + } + + template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> + ManagedType *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) + { + ManagedType *t = static_cast<ManagedType*>(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 f3f11e50e9..e12b8f1756 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<QV4::Object> qmlcontextobject(scope, ctx->d()->engine->qmlContextObject()); return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex, qmlcontextobject); } else if (property->isSignalHandler()) { - QV4::Scoped<QV4::QmlSignalHandler> handler(scope, new (scope.engine) QV4::QmlSignalHandler::Data(ctx->d()->engine, object, property->coreIndex)); + QV4::Scoped<QV4::QmlSignalHandler> handler(scope, scope.engine->memoryManager->alloc<QV4::QmlSignalHandler>(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<QV4::QObjectWrapper>(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<QObjectMethod>(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 08025e07cf..e2de584e31 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<RegExp>(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 29f759f93c..4c941979a4 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<RegExpCacheKey, RegExp::Data *> +class RegExpCache : public QHash<RegExpCacheKey, RegExp*> { public: ~RegExpCache(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 4ec1a7bc51..7ea8dbd0aa 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<String>(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<String>(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<String>(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<CallContext *>(ctx); - return (new (c->engine()) ArgumentsObject::Data(c))->asReturnedValue(); + return (c->engine()->memoryManager->alloc<ArgumentsObject>(c))->asReturnedValue(); } #endif // V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index cdc8622b26..638cf3c126 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -141,7 +141,7 @@ Returned<FunctionObject> *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<QV4::QmlBindingWrapper> wrapper(valueScope, new (engine) QV4::QmlBindingWrapper::Data(engine->rootContext, qmlScopeObject)); + QV4::Scoped<QV4::QmlBindingWrapper> wrapper(valueScope, engine->memoryManager->alloc<QV4::QmlBindingWrapper>(engine->rootContext, qmlScopeObject)); if (!signalParameters.isEmpty()) { if (error) @@ -150,7 +150,7 @@ Returned<FunctionObject> *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<QV4::IndexedBuiltinFunction>(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<CompilationUnitHolder>(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<CompilationUnitHolder>(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<QmlBindingWrapper>(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<QmlBindingWrapper>(scope, vmFunction, qmlObj)); return v.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index ed6e49034a..a45d047c28 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<SequenceType>()) { \ - QV4::Scoped<QV4::Object> obj(scope, new (engine) QQml##ElementTypeName##List::Data(engine, object, propertyIndex)); \ + QV4::Scoped<QV4::Object> obj(scope, engine->memoryManager->alloc<QQml##ElementTypeName##List>(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<SequenceType>()) { \ - QV4::Scoped<QV4::Object> obj(scope, new (engine) QQml##ElementTypeName##List::Data(engine, v.value<SequenceType >())); \ + QV4::Scoped<QV4::Object> obj(scope, engine->memoryManager->alloc<QQml##ElementTypeName##List>(engine, v.value<SequenceType >())); \ return obj.asReturnedValue(); \ } else |