aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-09-09 15:37:57 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-10-06 11:44:08 +0000
commit3b14e2ffdd8eb4b7f7f4508768b75f2acc399370 (patch)
tree7943f293bf2d0d376d5dc620448bab1a2b58027d /src/qml
parent1b90dc4482d001512f09a5785d4cbd8030879d82 (diff)
QML: Make Heap::Object and all subclasses trivial
GCC6 might dead-store-eliminate out our secret write to Base::mmdata, because it expects all memory content to be "undefined" before constructor calls. Clang might take the same approach if the constructor of Heap::Object is removed. By making these structs trivial, it also makes them memcpy-able. Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp10
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp5
-rw-r--r--src/qml/jsruntime/qv4argumentsobject_p.h22
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp12
-rw-r--r--src/qml/jsruntime/qv4arraybuffer_p.h6
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h4
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4arrayobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4booleanobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4context_p.h10
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp4
-rw-r--r--src/qml/jsruntime/qv4dataview_p.h4
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4dateobject_p.h14
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp73
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h38
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp63
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h38
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4globalobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp3
-rw-r--r--src/qml/jsruntime/qv4jsonobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4managed_p.h5
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp3
-rw-r--r--src/qml/jsruntime/qv4mathobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4memberdata_p.h2
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4numberobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4object.cpp6
-rw-r--r--src/qml/jsruntime/qv4object_p.h45
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp24
-rw-r--r--src/qml/jsruntime/qv4objectiterator_p.h51
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp4
-rw-r--r--src/qml/jsruntime/qv4objectproto_p.h2
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp42
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h24
-rw-r--r--src/qml/jsruntime/qv4regexp_p.h2
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp15
-rw-r--r--src/qml/jsruntime/qv4regexpobject_p.h8
-rw-r--r--src/qml/jsruntime/qv4script.cpp7
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp22
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4stringobject_p.h6
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp13
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h13
-rw-r--r--src/qml/jsruntime/qv4value_p.h2
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4variantobject_p.h4
-rw-r--r--src/qml/memory/qv4heap_p.h20
-rw-r--r--src/qml/memory/qv4mm_p.h40
-rw-r--r--src/qml/qml/qqmlcomponent.cpp9
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp9
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h2
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp21
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h11
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp5
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp39
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h18
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp43
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp21
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h15
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp28
-rw-r--r--src/qml/types/qqmldelegatemodel_p_p.h7
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h12
-rw-r--r--src/qml/util/qqmlchangeset_p.h25
69 files changed, 558 insertions, 433 deletions
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index 86c7554924..ce472ce7e5 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -103,11 +103,11 @@ QJSValueIterator::QJSValueIterator(const QJSValue& object)
return;
QV4::Scope scope(v4);
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->d()->it.flags = QV4::ObjectIterator::NoFlags;
+ it->d()->it().flags = QV4::ObjectIterator::NoFlags;
QV4::ScopedString nm(scope);
QV4::Property nextProperty;
QV4::PropertyAttributes nextAttributes;
- it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
+ it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
d_ptr->nextName.set(v4, nm.asReturnedValue());
}
@@ -157,7 +157,7 @@ bool QJSValueIterator::next()
QV4::ScopedString nm(scope);
QV4::Property nextProperty;
QV4::PropertyAttributes nextAttributes;
- it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
+ it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
d_ptr->nextName.set(v4, nm.asReturnedValue());
return d_ptr->currentName.as<QV4::String>() || d_ptr->currentIndex != UINT_MAX;
}
@@ -231,11 +231,11 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object)
QV4::ScopedObject o(scope, QJSValuePrivate::getValue(&object));
d_ptr->iterator.set(v4, v4->newForEachIteratorObject(o));
QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->d()->it.flags = QV4::ObjectIterator::NoFlags;
+ it->d()->it().flags = QV4::ObjectIterator::NoFlags;
QV4::ScopedString nm(scope);
QV4::Property nextProperty;
QV4::PropertyAttributes nextAttributes;
- it->d()->it.next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
+ it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
d_ptr->nextName.set(v4, nm.asReturnedValue());
return *this;
}
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 156c21ca66..0dfdf25158 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -45,9 +45,10 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArgumentsObject);
-Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
- : fullyCreated(false)
+void Heap::ArgumentsObject::init(QV4::CallContext *context)
{
+ Object::init();
+ fullyCreated = false;
this->context = context->d();
Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable());
diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h
index 6ccfd89fd4..37a8d0a94a 100644
--- a/src/qml/jsruntime/qv4argumentsobject_p.h
+++ b/src/qml/jsruntime/qv4argumentsobject_p.h
@@ -60,12 +60,12 @@ namespace QV4 {
namespace Heap {
struct ArgumentsGetterFunction : FunctionObject {
- inline ArgumentsGetterFunction(QV4::ExecutionContext *scope, uint index);
+ inline void init(QV4::ExecutionContext *scope, uint index);
uint index;
};
struct ArgumentsSetterFunction : FunctionObject {
- inline ArgumentsSetterFunction(QV4::ExecutionContext *scope, uint index);
+ inline void init(QV4::ExecutionContext *scope, uint index);
uint index;
};
@@ -75,7 +75,7 @@ struct ArgumentsObject : Object {
CalleePropertyIndex = 1,
CallerPropertyIndex = 3
};
- ArgumentsObject(QV4::CallContext *context);
+ void init(QV4::CallContext *context);
Pointer<CallContext> context;
bool fullyCreated;
Pointer<MemberData> mappedArguments;
@@ -91,11 +91,11 @@ struct ArgumentsGetterFunction: FunctionObject
static void call(const Managed *that, Scope &scope, CallData *d);
};
-inline
-Heap::ArgumentsGetterFunction::ArgumentsGetterFunction(QV4::ExecutionContext *scope, uint index)
- : Heap::FunctionObject(scope)
- , index(index)
+inline void
+Heap::ArgumentsGetterFunction::init(QV4::ExecutionContext *scope, uint index)
{
+ Heap::FunctionObject::init(scope);
+ this->index = index;
}
struct ArgumentsSetterFunction: FunctionObject
@@ -106,11 +106,11 @@ struct ArgumentsSetterFunction: FunctionObject
static void call(const Managed *that, Scope &scope, CallData *callData);
};
-inline
-Heap::ArgumentsSetterFunction::ArgumentsSetterFunction(QV4::ExecutionContext *scope, uint index)
- : Heap::FunctionObject(scope)
- , index(index)
+inline void
+Heap::ArgumentsSetterFunction::init(QV4::ExecutionContext *scope, uint index)
{
+ Heap::FunctionObject::init(scope);
+ this->index = index;
}
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index e88f17a658..908fa52680 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -46,9 +46,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArrayBufferCtor);
DEFINE_OBJECT_VTABLE(ArrayBuffer);
-Heap::ArrayBufferCtor::ArrayBufferCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("ArrayBuffer"))
+void Heap::ArrayBufferCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("ArrayBuffer"));
}
void ArrayBufferCtor::construct(const Managed *m, Scope &scope, CallData *callData)
@@ -94,8 +94,9 @@ ReturnedValue ArrayBufferCtor::method_isView(CallContext *ctx)
}
-Heap::ArrayBuffer::ArrayBuffer(size_t length)
+void Heap::ArrayBuffer::init(size_t length)
{
+ Object::init();
data = QTypedArrayData<char>::allocate(length + 1);
if (!data) {
data = 0;
@@ -106,9 +107,10 @@ Heap::ArrayBuffer::ArrayBuffer(size_t length)
memset(data->data(), 0, length + 1);
}
-Heap::ArrayBuffer::ArrayBuffer(const QByteArray& array)
- : data(const_cast<QByteArray&>(array).data_ptr())
+void Heap::ArrayBuffer::init(const QByteArray& array)
{
+ Object::init();
+ data = const_cast<QByteArray&>(array).data_ptr();
data->ref.ref();
}
diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h
index a5ca0f6bad..bc56d1ea31 100644
--- a/src/qml/jsruntime/qv4arraybuffer_p.h
+++ b/src/qml/jsruntime/qv4arraybuffer_p.h
@@ -60,12 +60,12 @@ namespace QV4 {
namespace Heap {
struct ArrayBufferCtor : FunctionObject {
- ArrayBufferCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object {
- ArrayBuffer(size_t length);
- ArrayBuffer(const QByteArray& array);
+ void init(size_t length);
+ void init(const QByteArray& array);
void destroy();
QTypedArrayData<char> *data;
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index ba0cc7cb30..9f810a32d5 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -133,7 +133,7 @@ struct ArrayData : public Base {
}
};
-Q_STATIC_ASSERT(std::is_trivial<ArrayData>::value);
+V4_ASSERT_IS_TRIVIAL(ArrayData)
struct SimpleArrayData : public ArrayData {
uint mappedIndex(uint index) const { return (index + offset) % alloc; }
@@ -153,7 +153,7 @@ struct SimpleArrayData : public ArrayData {
return attrs ? attrs[i] : Attr_Data;
}
};
-Q_STATIC_ASSERT(std::is_trivial<SimpleArrayData>::value);
+V4_ASSERT_IS_TRIVIAL(SimpleArrayData)
struct SparseArrayData : public ArrayData {
void destroy() { delete sparse; }
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 4d15c6c137..76faef137f 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -49,9 +49,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArrayCtor);
-Heap::ArrayCtor::ArrayCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Array"))
+void Heap::ArrayCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Array"));
}
void ArrayCtor::construct(const Managed *m, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h
index f49ed76b02..9a05bb8681 100644
--- a/src/qml/jsruntime/qv4arrayobject_p.h
+++ b/src/qml/jsruntime/qv4arrayobject_p.h
@@ -61,7 +61,7 @@ namespace QV4 {
namespace Heap {
struct ArrayCtor : FunctionObject {
- ArrayCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index 57c54e15c4..8047993266 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -45,9 +45,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(BooleanCtor);
DEFINE_OBJECT_VTABLE(BooleanObject);
-Heap::BooleanCtor::BooleanCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Boolean"))
+void Heap::BooleanCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Boolean"));
}
void BooleanCtor::construct(const Managed *, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4booleanobject_p.h b/src/qml/jsruntime/qv4booleanobject_p.h
index 17543e33e0..4c2f3c09e7 100644
--- a/src/qml/jsruntime/qv4booleanobject_p.h
+++ b/src/qml/jsruntime/qv4booleanobject_p.h
@@ -61,7 +61,7 @@ namespace QV4 {
namespace Heap {
struct BooleanCtor : FunctionObject {
- BooleanCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index ffedf737ce..0b42288ccc 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -128,7 +128,7 @@ struct ExecutionContext : Base {
bool strictMode : 8;
int lineNumber;
};
-Q_STATIC_ASSERT(std::is_trivial<ExecutionContext>::value);
+V4_ASSERT_IS_TRIVIAL(ExecutionContext)
struct CallContext : ExecutionContext {
static CallContext createOnStack(ExecutionEngine *v4);
@@ -145,20 +145,20 @@ struct CallContext : ExecutionContext {
Value *locals;
Pointer<Object> activation;
};
-Q_STATIC_ASSERT(std::is_trivial<CallContext>::value);
+V4_ASSERT_IS_TRIVIAL(CallContext)
struct GlobalContext : ExecutionContext {
void init(ExecutionEngine *engine);
Pointer<Object> global;
};
-Q_STATIC_ASSERT(std::is_trivial<GlobalContext>::value);
+V4_ASSERT_IS_TRIVIAL(GlobalContext)
struct CatchContext : ExecutionContext {
void init(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue);
Pointer<String> exceptionVarName;
Value exceptionValue;
};
-Q_STATIC_ASSERT(std::is_trivial<CatchContext>::value);
+V4_ASSERT_IS_TRIVIAL(CatchContext)
struct WithContext : ExecutionContext {
void init(ExecutionContext *outerContext, Object *with)
@@ -175,7 +175,7 @@ struct WithContext : ExecutionContext {
Pointer<Object> withObject;
};
-Q_STATIC_ASSERT(std::is_trivial<WithContext>::value);
+V4_ASSERT_IS_TRIVIAL(WithContext)
struct QmlContextWrapper;
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index fac3d5316c..db8376272d 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -49,9 +49,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(DataViewCtor);
DEFINE_OBJECT_VTABLE(DataView);
-Heap::DataViewCtor::DataViewCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("DataView"))
+void Heap::DataViewCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("DataView"));
}
void DataViewCtor::construct(const Managed *, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h
index f996a4c2f1..246124394a 100644
--- a/src/qml/jsruntime/qv4dataview_p.h
+++ b/src/qml/jsruntime/qv4dataview_p.h
@@ -60,11 +60,11 @@ namespace QV4 {
namespace Heap {
struct DataViewCtor : FunctionObject {
- DataViewCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct DataView : Object {
- DataView() {}
+ void init() { Object::init(); }
Pointer<ArrayBuffer> buffer;
uint byteLength;
uint byteOffset;
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 04358fe3b5..4f3138a452 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -634,13 +634,15 @@ static double getLocalTZA()
DEFINE_OBJECT_VTABLE(DateObject);
-Heap::DateObject::DateObject(const QDateTime &date)
+void Heap::DateObject::init(const QDateTime &date)
{
+ Object::init();
this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan();
}
-Heap::DateObject::DateObject(const QTime &time)
+void Heap::DateObject::init(const QTime &time)
{
+ Object::init();
if (!time.isValid()) {
date = qt_qnan();
return;
@@ -668,9 +670,9 @@ QDateTime DateObject::toQDateTime() const
DEFINE_OBJECT_VTABLE(DateCtor);
-Heap::DateCtor::DateCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Date"))
+void Heap::DateCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Date"));
}
void DateCtor::construct(const Managed *, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h
index c67acdcfa2..2d0648396e 100644
--- a/src/qml/jsruntime/qv4dateobject_p.h
+++ b/src/qml/jsruntime/qv4dateobject_p.h
@@ -63,24 +63,26 @@ namespace QV4 {
namespace Heap {
struct DateObject : Object {
- DateObject()
+ void init()
{
+ Object::init();
date = qt_qnan();
}
- DateObject(const Value &date)
+ void init(const Value &date)
{
+ Object::init();
this->date = date.toNumber();
}
- DateObject(const QDateTime &date);
- double date;
+ void init(const QDateTime &date);
+ void init(const QTime &time);
- DateObject(const QTime &time);
+ double date;
};
struct DateCtor : FunctionObject {
- DateCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index bb5d32cbd7..597ded6ae1 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -67,8 +67,9 @@
using namespace QV4;
-Heap::ErrorObject::ErrorObject()
+void Heap::ErrorObject::init()
{
+ Object::init();
stackTrace = nullptr;
Scope scope(internalClass->engine);
@@ -83,8 +84,9 @@ Heap::ErrorObject::ErrorObject()
*propertyData(QV4::ErrorObject::Index_LineNumber) = Encode::undefined();
}
-Heap::ErrorObject::ErrorObject(const Value &message, ErrorType t)
+void Heap::ErrorObject::init(const Value &message, ErrorType t)
{
+ Object::init();
errorType = t;
Scope scope(internalClass->engine);
@@ -103,8 +105,9 @@ Heap::ErrorObject::ErrorObject(const Value &message, ErrorType t)
*propertyData(QV4::ErrorObject::Index_Message) = message;
}
-Heap::ErrorObject::ErrorObject(const Value &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t)
+void Heap::ErrorObject::init(const Value &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t)
{
+ Object::init();
errorType = t;
Scope scope(internalClass->engine);
@@ -183,44 +186,44 @@ DEFINE_OBJECT_VTABLE(ErrorObject);
DEFINE_OBJECT_VTABLE(SyntaxErrorObject);
-Heap::SyntaxErrorObject::SyntaxErrorObject(const Value &msg)
- : Heap::ErrorObject(msg, SyntaxError)
+void Heap::SyntaxErrorObject::init(const Value &msg)
{
+ Heap::ErrorObject::init(msg, SyntaxError);
}
-Heap::SyntaxErrorObject::SyntaxErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber)
- : Heap::ErrorObject(msg, fileName, lineNumber, columnNumber, SyntaxError)
+void Heap::SyntaxErrorObject::init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber)
{
+ Heap::ErrorObject::init(msg, fileName, lineNumber, columnNumber, SyntaxError);
}
-Heap::EvalErrorObject::EvalErrorObject(const Value &message)
- : Heap::ErrorObject(message, EvalError)
+void Heap::EvalErrorObject::init(const Value &message)
{
+ Heap::ErrorObject::init(message, EvalError);
}
-Heap::RangeErrorObject::RangeErrorObject(const Value &message)
- : Heap::ErrorObject(message, RangeError)
+void Heap::RangeErrorObject::init(const Value &message)
{
+ Heap::ErrorObject::init(message, RangeError);
}
-Heap::ReferenceErrorObject::ReferenceErrorObject(const Value &message)
- : Heap::ErrorObject(message, ReferenceError)
+void Heap::ReferenceErrorObject::init(const Value &message)
{
+ Heap::ErrorObject::init(message, ReferenceError);
}
-Heap::ReferenceErrorObject::ReferenceErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber)
- : Heap::ErrorObject(msg, fileName, lineNumber, columnNumber, ReferenceError)
+void Heap::ReferenceErrorObject::init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber)
{
+ Heap::ErrorObject::init(msg, fileName, lineNumber, columnNumber, ReferenceError);
}
-Heap::TypeErrorObject::TypeErrorObject(const Value &message)
- : Heap::ErrorObject(message, TypeError)
+void Heap::TypeErrorObject::init(const Value &message)
{
+ Heap::ErrorObject::init(message, TypeError);
}
-Heap::URIErrorObject::URIErrorObject(const Value &message)
- : Heap::ErrorObject(message, URIError)
+void Heap::URIErrorObject::init(const Value &message)
{
+ Heap::ErrorObject::init(message, URIError);
}
DEFINE_OBJECT_VTABLE(ErrorCtor);
@@ -231,14 +234,14 @@ DEFINE_OBJECT_VTABLE(SyntaxErrorCtor);
DEFINE_OBJECT_VTABLE(TypeErrorCtor);
DEFINE_OBJECT_VTABLE(URIErrorCtor);
-Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Error"))
+void Heap::ErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Error"));
}
-Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope, const QString &name)
- : Heap::FunctionObject(scope, name)
+void Heap::ErrorCtor::init(QV4::ExecutionContext *scope, const QString &name)
{
+ Heap::FunctionObject::init(scope, name);
}
void ErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -252,9 +255,9 @@ void ErrorCtor::call(const Managed *that, Scope &scope, CallData *callData)
static_cast<const Object *>(that)->construct(scope, callData);
}
-Heap::EvalErrorCtor::EvalErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("EvalError"))
+void Heap::EvalErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("EvalError"));
}
void EvalErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -263,9 +266,9 @@ void EvalErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
scope.result = ErrorObject::create<EvalErrorObject>(scope.engine, v);
}
-Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("RangeError"))
+void Heap::RangeErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("RangeError"));
}
void RangeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -274,9 +277,9 @@ void RangeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData
scope.result = ErrorObject::create<RangeErrorObject>(scope.engine, v);
}
-Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("ReferenceError"))
+void Heap::ReferenceErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("ReferenceError"));
}
void ReferenceErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -285,9 +288,9 @@ void ReferenceErrorCtor::construct(const Managed *, Scope &scope, CallData *call
scope.result = ErrorObject::create<ReferenceErrorObject>(scope.engine, v);
}
-Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("SyntaxError"))
+void Heap::SyntaxErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("SyntaxError"));
}
void SyntaxErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -296,9 +299,9 @@ void SyntaxErrorCtor::construct(const Managed *, Scope &scope, CallData *callDat
scope.result = ErrorObject::create<SyntaxErrorObject>(scope.engine, v);
}
-Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("TypeError"))
+void Heap::TypeErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("TypeError"));
}
void TypeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
@@ -307,9 +310,9 @@ void TypeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
scope.result = ErrorObject::create<TypeErrorObject>(scope.engine, v);
}
-Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope)
- : Heap::ErrorCtor(scope, QStringLiteral("URIError"))
+void Heap::URIErrorCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::ErrorCtor::init(scope, QStringLiteral("URIError"));
}
void URIErrorCtor::construct(const Managed *, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index 206c7e6c59..b7a0889e08 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -73,9 +73,9 @@ struct ErrorObject : Object {
URIError
};
- ErrorObject();
- ErrorObject(const Value &message, ErrorType t = Error);
- ErrorObject(const Value &message, const QString &fileName, int line, int column, ErrorType t = Error);
+ void init();
+ void init(const Value &message, ErrorType t = Error);
+ void init(const Value &message, const QString &fileName, int line, int column, ErrorType t = Error);
void destroy() { delete stackTrace; }
ErrorType errorType;
@@ -84,58 +84,58 @@ struct ErrorObject : Object {
};
struct EvalErrorObject : ErrorObject {
- EvalErrorObject(const Value &message);
+ void init(const Value &message);
};
struct RangeErrorObject : ErrorObject {
- RangeErrorObject(const Value &message);
+ void init(const Value &message);
};
struct ReferenceErrorObject : ErrorObject {
- ReferenceErrorObject(const Value &message);
- ReferenceErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber);
+ void init(const Value &message);
+ void init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber);
};
struct SyntaxErrorObject : ErrorObject {
- SyntaxErrorObject(const Value &message);
- SyntaxErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber);
+ void init(const Value &message);
+ void init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber);
};
struct TypeErrorObject : ErrorObject {
- TypeErrorObject(const Value &message);
+ void init(const Value &message);
};
struct URIErrorObject : ErrorObject {
- URIErrorObject(const Value &message);
+ void init(const Value &message);
};
struct ErrorCtor : Heap::FunctionObject {
- ErrorCtor(QV4::ExecutionContext *scope);
- ErrorCtor(QV4::ExecutionContext *scope, const QString &name);
+ void init(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope, const QString &name);
};
struct EvalErrorCtor : ErrorCtor {
- EvalErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct RangeErrorCtor : ErrorCtor {
- RangeErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct ReferenceErrorCtor : ErrorCtor {
- ReferenceErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct SyntaxErrorCtor : ErrorCtor {
- SyntaxErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct TypeErrorCtor : ErrorCtor {
- TypeErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct URIErrorCtor : ErrorCtor {
- URIErrorCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index aa8c7d6a81..118ed89c43 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -68,18 +68,20 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(FunctionObject);
-Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
{
+ Object::init();
+ function = nullptr;
this->scope = scope->d();
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
f->init(name, createProto);
}
-Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *function, bool createProto)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto)
{
+ Object::init();
+ function = nullptr;
this->scope = scope->d();
Scope s(scope->engine());
ScopedString name(s, function->name());
@@ -87,9 +89,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *fun
f->init(name, createProto);
}
-Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString &name, bool createProto)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto)
{
+ Object::init();
+ function = nullptr;
this->scope = scope->d();
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
@@ -97,9 +100,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString
f->init(n, createProto);
}
-Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(ExecutionContext *scope, const QString &name, bool createProto)
{
+ Object::init();
+ function = nullptr;
this->scope = scope;
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
@@ -107,9 +111,10 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &nam
f->init(n, createProto);
}
-Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const ReturnedValue name)
{
+ Object::init();
+ function = nullptr;
this->scope = scope->d();
Scope s(scope);
ScopedFunctionObject f(s, this);
@@ -117,9 +122,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const Returne
f->init(n, false);
}
-Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init(ExecutionContext *scope, const ReturnedValue name)
{
+ Object::init();
+ function = nullptr;
this->scope = scope;
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
@@ -127,9 +133,10 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValu
f->init(n, false);
}
-Heap::FunctionObject::FunctionObject()
- : function(Q_NULLPTR)
+void Heap::FunctionObject::init()
{
+ Object::init();
+ function = nullptr;
this->scope = internalClass->engine->rootContext()->d();
Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype);
*propertyData(Index_Prototype) = Encode::undefined();
@@ -227,7 +234,7 @@ QQmlSourceLocation FunctionObject::sourceLocation() const
{
if (isBinding()) {
Q_ASSERT(as<const QV4::QQmlBindingFunction>());
- return static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation;
+ return *static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation;
}
QV4::Function *function = d()->function;
Q_ASSERT(function);
@@ -237,9 +244,9 @@ QQmlSourceLocation FunctionObject::sourceLocation() const
DEFINE_OBJECT_VTABLE(FunctionCtor);
-Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Function"))
+void Heap::FunctionCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Function"));
}
// 15.3.2
@@ -305,8 +312,9 @@ void FunctionCtor::call(const Managed *that, Scope &scope, CallData *callData)
DEFINE_OBJECT_VTABLE(FunctionPrototype);
-Heap::FunctionPrototype::FunctionPrototype()
+void Heap::FunctionPrototype::init()
{
+ Heap::FunctionObject::init();
}
void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor)
@@ -417,9 +425,9 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
DEFINE_OBJECT_VTABLE(ScriptFunction);
-Heap::ScriptFunction::ScriptFunction(QV4::ExecutionContext *scope, Function *function)
- : Heap::SimpleScriptFunction(scope, function, true)
+void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
{
+ Heap::SimpleScriptFunction::init(scope, function, true);
}
void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData)
@@ -478,8 +486,9 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData)
DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
-Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto)
+void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *function, bool createProto)
{
+ FunctionObject::init();
this->scope = scope->d();
this->function = function;
@@ -599,10 +608,10 @@ Heap::Object *SimpleScriptFunction::protoForConstructor()
DEFINE_OBJECT_VTABLE(BuiltinFunction);
-Heap::BuiltinFunction::BuiltinFunction(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *))
- : Heap::FunctionObject(scope, name)
- , code(code)
+void Heap::BuiltinFunction::init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *))
{
+ Heap::FunctionObject::init(scope, name);
+ this->code = code;
}
void BuiltinFunction::construct(const Managed *f, Scope &scope, CallData *)
@@ -656,10 +665,10 @@ DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction);
DEFINE_OBJECT_VTABLE(BoundFunction);
-Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target,
- const Value &boundThis, QV4::MemberData *boundArgs)
- : Heap::FunctionObject(scope, QStringLiteral("__bound function__"))
+void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject *target,
+ const Value &boundThis, QV4::MemberData *boundArgs)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("__bound function__"));
this->target = target->d();
this->boundArgs = boundArgs ? boundArgs->d() : 0;
this->boundThis = boundThis;
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index f5a9376b9e..e58b83e2c3 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -69,13 +69,13 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
Index_ProtoConstructor = 0
};
- FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false);
- FunctionObject(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false);
- FunctionObject(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name);
- FunctionObject(ExecutionContext *scope, const ReturnedValue name);
- FunctionObject();
+ void init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false);
+ void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false);
+ void init(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
+ void init(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
+ void init(QV4::ExecutionContext *scope, const ReturnedValue name);
+ void init(ExecutionContext *scope, const ReturnedValue name);
+ void init();
void destroy();
unsigned int formalParameterCount() { return function ? function->nFormals : 0; }
@@ -87,20 +87,20 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
};
struct FunctionCtor : FunctionObject {
- FunctionCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
struct FunctionPrototype : FunctionObject {
- FunctionPrototype();
+ void init();
};
struct Q_QML_EXPORT BuiltinFunction : FunctionObject {
- BuiltinFunction(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *));
+ void init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *));
ReturnedValue (*code)(QV4::CallContext *);
};
struct IndexedBuiltinFunction : FunctionObject {
- inline IndexedBuiltinFunction(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(QV4::CallContext *ctx, uint index));
+ inline void init(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(QV4::CallContext *ctx, uint index));
ReturnedValue (*code)(QV4::CallContext *, uint index);
uint index;
};
@@ -110,15 +110,15 @@ struct SimpleScriptFunction : FunctionObject {
Index_Name = FunctionObject::Index_Prototype + 1,
Index_Length
};
- SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto);
+ void init(QV4::ExecutionContext *scope, Function *function, bool createProto);
};
struct ScriptFunction : SimpleScriptFunction {
- ScriptFunction(QV4::ExecutionContext *scope, Function *function);
+ void init(QV4::ExecutionContext *scope, Function *function);
};
struct BoundFunction : FunctionObject {
- BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs);
+ void init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs);
Pointer<FunctionObject> target;
Value boundThis;
Pointer<MemberData> boundArgs;
@@ -216,12 +216,12 @@ struct IndexedBuiltinFunction: FunctionObject
static void call(const Managed *that, Scope &scope, CallData *callData);
};
-Heap::IndexedBuiltinFunction::IndexedBuiltinFunction(QV4::ExecutionContext *scope, uint index,
- ReturnedValue (*code)(QV4::CallContext *ctx, uint index))
- : Heap::FunctionObject(scope),
- code(code)
- , index(index)
+void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index,
+ ReturnedValue (*code)(QV4::CallContext *ctx, uint index))
{
+ Heap::FunctionObject::init(scope);
+ this->index = index;
+ this->code = code;
}
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index b88e271a26..feb0d90d26 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -330,9 +330,9 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
DEFINE_OBJECT_VTABLE(EvalFunction);
-Heap::EvalFunction::EvalFunction(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, scope->d()->engine->id_eval())
+void Heap::EvalFunction::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, scope->d()->engine->id_eval());
Scope s(scope);
ScopedFunctionObject f(s, this);
f->defineReadonlyProperty(s.engine->id_length(), Primitive::fromInt32(1));
diff --git a/src/qml/jsruntime/qv4globalobject_p.h b/src/qml/jsruntime/qv4globalobject_p.h
index 403639f8c1..e8b3a92d34 100644
--- a/src/qml/jsruntime/qv4globalobject_p.h
+++ b/src/qml/jsruntime/qv4globalobject_p.h
@@ -60,7 +60,7 @@ namespace QV4 {
namespace Heap {
struct EvalFunction : FunctionObject {
- EvalFunction(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 5b665d8836..9636fefc14 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -867,8 +867,9 @@ QString Stringify::JA(ArrayObject *a)
}
-Heap::JsonObject::JsonObject()
+void Heap::JsonObject::init()
{
+ Object::init();
Scope scope(internalClass->engine);
ScopedObject o(scope, this);
diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h
index c3a3b191c0..43248a214d 100644
--- a/src/qml/jsruntime/qv4jsonobject_p.h
+++ b/src/qml/jsruntime/qv4jsonobject_p.h
@@ -64,7 +64,7 @@ namespace QV4 {
namespace Heap {
struct JsonObject : Object {
- JsonObject();
+ void init();
};
}
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index b56155b5db..0359559f34 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -88,9 +88,10 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
QV4::Heap::DataClass *d() const { \
QV4::Heap::DataClass *dptr = d_unchecked(); \
- if (std::is_trivial<QV4::Heap::DataClass>::value) dptr->_checkIsInitialized(); \
+ dptr->_checkIsInitialized(); \
return dptr; \
- }
+ } \
+ V4_ASSERT_IS_TRIVIAL(QV4::Heap::DataClass)
#define V4_MANAGED(DataClass, superClass) \
private: \
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index 9fe8224736..e03b2762cc 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -51,8 +51,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(MathObject);
-Heap::MathObject::MathObject()
+void Heap::MathObject::init()
{
+ Object::init();
Scope scope(internalClass->engine);
ScopedObject m(scope, this);
diff --git a/src/qml/jsruntime/qv4mathobject_p.h b/src/qml/jsruntime/qv4mathobject_p.h
index 01e778d9ec..f6b1a4395f 100644
--- a/src/qml/jsruntime/qv4mathobject_p.h
+++ b/src/qml/jsruntime/qv4mathobject_p.h
@@ -59,7 +59,7 @@ namespace QV4 {
namespace Heap {
struct MathObject : Object {
- MathObject();
+ void init();
};
}
diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h
index 41da730428..969eee3619 100644
--- a/src/qml/jsruntime/qv4memberdata_p.h
+++ b/src/qml/jsruntime/qv4memberdata_p.h
@@ -66,7 +66,7 @@ struct MemberData : Base {
};
Value data[1];
};
-Q_STATIC_ASSERT(std::is_trivial<MemberData>::value);
+V4_ASSERT_IS_TRIVIAL(MemberData)
}
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index f8e0d8763b..1733df34ae 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -71,9 +71,9 @@ const NumberLocale *NumberLocale::instance()
return numberLocaleHolder();
}
-Heap::NumberCtor::NumberCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Number"))
+void Heap::NumberCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Number"));
}
void NumberCtor::construct(const Managed *, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4numberobject_p.h b/src/qml/jsruntime/qv4numberobject_p.h
index 2416165c78..6022b3a029 100644
--- a/src/qml/jsruntime/qv4numberobject_p.h
+++ b/src/qml/jsruntime/qv4numberobject_p.h
@@ -61,7 +61,7 @@ namespace QV4 {
namespace Heap {
struct NumberCtor : FunctionObject {
- NumberCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index aeb185049f..00e6d230da 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -1160,10 +1160,10 @@ void Object::initSparseArray()
DEFINE_OBJECT_VTABLE(ArrayObject);
-Heap::ArrayObject::ArrayObject(const QStringList &list)
- : Heap::Object()
+void Heap::ArrayObject::init(const QStringList &list)
{
- init();
+ Object::init();
+ commonInit();
Scope scope(internalClass->engine);
ScopedObject a(scope, this);
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 54ce2ea60d..6ddeb84d3c 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -68,7 +68,7 @@ namespace QV4 {
namespace Heap {
struct Object : Base {
- inline Object() { Base::init(); }
+ void init() { Base::init(); }
const Value *propertyData(uint index) const { if (index < inlineMemberSize) return reinterpret_cast<const Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; }
Value *propertyData(uint index) { if (index < inlineMemberSize) return reinterpret_cast<Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; }
@@ -93,9 +93,10 @@ struct Object : Base {
Data *d_unchecked() const { return static_cast<Data *>(m()); } \
Data *d() const { \
Data *dptr = d_unchecked(); \
- if (std::is_trivial<Data>::value) dptr->_checkIsInitialized(); \
+ dptr->_checkIsInitialized(); \
return dptr; \
- }
+ } \
+ V4_ASSERT_IS_TRIVIAL(Data);
#define V4_OBJECT2(DataClass, superClass) \
private: \
@@ -111,9 +112,10 @@ struct Object : Base {
QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
QV4::Heap::DataClass *d() const { \
QV4::Heap::DataClass *dptr = d_unchecked(); \
- if (std::is_trivial<QV4::Heap::DataClass>::value) dptr->_checkIsInitialized(); \
+ dptr->_checkIsInitialized(); \
return dptr; \
- }
+ } \
+ V4_ASSERT_IS_TRIVIAL(QV4::Heap::DataClass);
#define V4_INTERNALCLASS(c) \
static QV4::InternalClass *defaultInternalClass(QV4::ExecutionEngine *e) \
@@ -375,18 +377,22 @@ private:
namespace Heap {
struct BooleanObject : Object {
- BooleanObject() {}
- BooleanObject(bool b)
- : b(b)
- {}
+ void init() { Object::init(); }
+ void init(bool b) {
+ Object::init();
+ this->b = b;
+ }
+
bool b;
};
struct NumberObject : Object {
- NumberObject() {}
- NumberObject(double val)
- : value(val)
- {}
+ void init() { Object::init(); }
+ void init(double val) {
+ Object::init();
+ value = val;
+ }
+
double value;
};
@@ -395,10 +401,15 @@ struct ArrayObject : Object {
LengthPropertyIndex = 0
};
- ArrayObject()
- { init(); }
- ArrayObject(const QStringList &list);
- void init()
+ void init() {
+ Object::init();
+ commonInit();
+ }
+
+ void init(const QStringList &list);
+
+private:
+ void commonInit()
{ *propertyData(LengthPropertyIndex) = Primitive::fromInt32(0); }
};
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index 4354e09248..7943a13ac0 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -45,30 +45,6 @@
using namespace QV4;
-ObjectIterator::ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags)
- : engine(e)
- , object(scratch1)
- , current(scratch2)
- , arrayNode(0)
- , arrayIndex(0)
- , memberIndex(0)
- , flags(flags)
-{
- init(o);
-}
-
-ObjectIterator::ObjectIterator(Scope &scope, const Object *o, uint flags)
- : engine(scope.engine)
- , object(scope.alloc(1))
- , current(scope.alloc(1))
- , arrayNode(0)
- , arrayIndex(0)
- , memberIndex(0)
- , flags(flags)
-{
- init(o);
-}
-
void ObjectIterator::init(const Object *o)
{
object->setM(o ? o->m() : 0);
diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h
index 6bef703a4d..98e94a95ea 100644
--- a/src/qml/jsruntime/qv4objectiterator_p.h
+++ b/src/qml/jsruntime/qv4objectiterator_p.h
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
-struct Q_QML_EXPORT ObjectIterator
+struct Q_QML_EXPORT ObjectIteratorData
{
enum Flags {
NoFlags = 0,
@@ -72,21 +72,52 @@ struct Q_QML_EXPORT ObjectIterator
uint arrayIndex;
uint memberIndex;
uint flags;
+};
+V4_ASSERT_IS_TRIVIAL(ObjectIteratorData)
+
+struct Q_QML_EXPORT ObjectIterator: ObjectIteratorData
+{
+ ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags)
+ {
+ engine = e;
+ object = scratch1;
+ current = scratch2;
+ arrayNode = nullptr;
+ arrayIndex = 0;
+ memberIndex = 0;
+ this->flags = flags;
+ init(o);
+ }
+
+ ObjectIterator(Scope &scope, const Object *o, uint flags)
+ {
+ engine = scope.engine;
+ object = scope.alloc(1);
+ current = scope.alloc(1);
+ arrayNode = nullptr;
+ arrayIndex = 0;
+ memberIndex = 0;
+ this->flags = flags;
+ init(o);
+ }
- ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags);
- ObjectIterator(Scope &scope, const Object *o, uint flags);
- void init(const Object *o);
void next(Value *name, uint *index, Property *pd, PropertyAttributes *attributes = 0);
ReturnedValue nextPropertyName(Value *value);
ReturnedValue nextPropertyNameAsString(Value *value);
ReturnedValue nextPropertyNameAsString();
+
+private:
+ void init(const Object *o);
};
namespace Heap {
struct ForEachIteratorObject : Object {
- ForEachIteratorObject(QV4::Object *o);
- ObjectIterator it;
+ void init(QV4::Object *o);
+ ObjectIterator &it() { return *reinterpret_cast<ObjectIterator*>(&itData); }
Value workArea[2];
+
+private:
+ ObjectIteratorData itData;
};
}
@@ -95,16 +126,18 @@ struct ForEachIteratorObject: Object {
V4_OBJECT2(ForEachIteratorObject, Object)
Q_MANAGED_TYPE(ForeachIteratorObject)
- ReturnedValue nextPropertyName() { return d()->it.nextPropertyNameAsString(); }
+ ReturnedValue nextPropertyName() { return d()->it().nextPropertyNameAsString(); }
protected:
static void markObjects(Heap::Base *that, ExecutionEngine *e);
};
inline
-Heap::ForEachIteratorObject::ForEachIteratorObject(QV4::Object *o)
- : it(internalClass->engine, workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain)
+void Heap::ForEachIteratorObject::init(QV4::Object *o)
{
+ Object::init();
+ it() = ObjectIterator(internalClass->engine, workArea, workArea + 1, o,
+ ObjectIterator::EnumerableOnly | ObjectIterator::WithProtoChain);
}
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index cfd76166f2..6020c48250 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -54,9 +54,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ObjectCtor);
-Heap::ObjectCtor::ObjectCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("Object"))
+void Heap::ObjectCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("Object"));
}
void ObjectCtor::construct(const Managed *that, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h
index 47a37b196f..e3d85782d5 100644
--- a/src/qml/jsruntime/qv4objectproto_p.h
+++ b/src/qml/jsruntime/qv4objectproto_p.h
@@ -61,7 +61,7 @@ namespace QV4 {
namespace Heap {
struct ObjectCtor : FunctionObject {
- ObjectCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index c977573b9b..fc3d147c1d 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -195,8 +195,9 @@ static QV4::ReturnedValue loadProperty(QV4::ExecutionEngine *v4, QObject *object
}
}
-Heap::QObjectWrapper::QObjectWrapper(QObject *object)
+void Heap::QObjectWrapper::init(QObject *object)
{
+ Object::init();
qObj.init(object);
}
@@ -1680,7 +1681,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in
method->d()->setObject(object);
if (QQmlData *ddata = QQmlData::get(object))
- method->d()->propertyCache = ddata->propertyCache;
+ method->d()->setPropertyCache(ddata->propertyCache);
method->d()->index = index;
return method.asReturnedValue();
@@ -1690,21 +1691,21 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, const QQmlValueType
{
Scope valueScope(scope);
Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope));
- method->d()->propertyCache = valueType->d()->propertyCache;
+ method->d()->setPropertyCache(valueType->d()->propertyCache());
method->d()->index = index;
method->d()->valueTypeWrapper = valueType->d();
return method.asReturnedValue();
}
-Heap::QObjectMethod::QObjectMethod(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope)
+void Heap::QObjectMethod::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope);
}
const QMetaObject *Heap::QObjectMethod::metaObject()
{
- if (propertyCache)
- return propertyCache->createMetaObject();
+ if (propertyCache())
+ return propertyCache()->createMetaObject();
return object()->metaObject();
}
@@ -1776,13 +1777,13 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
return;
}
- object = QQmlObjectOrGadget(d()->propertyCache.data(), d()->valueTypeWrapper->gadgetPtr);
+ object = QQmlObjectOrGadget(d()->propertyCache(), d()->valueTypeWrapper->gadgetPtr);
}
QQmlPropertyData method;
- if (d()->propertyCache) {
- QQmlPropertyData *data = d()->propertyCache->method(d()->index);
+ if (d()->propertyCache()) {
+ QQmlPropertyData *data = d()->propertyCache()->method(d()->index);
if (!data) {
scope.result = QV4::Encode::undefined();
return;
@@ -1825,7 +1826,7 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
if (!method.isOverload()) {
scope.result = CallPrecise(object, method, v4, callData);
} else {
- scope.result = CallOverloaded(object, method, v4, callData, d()->propertyCache);
+ scope.result = CallOverloaded(object, method, v4, callData, d()->propertyCache());
}
}
@@ -1841,11 +1842,13 @@ void QObjectMethod::markObjects(Heap::Base *that, ExecutionEngine *e)
DEFINE_OBJECT_VTABLE(QObjectMethod);
-Heap::QMetaObjectWrapper::QMetaObjectWrapper(const QMetaObject *metaObject)
- : metaObject(metaObject)
- , constructors(nullptr)
- , constructorCount(0)
-{}
+void Heap::QMetaObjectWrapper::init(const QMetaObject *metaObject)
+{
+ FunctionObject::init();
+ this->metaObject = metaObject;
+ constructors = nullptr;
+ constructorCount = 0;
+}
void Heap::QMetaObjectWrapper::destroy()
{
@@ -2013,9 +2016,10 @@ DEFINE_OBJECT_VTABLE(QMetaObjectWrapper);
-Heap::QmlSignalHandler::QmlSignalHandler(QObject *object, int signalIndex)
- : signalIndex(signalIndex)
+void Heap::QmlSignalHandler::init(QObject *object, int signalIndex)
{
+ Object::init();
+ this->signalIndex = signalIndex;
setObject(object);
}
@@ -2023,7 +2027,7 @@ DEFINE_OBJECT_VTABLE(QmlSignalHandler);
void QmlSignalHandler::initProto(ExecutionEngine *engine)
{
- if (engine->signalHandlerPrototype()->d())
+ if (engine->signalHandlerPrototype()->d_unchecked())
return;
Scope scope(engine);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 37397db55b..727af6c9c6 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -78,7 +78,7 @@ namespace Heap {
struct QQmlValueTypeWrapper;
struct QObjectWrapper : Object {
- QObjectWrapper(QObject *object);
+ void init(QObject *object);
void destroy() { qObj.destroy(); }
QObject *object() const { return qObj.data(); }
@@ -88,16 +88,22 @@ private:
};
struct QObjectMethod : FunctionObject {
- QObjectMethod(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
void destroy()
{
- propertyCache = nullptr;
+ setPropertyCache(nullptr);
qObj.destroy();
FunctionObject::destroy();
}
- QQmlRefPointer<QQmlPropertyCache> propertyCache;
- int index;
+ QQmlPropertyCache *propertyCache() const { return _propertyCache; }
+ void setPropertyCache(QQmlPropertyCache *c) {
+ if (c)
+ c->addref();
+ if (_propertyCache)
+ _propertyCache->release();
+ _propertyCache = c;
+ }
Pointer<QQmlValueTypeWrapper> valueTypeWrapper;
@@ -107,6 +113,10 @@ struct QObjectMethod : FunctionObject {
private:
QQmlQPointer<QObject> qObj;
+ QQmlPropertyCache *_propertyCache;
+
+public:
+ int index;
};
struct QMetaObjectWrapper : FunctionObject {
@@ -114,13 +124,13 @@ struct QMetaObjectWrapper : FunctionObject {
QQmlPropertyData *constructors;
int constructorCount;
- QMetaObjectWrapper(const QMetaObject* metaObject);
+ void init(const QMetaObject* metaObject);
void destroy();
void ensureConstructorsCache();
};
struct QmlSignalHandler : Object {
- QmlSignalHandler(QObject *object, int signalIndex);
+ void init(QObject *object, int signalIndex);
void destroy() { qObj.destroy(); }
int signalIndex;
diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h
index b3bdeada94..d3e63375a5 100644
--- a/src/qml/jsruntime/qv4regexp_p.h
+++ b/src/qml/jsruntime/qv4regexp_p.h
@@ -91,7 +91,7 @@ struct RegExp : Base {
int captureCount() const { return subPatternCount + 1; }
};
-Q_STATIC_ASSERT(std::is_trivial<RegExp>::value);
+V4_ASSERT_IS_TRIVIAL(RegExp)
}
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index b8780b8c53..4022d98c3f 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -69,8 +69,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(RegExpObject);
-Heap::RegExpObject::RegExpObject()
+void Heap::RegExpObject::init()
{
+ Object::init();
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
o->d()->value = QV4::RegExp::create(scope.engine, QString(), false, false);
@@ -78,9 +79,10 @@ Heap::RegExpObject::RegExpObject()
o->initProperties();
}
-Heap::RegExpObject::RegExpObject(QV4::RegExp *value, bool global)
- : global(global)
+void Heap::RegExpObject::init(QV4::RegExp *value, bool global)
{
+ Object::init();
+ this->global = global;
this->value = value->d();
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
@@ -90,8 +92,9 @@ Heap::RegExpObject::RegExpObject(QV4::RegExp *value, bool global)
// Converts a QRegExp to a JS RegExp.
// The conversion is not 100% exact since ECMA regexp and QRegExp
// have different semantics/flags, but we try to do our best.
-Heap::RegExpObject::RegExpObject(const QRegExp &re)
+void Heap::RegExpObject::init(const QRegExp &re)
{
+ Object::init();
global = false;
// Convert the pattern to a ECMAScript pattern.
@@ -217,9 +220,9 @@ uint RegExpObject::flags() const
DEFINE_OBJECT_VTABLE(RegExpCtor);
-Heap::RegExpCtor::RegExpCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("RegExp"))
+void Heap::RegExpCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("RegExp"));
clearLastMatch();
}
diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h
index 655e120c16..2c82cfdfd1 100644
--- a/src/qml/jsruntime/qv4regexpobject_p.h
+++ b/src/qml/jsruntime/qv4regexpobject_p.h
@@ -74,16 +74,16 @@ namespace QV4 {
namespace Heap {
struct RegExpObject : Object {
- RegExpObject();
- RegExpObject(QV4::RegExp *value, bool global);
- RegExpObject(const QRegExp &re);
+ void init();
+ void init(QV4::RegExp *value, bool global);
+ void init(const QRegExp &re);
Pointer<RegExp> value;
bool global;
};
struct RegExpCtor : FunctionObject {
- RegExpCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
Value lastMatch;
Pointer<String> lastInput;
int lastMatchStart;
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index e3475e5cd6..787047806a 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -65,7 +65,7 @@ namespace QV4 {
namespace Heap {
struct QmlBindingWrapper : FunctionObject {
- QmlBindingWrapper(QV4::QmlContext *scope, Function *f);
+ void init(QV4::QmlContext *scope, Function *f);
};
}
@@ -84,9 +84,10 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlBindingWrapper);
-Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::QmlContext *scope, Function *f)
- : Heap::FunctionObject(scope, scope->d()->engine->id_eval(), /*createProto = */ false)
+void Heap::QmlBindingWrapper::init(QV4::QmlContext *scope, Function *f)
{
+ Heap::FunctionObject::init(scope, scope->d()->engine->id_eval(), /*createProto = */ false);
+
Q_ASSERT(scope->inUse());
function = f;
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index fb9ef4a2b2..4b82a7d83f 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -216,8 +216,8 @@ namespace Heap {
template <typename Container>
struct QQmlSequence : Object {
- QQmlSequence(const Container &container);
- QQmlSequence(QObject *object, int propertyIndex);
+ void init(const Container &container);
+ void init(QObject *object, int propertyIndex);
void destroy() {
delete container;
object.destroy();
@@ -557,11 +557,12 @@ public:
template <typename Container>
-Heap::QQmlSequence<Container>::QQmlSequence(const Container &container)
- : container(new Container(container))
- , propertyIndex(-1)
- , isReference(false)
+void Heap::QQmlSequence<Container>::init(const Container &container)
{
+ Object::init();
+ this->container = new Container(container);
+ propertyIndex = -1;
+ isReference = false;
object.init();
QV4::Scope scope(internalClass->engine);
@@ -571,11 +572,12 @@ Heap::QQmlSequence<Container>::QQmlSequence(const Container &container)
}
template <typename Container>
-Heap::QQmlSequence<Container>::QQmlSequence(QObject *object, int propertyIndex)
- : container(new Container)
- , propertyIndex(propertyIndex)
- , isReference(true)
+void Heap::QQmlSequence<Container>::init(QObject *object, int propertyIndex)
{
+ Object::init();
+ this->container = new Container;
+ this->propertyIndex = propertyIndex;
+ isReference = true;
this->object.init(object);
QV4::Scope scope(internalClass->engine);
QV4::Scoped<QV4::QQmlSequence<Container> > o(scope, this);
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 40c5c8a263..df34ec0151 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -133,7 +133,7 @@ private:
static void append(const String *data, QChar *ch);
#endif
};
-Q_STATIC_ASSERT(std::is_trivial<String>::value);
+V4_ASSERT_IS_TRIVIAL(String)
}
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 1c474fb18d..829ada0c1a 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -73,15 +73,17 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(StringObject);
-Heap::StringObject::StringObject()
+void Heap::StringObject::init()
{
+ Object::init();
Q_ASSERT(vtable() == QV4::StringObject::staticVTable());
string = internalClass->engine->id_empty()->d();
*propertyData(LengthPropertyIndex) = Primitive::fromInt32(0);
}
-Heap::StringObject::StringObject(const QV4::String *str)
+void Heap::StringObject::init(const QV4::String *str)
{
+ Object::init();
string = str->d();
*propertyData(LengthPropertyIndex) = Primitive::fromInt32(length());
}
@@ -152,9 +154,9 @@ void StringObject::markObjects(Heap::Base *that, ExecutionEngine *e)
DEFINE_OBJECT_VTABLE(StringCtor);
-Heap::StringCtor::StringCtor(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope, QStringLiteral("String"))
+void Heap::StringCtor::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope, QStringLiteral("String"));
}
void StringCtor::construct(const Managed *m, Scope &scope, CallData *callData)
diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h
index 54425b0909..b9f9d44fe8 100644
--- a/src/qml/jsruntime/qv4stringobject_p.h
+++ b/src/qml/jsruntime/qv4stringobject_p.h
@@ -65,8 +65,8 @@ struct StringObject : Object {
LengthPropertyIndex = 0
};
- StringObject();
- StringObject(const QV4::String *string);
+ void init();
+ void init(const QV4::String *string);
String *string;
Heap::String *getIndex(uint index) const;
@@ -74,7 +74,7 @@ struct StringObject : Object {
};
struct StringCtor : FunctionObject {
- StringCtor(QV4::ExecutionContext *scope);
+ void init(QV4::ExecutionContext *scope);
};
}
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index ae5ebcad1b..009c573bf8 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -202,10 +202,10 @@ const TypedArrayOperations operations[Heap::TypedArray::NTypes] = {
};
-Heap::TypedArrayCtor::TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::Type t)
- : Heap::FunctionObject(scope, QLatin1String(operations[t].name))
- , type(t)
+void Heap::TypedArrayCtor::init(QV4::ExecutionContext *scope, TypedArray::Type t)
{
+ Heap::FunctionObject::init(scope, QLatin1String(operations[t].name));
+ type = t;
}
void TypedArrayCtor::construct(const Managed *m, Scope &scope, CallData *callData)
@@ -363,10 +363,11 @@ void TypedArrayCtor::call(const Managed *that, Scope &scope, CallData *callData)
construct(that, scope, callData);
}
-Heap::TypedArray::TypedArray(Type t)
- : type(operations + t),
- arrayType(t)
+void Heap::TypedArray::init(Type t)
{
+ Object::init();
+ type = operations + t;
+ arrayType = t;
}
Heap::TypedArray *TypedArray::create(ExecutionEngine *e, Heap::TypedArray::Type t)
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index d96027b96a..0112d2e4a1 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -86,7 +86,7 @@ struct TypedArray : Object {
NTypes
};
- TypedArray(Type t);
+ void init(Type t);
const TypedArrayOperations *type;
Pointer<ArrayBuffer> buffer;
@@ -96,13 +96,13 @@ struct TypedArray : Object {
};
struct TypedArrayCtor : FunctionObject {
- TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::Type t);
+ void init(QV4::ExecutionContext *scope, TypedArray::Type t);
TypedArray::Type type;
};
struct TypedArrayPrototype : Object {
- inline TypedArrayPrototype(TypedArray::Type t);
+ inline void init(TypedArray::Type t);
TypedArray::Type type;
};
@@ -160,10 +160,11 @@ struct TypedArrayPrototype : Object
static ReturnedValue method_subarray(CallContext *ctx);
};
-inline
-Heap::TypedArrayPrototype::TypedArrayPrototype(TypedArray::Type t)
- : type(t)
+inline void
+Heap::TypedArrayPrototype::init(TypedArray::Type t)
{
+ Object::init();
+ type = t;
}
} // namespace QV4
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 78cd4de9fb..6e28e21887 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -428,7 +428,7 @@ public:
template<typename T>
Value &operator=(const Scoped<T> &t);
};
-Q_STATIC_ASSERT(std::is_trivial<Value>::value);
+V4_ASSERT_IS_TRIVIAL(Value)
inline bool Value::isString() const
{
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index eff4db268c..b26dd27913 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -50,13 +50,15 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(VariantObject);
-Heap::VariantObject::VariantObject()
+void Heap::VariantObject::init()
{
+ Object::init();
scarceData = new ExecutionEngine::ScarceResourceData;
}
-Heap::VariantObject::VariantObject(const QVariant &value)
+void Heap::VariantObject::init(const QVariant &value)
{
+ Object::init();
scarceData = new ExecutionEngine::ScarceResourceData(value);
if (isScarce())
removeVmePropertyReference();
diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h
index 5a6644bdcf..efaf5e1e65 100644
--- a/src/qml/jsruntime/qv4variantobject_p.h
+++ b/src/qml/jsruntime/qv4variantobject_p.h
@@ -66,8 +66,8 @@ namespace Heap {
struct VariantObject : Object
{
- VariantObject();
- VariantObject(const QVariant &value);
+ void init();
+ void init(const QVariant &value);
void destroy() {
Q_ASSERT(scarceData);
if (isScarce())
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index d15d14e463..abbe85c04e 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -58,6 +58,12 @@
// parent's init all up the inheritance chain), define QML_CHECK_INIT_DESTROY_CALLS below.
#undef QML_CHECK_INIT_DESTROY_CALLS
+#if defined(_MSC_VER) && (_MSC_VER < 1900) // broken compilers:
+# define V4_ASSERT_IS_TRIVIAL(x)
+#else // working compilers:
+# define V4_ASSERT_IS_TRIVIAL(x) Q_STATIC_ASSERT(std::is_trivial< x >::value);
+#endif
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -82,6 +88,8 @@ struct VTable
namespace Heap {
struct Q_QML_EXPORT Base {
+ void *operator new(size_t) = delete;
+
quintptr mm_data; // vtable and markbit
inline ReturnedValue asReturnedValue() const;
@@ -128,13 +136,19 @@ struct Q_QML_EXPORT Base {
void init() { setInitialized(); }
#ifdef QML_CHECK_INIT_DESTROY_CALLS
bool _isInitialized;
- void _checkIsInitialized() { Q_ASSERT(_isInitialized); }
+ void _checkIsInitialized() {
+ if (!_isInitialized)
+ fprintf(stderr, "ERROR: use of object '%s' before call to init() !!\n",
+ vtable()->className);
+ Q_ASSERT(_isInitialized);
+ }
void setInitialized() { Q_ASSERT(!_isInitialized); _isInitialized = true; }
#else
Q_ALWAYS_INLINE void _checkIsInitialized() {}
Q_ALWAYS_INLINE void setInitialized() {}
#endif
};
+V4_ASSERT_IS_TRIVIAL(Base)
template <typename T>
struct Pointer {
@@ -148,7 +162,7 @@ struct Pointer {
T *ptr;
};
-Q_STATIC_ASSERT(std::is_trivial<Pointer<void>>::value);
+V4_ASSERT_IS_TRIVIAL(Pointer<void>)
}
@@ -204,7 +218,7 @@ private:
QtSharedPointer::ExternalRefCountData *d;
QObject *qObject;
};
-Q_STATIC_ASSERT(std::is_trivial<QQmlQPointer<QObject>>::value);
+V4_ASSERT_IS_TRIVIAL(QQmlQPointer<QObject>)
#endif
}
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index cfd348e14a..e68fc07a46 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -108,6 +108,7 @@ public:
template<typename ManagedType>
inline typename ManagedType::Data *allocManaged(std::size_t size, std::size_t unmanagedSize = 0)
{
+ V4_ASSERT_IS_TRIVIAL(typename ManagedType::Data)
size = align(size);
Heap::Base *o = allocData(size, unmanagedSize);
o->setVtable(ManagedType::staticVTable());
@@ -142,7 +143,6 @@ public:
template <typename ManagedType, typename Arg1>
typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 arg1)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data), unmanagedSize));
t->d_unchecked()->init(this, arg1);
@@ -154,7 +154,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- (void)new (t->d()) typename ObjectType::Data();
+ t->d_unchecked()->init();
return t->d();
}
@@ -163,8 +163,8 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d()->prototype = prototype->d();
- (void)new (t->d()) typename ObjectType::Data();
+ t->d_unchecked()->prototype = prototype->d();
+ t->d_unchecked()->init();
return t->d();
}
@@ -173,8 +173,8 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d()->prototype = prototype->d();
- (void)new (t->d()) typename ObjectType::Data(arg1);
+ t->d_unchecked()->prototype = prototype->d();
+ t->d_unchecked()->init(arg1);
return t->d();
}
@@ -183,8 +183,8 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d()->prototype = prototype->d();
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2);
+ t->d_unchecked()->prototype = prototype->d();
+ t->d_unchecked()->init(arg1, arg2);
return t->d();
}
@@ -193,8 +193,8 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d()->prototype = prototype->d();
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2, arg3);
+ t->d_unchecked()->prototype = prototype->d();
+ t->d_unchecked()->init(arg1, arg2, arg3);
return t->d();
}
@@ -203,8 +203,8 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d()->prototype = prototype->d();
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2, arg3, arg4);
+ t->d_unchecked()->prototype = prototype->d();
+ t->d_unchecked()->init(arg1, arg2, arg3, arg4);
return t->d();
}
@@ -213,7 +213,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- (void)new (t->d()) typename ObjectType::Data();
+ t->d_unchecked()->init();
return t->d();
}
@@ -222,7 +222,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- (void)new (t->d()) typename ObjectType::Data(arg1);
+ t->d_unchecked()->init(arg1);
return t->d();
}
@@ -231,7 +231,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2);
+ t->d_unchecked()->init(arg1, arg2);
return t->d();
}
@@ -240,7 +240,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2, arg3);
+ t->d_unchecked()->init(arg1, arg2, arg3);
return t->d();
}
@@ -249,7 +249,7 @@ public:
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- (void)new (t->d()) typename ObjectType::Data(arg1, arg2, arg3, arg4);
+ t->d_unchecked()->init(arg1, arg2, arg3, arg4);
return t->d();
}
@@ -257,7 +257,6 @@ public:
template <typename ManagedType>
typename ManagedType::Data *alloc()
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init();
@@ -267,7 +266,6 @@ public:
template <typename ManagedType, typename Arg1>
typename ManagedType::Data *alloc(Arg1 arg1)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init(arg1);
@@ -277,7 +275,6 @@ public:
template <typename ManagedType, typename Arg1, typename Arg2>
typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init(arg1, arg2);
@@ -287,7 +284,6 @@ public:
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3>
typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init(arg1, arg2, arg3);
@@ -297,7 +293,6 @@ public:
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init(arg1, arg2, arg3, arg4);
@@ -307,7 +302,6 @@ public:
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
{
- Q_STATIC_ASSERT(std::is_trivial<typename ManagedType::Data>::value); // TODO: move down to allocManaged
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
t->d_unchecked()->init(arg1, arg2, arg3, arg4, arg5);
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 9a993d4ec3..23b8e5a712 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1058,7 +1058,7 @@ namespace QV4 {
namespace Heap {
struct QmlIncubatorObject : Object {
- QmlIncubatorObject(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
+ void init(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
inline void destroy();
QQmlComponentIncubator *incubator;
QQmlQPointer<QObject> parent;
@@ -1484,10 +1484,11 @@ QQmlComponentExtension::~QQmlComponentExtension()
{
}
-QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(QQmlIncubator::IncubationMode m)
- : valuemap(QV4::Primitive::undefinedValue())
- , statusChanged(QV4::Primitive::undefinedValue())
+void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
{
+ Object::init();
+ valuemap = QV4::Primitive::undefinedValue();
+ statusChanged = QV4::Primitive::undefinedValue();
parent.init();
qmlContext = nullptr;
incubator = new QQmlComponentIncubator(this, m);
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 95ff7b866f..8827216136 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -61,11 +61,12 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
-Heap::QmlContextWrapper::QmlContextWrapper(QQmlContextData *context, QObject *scopeObject, bool ownsContext)
- : readOnly(true)
- , ownsContext(ownsContext)
- , isNullWrapper(false)
+void Heap::QmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext)
{
+ Object::init();
+ readOnly = true;
+ this->ownsContext = ownsContext;
+ isNullWrapper = false;
this->context = new QQmlGuardedContextData(context);
this->scopeObject.init(scopeObject);
}
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 9e5ba4a10c..126ffecf0d 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -64,7 +64,7 @@ namespace QV4 {
namespace Heap {
struct QmlContextWrapper : Object {
- QmlContextWrapper(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
+ void init(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
void destroy();
bool readOnly;
bool ownsContext;
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 4bc0e11340..91225a1fea 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -52,8 +52,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlListWrapper);
-Heap::QmlListWrapper::QmlListWrapper()
+void Heap::QmlListWrapper::init()
{
+ Object::init();
object.init();
QV4::Scope scope(internalClass->engine);
QV4::ScopedObject o(scope, this);
@@ -75,7 +76,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, i
Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocObject<QmlListWrapper>());
r->d()->object = object;
r->d()->propertyType = propType;
- void *args[] = { &r->d()->property, 0 };
+ void *args[] = { &r->d()->property(), 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
return r.asReturnedValue();
}
@@ -86,7 +87,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, const QQmlListProp
Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocObject<QmlListWrapper>());
r->d()->object = prop.object;
- r->d()->property = prop;
+ r->d()->property() = prop;
r->d()->propertyType = propType;
return r.asReturnedValue();
}
@@ -96,7 +97,7 @@ QVariant QmlListWrapper::toVariant() const
if (!d()->object)
return QVariant();
- return QVariant::fromValue(QQmlListReferencePrivate::init(d()->property, d()->propertyType, engine()->qmlEngine()));
+ return QVariant::fromValue(QQmlListReferencePrivate::init(d()->property(), d()->propertyType, engine()->qmlEngine()));
}
@@ -107,7 +108,7 @@ ReturnedValue QmlListWrapper::get(const Managed *m, String *name, bool *hasPrope
QV4::ExecutionEngine *v4 = w->engine();
if (name->equals(v4->id_length()) && !w->d()->object.isNull()) {
- quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
return Primitive::fromUInt32(count).asReturnedValue();
}
@@ -126,11 +127,11 @@ ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *has
const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
QV4::ExecutionEngine *v4 = w->engine();
- quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
- if (index < count && w->d()->property.at) {
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
+ if (index < count && w->d()->property().at) {
if (hasProperty)
*hasProperty = true;
- return QV4::QObjectWrapper::wrap(v4, w->d()->property.at(&w->d()->property, index));
+ return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index));
}
if (hasProperty)
@@ -152,12 +153,12 @@ void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name
*index = UINT_MAX;
Q_ASSERT(m->as<QmlListWrapper>());
QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
- quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
if (it->arrayIndex < count) {
*index = it->arrayIndex;
++it->arrayIndex;
*attrs = QV4::Attr_Data;
- p->value = QV4::QObjectWrapper::wrap(w->engine(), w->d()->property.at(&w->d()->property, *index));
+ p->value = QV4::QObjectWrapper::wrap(w->engine(), w->d()->property().at(&w->d()->property(), *index));
return;
}
return QV4::Object::advanceIterator(m, it, name, index, p, attrs);
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 18038d2a80..d01b332159 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -66,11 +66,18 @@ namespace QV4 {
namespace Heap {
struct QmlListWrapper : Object {
- QmlListWrapper();
+ void init();
void destroy();
QQmlQPointer<QObject> object;
- QQmlListProperty<QObject> property;
+
+ QQmlListProperty<QObject> &property() {
+ return *reinterpret_cast<QQmlListProperty<QObject>*>(propertyData);
+ }
+
int propertyType;
+
+private:
+ void *propertyData[sizeof(QQmlListProperty<QObject>)/sizeof(void*)];
};
}
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 4494fa9b53..ea1b7bf369 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -143,7 +143,7 @@ namespace QV4 {
namespace Heap {
struct QQmlLocaleData : Object {
- inline QQmlLocaleData() { locale = new QLocale; }
+ inline void init() { locale = new QLocale; }
void destroy() { delete locale; }
QLocale *locale;
};
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index c8e2e5387c..a3ac207fc3 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -55,9 +55,10 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlTypeWrapper);
-Heap::QmlTypeWrapper::QmlTypeWrapper()
- : mode(IncludeEnums)
+void Heap::QmlTypeWrapper::init()
{
+ Object::init();
+ mode = IncludeEnums;
object.init();
}
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index fe75aefca9..3b0ae04cc1 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -71,7 +71,7 @@ struct QmlTypeWrapper : Object {
ExcludeEnums
};
- QmlTypeWrapper();
+ void init();
void destroy();
TypeNameMode mode;
QQmlQPointer<QObject> object;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 2279b72cbe..11849d2c63 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -63,8 +63,11 @@ namespace Heap {
struct QQmlValueTypeReference : QQmlValueTypeWrapper
{
- QQmlValueTypeReference() { object.init(); }
- ~QQmlValueTypeReference() { object.destroy(); }
+ void init() {
+ QQmlValueTypeWrapper::init();
+ object.init();
+ }
+ void destroy() { object.destroy(); }
QQmlQPointer<QObject> object;
int property;
};
@@ -86,7 +89,7 @@ DEFINE_OBJECT_VTABLE(QV4::QQmlValueTypeReference);
using namespace QV4;
-Heap::QQmlValueTypeWrapper::~QQmlValueTypeWrapper()
+void Heap::QQmlValueTypeWrapper::destroy()
{
if (gadgetPtr) {
valueType->metaType.destruct(gadgetPtr);
@@ -140,7 +143,7 @@ bool QQmlValueTypeReference::readReferenceValue() const
::operator delete(d()->gadgetPtr);
}
d()->gadgetPtr =0;
- d()->propertyCache = cache;
+ d()->setPropertyCache(cache);
d()->valueType = QQmlValueTypeFactory::valueType(variantReferenceType);
if (!cache)
return false;
@@ -163,7 +166,7 @@ bool QQmlValueTypeReference::readReferenceValue() const
void QQmlValueTypeWrapper::initProto(ExecutionEngine *v4)
{
- if (v4->valueTypeWrapperPrototype()->d())
+ if (v4->valueTypeWrapperPrototype()->d_unchecked())
return;
Scope scope(v4);
@@ -180,7 +183,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
Scoped<QQmlValueTypeReference> r(scope, engine->memoryManager->allocObject<QQmlValueTypeReference>());
r->d()->object = object;
r->d()->property = property;
- r->d()->propertyCache = QJSEnginePrivate::get(engine)->cache(metaObject);
+ r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
r->d()->valueType = QQmlValueTypeFactory::valueType(typeId);
r->d()->gadgetPtr = 0;
return r->asReturnedValue();
@@ -192,7 +195,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
initProto(engine);
Scoped<QQmlValueTypeWrapper> r(scope, engine->memoryManager->allocObject<QQmlValueTypeWrapper>());
- r->d()->propertyCache = QJSEnginePrivate::get(engine)->cache(metaObject);
+ r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
r->d()->valueType = QQmlValueTypeFactory::valueType(typeId);
r->d()->gadgetPtr = 0;
r->d()->setValue(value);
@@ -218,12 +221,6 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const
return true;
}
-void QQmlValueTypeWrapper::destroy(Heap::Base *that)
-{
- Heap::QQmlValueTypeWrapper *w = static_cast<Heap::QQmlValueTypeWrapper *>(that);
- w->Heap::QQmlValueTypeWrapper::~QQmlValueTypeWrapper();
-}
-
bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
{
Q_ASSERT(m && m->as<QQmlValueTypeWrapper>() && other);
@@ -243,7 +240,7 @@ PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, String *name)
Q_ASSERT(m->as<const QQmlValueTypeWrapper>());
const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
- QQmlPropertyData *result = r->d()->propertyCache->property(name, 0, 0);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(name, 0, 0);
return result ? Attr_Data : Attr_Invalid;
}
@@ -259,8 +256,8 @@ void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value
return;
}
- if (that->d()->propertyCache) {
- const QMetaObject *mo = that->d()->propertyCache->createMetaObject();
+ if (that->d()->propertyCache()) {
+ const QMetaObject *mo = that->d()->propertyCache()->createMetaObject();
const int propertyCount = mo->propertyCount();
if (it->arrayIndex < static_cast<uint>(propertyCount)) {
Scope scope(that->engine());
@@ -335,7 +332,7 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(CallContext *ctx)
} else {
result += QString::fromUtf8(QMetaType::typeName(w->d()->valueType->typeId))
+ QLatin1Char('(');
- const QMetaObject *mo = w->d()->propertyCache->metaObject();
+ const QMetaObject *mo = w->d()->propertyCache()->metaObject();
const int propCount = mo->propertyCount();
for (int i = 0; i < propCount; ++i) {
if (mo->property(i).isDesignable()) {
@@ -362,7 +359,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha
return Primitive::undefinedValue().asReturnedValue();
}
- QQmlPropertyData *result = r->d()->propertyCache->property(name, 0, 0);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(name, 0, 0);
if (!result)
return Object::get(m, name, hasProperty);
@@ -381,7 +378,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha
return QV4::Encode(constructor(v)); \
}
- const QMetaObject *metaObject = r->d()->propertyCache->metaObject();
+ const QMetaObject *metaObject = r->d()->propertyCache()->metaObject();
int index = result->coreIndex();
QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::ReadProperty, &metaObject, &index);
@@ -429,8 +426,8 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
writeBackPropertyType = writebackProperty.userType();
}
- const QMetaObject *metaObject = r->d()->propertyCache->metaObject();
- const QQmlPropertyData *pd = r->d()->propertyCache->property(name, 0, 0);
+ const QMetaObject *metaObject = r->d()->propertyCache()->metaObject();
+ const QQmlPropertyData *pd = r->d()->propertyCache()->property(name, 0, 0);
if (!pd)
return;
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 94eeba366a..b8ca5a16f4 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -66,14 +66,24 @@ namespace QV4 {
namespace Heap {
struct QQmlValueTypeWrapper : Object {
- QQmlValueTypeWrapper() {}
- ~QQmlValueTypeWrapper();
- QQmlRefPointer<QQmlPropertyCache> propertyCache;
+ void init() { Object::init(); }
+ void destroy();
+ QQmlPropertyCache *propertyCache() const { return _propertyCache; }
+ void setPropertyCache(QQmlPropertyCache *c) {
+ if (c)
+ c->addref();
+ if (_propertyCache)
+ _propertyCache->release();
+ _propertyCache = c;
+ }
mutable void *gadgetPtr;
QQmlValueType *valueType;
void setValue(const QVariant &value) const;
QVariant toVariant() const;
+
+private:
+ QQmlPropertyCache *_propertyCache;
};
}
@@ -82,7 +92,7 @@ struct Q_QML_EXPORT QQmlValueTypeWrapper : Object
{
V4_OBJECT2(QQmlValueTypeWrapper, Object)
V4_PROTOTYPE(valueTypeWrapperPrototype)
- static void destroy(Heap::Base *b);
+ V4_NEEDS_DESTROY
public:
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 5128fc0f08..fe2d7da694 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -174,7 +174,7 @@ public:
namespace Heap {
struct NamedNodeMap : Object {
- NamedNodeMap(NodeImpl *data, const QList<NodeImpl *> &list);
+ void init(NodeImpl *data, const QList<NodeImpl *> &list);
void destroy() {
delete listPtr;
if (d)
@@ -191,7 +191,7 @@ struct NamedNodeMap : Object {
};
struct NodeList : Object {
- NodeList(NodeImpl *data);
+ void init(NodeImpl *data);
void destroy() {
if (d)
d->release();
@@ -200,11 +200,11 @@ struct NodeList : Object {
};
struct NodePrototype : Object {
- NodePrototype();
+ void init();
};
struct Node : Object {
- Node(NodeImpl *data);
+ void init(NodeImpl *data);
void destroy() {
if (d)
d->release();
@@ -228,9 +228,10 @@ public:
static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
};
-Heap::NamedNodeMap::NamedNodeMap(NodeImpl *data, const QList<NodeImpl *> &list)
- : d(data)
+void Heap::NamedNodeMap::init(NodeImpl *data, const QList<NodeImpl *> &list)
{
+ Object::init();
+ d = data;
this->list() = list;
if (d)
d->addref();
@@ -253,9 +254,10 @@ public:
};
-Heap::NodeList::NodeList(NodeImpl *data)
- : d(data)
+void Heap::NodeList::init(NodeImpl *data)
{
+ Object::init();
+ d = data;
if (d)
d->addref();
}
@@ -294,8 +296,9 @@ public:
};
-Heap::NodePrototype::NodePrototype()
+void Heap::NodePrototype::init()
{
+ Object::init();
Scope scope(internalClass->engine);
ScopedObject o(scope, this);
@@ -327,9 +330,10 @@ struct Node : public Object
bool isNull() const;
};
-Heap::Node::Node(NodeImpl *data)
- : d(data)
+void Heap::Node::init(NodeImpl *data)
{
+ Object::init();
+ d = data;
if (d)
d->addref();
}
@@ -1594,7 +1598,11 @@ namespace QV4 {
namespace Heap {
struct QQmlXMLHttpRequestWrapper : Object {
- QQmlXMLHttpRequestWrapper(QQmlXMLHttpRequest *request);
+ void init(QQmlXMLHttpRequest *request) {
+ Object::init();
+ this->request = request;
+ }
+
void destroy() {
delete request;
}
@@ -1602,7 +1610,7 @@ struct QQmlXMLHttpRequestWrapper : Object {
};
struct QQmlXMLHttpRequestCtor : FunctionObject {
- QQmlXMLHttpRequestCtor(ExecutionEngine *engine);
+ void init(ExecutionEngine *engine);
Pointer<Object> proto;
};
@@ -1615,11 +1623,6 @@ struct QQmlXMLHttpRequestWrapper : public Object
V4_NEEDS_DESTROY
};
-Heap::QQmlXMLHttpRequestWrapper::QQmlXMLHttpRequestWrapper(QQmlXMLHttpRequest *request)
- : request(request)
-{
-}
-
struct QQmlXMLHttpRequestCtor : public FunctionObject
{
V4_OBJECT2(QQmlXMLHttpRequestCtor, FunctionObject)
@@ -1671,9 +1674,9 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
DEFINE_OBJECT_VTABLE(QQmlXMLHttpRequestWrapper);
-Heap::QQmlXMLHttpRequestCtor::QQmlXMLHttpRequestCtor(ExecutionEngine *engine)
- : Heap::FunctionObject(engine->rootContext(), QStringLiteral("XMLHttpRequest"))
+void Heap::QQmlXMLHttpRequestCtor::init(ExecutionEngine *engine)
{
+ Heap::FunctionObject::init(engine->rootContext(), QStringLiteral("XMLHttpRequest"));
Scope scope(engine);
Scoped<QV4::QQmlXMLHttpRequestCtor> ctor(scope, this);
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 222b61ae49..cf0fd57773 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -91,10 +91,11 @@ struct StaticQtMetaObject : public QObject
{ return &staticQtMetaObject; }
};
-Heap::QtObject::QtObject(QQmlEngine *qmlEngine)
- : enumeratorIterator(0)
- , keyIterator(0)
+void Heap::QtObject::init(QQmlEngine *qmlEngine)
{
+ Heap::Object::init();
+ enumeratorIterator = 0;
+ keyIterator = 0;
Scope scope(internalClass->engine);
ScopedObject o(scope, this);
@@ -1302,17 +1303,18 @@ ReturnedValue QtObject::method_locale(CallContext *ctx)
return QQmlLocale::locale(ctx->engine(), code);
}
-Heap::QQmlBindingFunction::QQmlBindingFunction(const QV4::FunctionObject *originalFunction)
- : QV4::Heap::FunctionObject(originalFunction->scope(), originalFunction->name())
+void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction)
{
+ QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name());
+ bindingLocation = new QQmlSourceLocation;
this->originalFunction = originalFunction->d();
}
void QQmlBindingFunction::initBindingLocation()
{
QV4::StackFrame frame = engine()->currentStackFrame();
- d()->bindingLocation.sourceFile = frame.source;
- d()->bindingLocation.line = frame.line;
+ d()->bindingLocation->sourceFile = frame.source;
+ d()->bindingLocation->line = frame.line;
}
void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData)
@@ -1436,8 +1438,9 @@ ReturnedValue QtObject::method_get_styleHints(CallContext *ctx)
}
-QV4::Heap::ConsoleObject::ConsoleObject()
+void QV4::Heap::ConsoleObject::init()
{
+ Object::init();
QV4::Scope scope(internalClass->engine);
QV4::ScopedObject o(scope, this);
@@ -1559,6 +1562,8 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c
return QV4::Encode::undefined();
}
+DEFINE_OBJECT_VTABLE(ConsoleObject);
+
QV4::ReturnedValue ConsoleObject::method_error(CallContext *ctx)
{
return writeToConsole(Error, ctx);
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index 8c0759679a..c4bb5504a3 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -64,7 +64,7 @@ namespace QV4 {
namespace Heap {
struct QtObject : Object {
- QtObject(QQmlEngine *qmlEngine);
+ void init(QQmlEngine *qmlEngine);
QObject *platform;
QObject *application;
@@ -77,14 +77,17 @@ struct QtObject : Object {
};
struct ConsoleObject : Object {
- ConsoleObject();
+ void init();
};
struct QQmlBindingFunction : FunctionObject {
- QQmlBindingFunction(const QV4::FunctionObject *originalFunction);
+ void init(const QV4::FunctionObject *originalFunction);
+ void destroy() {
+ delete bindingLocation;
+ }
Pointer<FunctionObject> originalFunction;
// Set when the binding is created later
- QQmlSourceLocation bindingLocation;
+ QQmlSourceLocation *bindingLocation;
};
}
@@ -145,9 +148,7 @@ private:
struct ConsoleObject : Object
{
- typedef Heap::ConsoleObject Data;
- const Data *d() const { return static_cast<const Data *>(Object::d()); }
- Data *d() { return static_cast<Data *>(Object::d()); }
+ V4_OBJECT2(ConsoleObject, Object)
static ReturnedValue method_error(CallContext *ctx);
static ReturnedValue method_log(CallContext *ctx);
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 02a5514275..395a3e5641 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -62,21 +62,24 @@ namespace QV4 {
namespace Heap {
struct DelegateModelGroupFunction : FunctionObject {
- DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg));
+ void init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg));
- uint flag;
QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg);
+ uint flag;
};
struct QQmlDelegateModelGroupChange : Object {
- QQmlDelegateModelGroupChange() {}
+ void init() { Object::init(); }
- QQmlChangeSet::Change change;
+ QQmlChangeSet::ChangeData change;
};
struct QQmlDelegateModelGroupChangeArray : Object {
- QQmlDelegateModelGroupChangeArray(const QVector<QQmlChangeSet::Change> &changes);
- void destroy() { delete changes; }
+ void init(const QVector<QQmlChangeSet::Change> &changes);
+ void destroy() {
+ delete changes;
+ }
+
QVector<QQmlChangeSet::Change> *changes;
};
@@ -106,11 +109,11 @@ struct DelegateModelGroupFunction : QV4::FunctionObject
}
};
-Heap::DelegateModelGroupFunction::DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg))
- : QV4::Heap::FunctionObject(scope, QStringLiteral("DelegateModelGroupFunction"))
- , flag(flag)
- , code(code)
+void Heap::DelegateModelGroupFunction::init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg))
{
+ QV4::Heap::FunctionObject::init(scope, QStringLiteral("DelegateModelGroupFunction"));
+ this->flag = flag;
+ this->code = code;
}
}
@@ -3300,9 +3303,10 @@ public:
}
};
-QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(const QVector<QQmlChangeSet::Change> &changes)
- : changes(new QVector<QQmlChangeSet::Change>(changes))
+void QV4::Heap::QQmlDelegateModelGroupChangeArray::init(const QVector<QQmlChangeSet::Change> &changes)
{
+ Object::init();
+ this->changes = new QVector<QQmlChangeSet::Change>(changes);
QV4::Scope scope(internalClass->engine);
QV4::ScopedObject o(scope, this);
o->setArrayType(QV4::Heap::ArrayData::Custom);
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index a34450ebd6..6cb82fddfc 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -160,7 +160,7 @@ protected:
namespace QV4 {
namespace Heap {
struct QQmlDelegateModelItemObject : Object {
- inline QQmlDelegateModelItemObject(QQmlDelegateModelItem *item);
+ inline void init(QQmlDelegateModelItem *item);
void destroy();
QQmlDelegateModelItem *item;
};
@@ -174,9 +174,10 @@ struct QQmlDelegateModelItemObject : QV4::Object
V4_NEEDS_DESTROY
};
-QV4::Heap::QQmlDelegateModelItemObject::QQmlDelegateModelItemObject(QQmlDelegateModelItem *item)
- : item(item)
+void QV4::Heap::QQmlDelegateModelItemObject::init(QQmlDelegateModelItem *item)
{
+ Object::init();
+ this->item = item;
}
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index d3ff032ae9..bd2102679b 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -162,11 +162,12 @@ namespace QV4 {
namespace Heap {
struct ModelObject : public QObjectWrapper {
- ModelObject(QObject *object, QQmlListModel *model, int elementIndex)
- : QObjectWrapper(object)
- , m_model(model)
- , m_elementIndex(elementIndex)
- {}
+ void init(QObject *object, QQmlListModel *model, int elementIndex)
+ {
+ QObjectWrapper::init(object);
+ m_model = model;
+ m_elementIndex = elementIndex;
+ }
QQmlListModel *m_model;
int m_elementIndex;
};
@@ -180,6 +181,7 @@ struct ModelObject : public QObjectWrapper
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
V4_OBJECT2(ModelObject, QObjectWrapper)
+ V4_NEEDS_DESTROY
};
} // namespace QV4
diff --git a/src/qml/util/qqmlchangeset_p.h b/src/qml/util/qqmlchangeset_p.h
index b7a637fb2e..8e1fa3f9f2 100644
--- a/src/qml/util/qqmlchangeset_p.h
+++ b/src/qml/util/qqmlchangeset_p.h
@@ -68,16 +68,31 @@ public:
int offset;
};
- struct Change
+ // The storrage for Change (below). This struct is trivial, which it has to be in order to store
+ // it in a QV4::Heap::Base object. The Change struct doesn't add any storage fields, so it is
+ // safe to cast ChangeData to/from Change.
+ struct ChangeData
{
- Change() : index(0), count(0), moveId(-1) {}
- Change(int index, int count, int moveId = -1, int offset = 0)
- : index(index), count(count), moveId(moveId), offset(offset) {}
-
int index;
int count;
int moveId;
int offset;
+ };
+
+ struct Change: ChangeData
+ {
+ Change() {
+ index = 0;
+ count = 0;
+ moveId = -1;
+ offset = 0;
+ }
+ Change(int index, int count, int moveId = -1, int offset = 0) {
+ this->index = index;
+ this->count = count;
+ this->moveId = moveId;
+ this->offset = offset;
+ }
bool isMove() const { return moveId >= 0; }