aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/localstorage/plugin.cpp4
-rw-r--r--src/particles/qquickv4particledata.cpp2
-rw-r--r--src/qml/jsruntime/qv4context.cpp14
-rw-r--r--src/qml/jsruntime/qv4context_p.h6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp131
-rw-r--r--src/qml/jsruntime/qv4engine_p.h1
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4function.cpp3
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h13
-rw-r--r--src/qml/jsruntime/qv4managed.cpp8
-rw-r--r--src/qml/jsruntime/qv4managed_p.h1
-rw-r--r--src/qml/jsruntime/qv4mm.cpp2
-rw-r--r--src/qml/jsruntime/qv4mm_p.h52
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp6
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp11
-rw-r--r--src/qml/jsruntime/qv4regexp_p.h4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp8
-rw-r--r--src/qml/jsruntime/qv4script.cpp12
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp4
-rw-r--r--src/qml/qml/qqmlcomponent.cpp2
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp6
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp4
-rw-r--r--src/qml/qml/qqmllocale.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp4
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp12
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp18
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp6
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp14
-rw-r--r--src/qml/util/qqmladaptormodel.cpp8
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp21
-rw-r--r--src/quick/items/qquickview.cpp4
-rw-r--r--src/quick/items/qquickview_p.h2
-rw-r--r--tests/auto/qml/qv4debugger/tst_qv4debugger.cpp4
-rw-r--r--tools/qmljs/main.cpp4
36 files changed, 228 insertions, 187 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 651b8d466f..d7ef00bc98 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<QQmlSqlDatabaseWrapper>(e);
}
~QQmlSqlDatabaseWrapper() {
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index cfe99afafc..4046c9da2e 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<QV4ParticleData>(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 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 &param, 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
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 716aa31fdc..3cf39bd494 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<QmlIncubatorObject> r(scope, new (v4) QmlIncubatorObject::Data(args->engine(), mode));
+ QV4::Scoped<QmlIncubatorObject> r(scope, v4->memoryManager->alloc<QmlIncubatorObject>(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 53353f6f1a..83ef8c6230 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<QmlContextWrapper> w(valueScope, new (v4) QmlContextWrapper::Data(v8, ctxt, scope));
+ Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->alloc<QmlContextWrapper>(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<QmlContextWrapper> w(scope, new (v4) QmlContextWrapper::Data(v8, context, 0, true));
+ Scoped<QmlContextWrapper> w(scope, v4->memoryManager->alloc<QmlContextWrapper>(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<QQmlIdObjectsArray> a(scope, new (v4) QQmlIdObjectsArray::Data(v4, this));
+ Scoped<QQmlIdObjectsArray> a(scope, v4->memoryManager->alloc<QQmlIdObjectsArray>(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 6897b045dd..b84752501f 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<QmlListWrapper> r(scope, new (v4) QmlListWrapper::Data(v8));
+ Scoped<QmlListWrapper> r(scope, v4->memoryManager->alloc<QmlListWrapper>(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<QObje
ExecutionEngine *v4 = QV8Engine::getV4(v8);
Scope scope(v4);
- Scoped<QmlListWrapper> r(scope, new (v4) QmlListWrapper::Data(v8));
+ Scoped<QmlListWrapper> r(scope, v4->memoryManager->alloc<QmlListWrapper>(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 0d67b3a319..b1ce0da8e0 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<QQmlLocaleData> wrapper(scope, new (v4) QQmlLocaleData::Data(v4));
+ QV4::Scoped<QQmlLocaleData> wrapper(scope, v4->memoryManager->alloc<QQmlLocaleData>(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 8162777172..9501b705ba 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<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4) QV4::QmlBindingWrapper::Data(v4->rootContext, qmlScope));
+ QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(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<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, new (v4) QV4::QmlBindingWrapper::Data(v4->rootContext, qmlScope));
+ QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(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 958c51158c..53afd36437 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<QmlTypeWrapper> w(scope, new (v4) QmlTypeWrapper::Data(v8));
+ Scoped<QmlTypeWrapper> w(scope, v4->memoryManager->alloc<QmlTypeWrapper>(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<QmlTypeWrapper> w(scope, new (v4) QmlTypeWrapper::Data(v8));
+ Scoped<QmlTypeWrapper> w(scope, v4->memoryManager->alloc<QmlTypeWrapper>(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 f70daec3f6..52b45bd1bb 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<QmlValueTypeReference>(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<QmlValueTypeCopy>(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 f5de4af36e..d864c1f0b0 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<NodePrototype>(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<Node> instance(scope, new (v4) Node::Data(v4, data));
+ Scoped<Node> instance(scope, v4->memoryManager->alloc<Node>(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<Node>(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<NodeImpl *> &list)
{
ExecutionEngine *v4 = QV8Engine::getV4(engine);
- return (new (v4) NamedNodeMap::Data(v4, data, list))->asReturnedValue();
+ return (v4->memoryManager->alloc<NamedNodeMap>(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<NodeList>(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<QQmlXMLHttpRequestWrapper> w(scope, new (that->engine()) QQmlXMLHttpRequestWrapper::Data(that->engine(), r));
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, that->engine()->memoryManager->alloc<QQmlXMLHttpRequestWrapper>(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<QQmlXMLHttpRequestCtor> ctor(scope, new (v4) QQmlXMLHttpRequestCtor::Data(v4));
+ Scoped<QQmlXMLHttpRequestCtor> ctor(scope, v4->memoryManager->alloc<QQmlXMLHttpRequestCtor>(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 0d4ffaf9f8..e07d97e67c 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<QQmlBindingFunction>(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<QV4::ConsoleObject>(v4));
globalObject->defineDefaultProperty(QStringLiteral("console"), console);
- ScopedObject qt(scope, new (v4) QV4::QtObject::Data(v4, qmlEngine));
+ ScopedObject qt(scope, v4->memoryManager->alloc<QV4::QtObject>(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 c86da03276..7fd880681f 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<DelegateModelGroupFunction>(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<QQmlDelegateModelItemObject>(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<QQmlDelegateModelGroupChange>(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<QQmlChangeSet::Change> &changes)
+ static QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes)
{
- return new (engine) Data(engine, changes);
+ return engine->memoryManager->alloc<QQmlDelegateModelGroupChangeArray>(engine, changes);
}
quint32 count() const { return d()->changes.count(); }
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index d33000559b..6349c6fa31 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<QV4::IndexedBuiltinFunction>(v4->rootContext, propertyId, QQmlDMCachedModelData::get_property));
+ QV4::ScopedFunctionObject s(scope, v4->memoryManager->alloc<QV4::IndexedBuiltinFunction>(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<QQmlDelegateModelItemObject>(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<QQmlDelegateModelItemObject>(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 028054074e..d71f1da98f 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<QQuickJSContext2DPrototype>(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<QQuickJSContext2DPrototype*>(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<QQuickJSContext2DPixelData> pixelData(scope, new (scope.engine) QQuickJSContext2DPixelData::Data(v4));
+ QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, scope.engine->memoryManager->alloc<QQuickJSContext2DPixelData>(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<QQuickJSContext2DImageData> imageData(scope, new (scope.engine) QQuickJSContext2DImageData::Data(v4));
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, scope.engine->memoryManager->alloc<QQuickJSContext2DImageData>(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<QQuickContext2DStyle> gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->alloc<QQuickContext2DStyle>(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<QQuickContext2DStyle> gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->alloc<QQuickContext2DStyle>(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<QQuickContext2DStyle> gradient(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->alloc<QQuickContext2DStyle>(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<QQuickContext2DStyle> pattern(scope, new (scope.engine) QQuickContext2DStyle::Data(scope.engine));
+ QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->alloc<QQuickContext2DStyle>(scope.engine));
QColor color = engine->toVariant(ctx->d()->callData->args[0], qMetaTypeId<QColor>()).value<QColor>();
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<QQuickJSContext2D> wrapper(scope, new (v4Engine) QQuickJSContext2D::Data(v4Engine));
+ QV4::Scoped<QQuickJSContext2D> wrapper(scope, v4Engine->memoryManager->alloc<QQuickJSContext2D>(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 5e26cbeeb5..32fda331ee 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<QQuickRootItemMarker>(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 8b35500de9..4666ed4d4b 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 b7e5cf48e0..d7b1f2dbc3 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<QV4::String> 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 3fe3a0de8f..50bba820e5 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<builtins::Print>(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<builtins::GC>(ctx));
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
foreach (const QString &fn, args) {