aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-08-27 22:32:38 +0200
committerLars Knoll <lars.knoll@theqtcompany.com>2015-09-22 08:20:01 +0000
commitd7e535e99babae46d01311059f5ef6080dc90751 (patch)
treea526cf8c87c4838554fd7768bfca106e585b61ac
parent9420eb5c4e55d68b996bb0120db1f2dfeeef3a8c (diff)
Convert variant object and ObjectProto
Change-Id: I5ee3b453b74f5832997aca68d04979302f9afac5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/qml/jsruntime/qv4engine.cpp10
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp1
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp9
-rw-r--r--src/qml/jsruntime/qv4variantobject_p.h6
-rw-r--r--src/qml/memory/qv4mm_p.h13
5 files changed, 25 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index d881474bbc..19a4467ca8 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -298,7 +298,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
jsStrings[String_buffer] = newIdentifier(QStringLiteral("buffer"));
jsStrings[String_lastIndex] = newIdentifier(QStringLiteral("lastIndex"));
- jsObjects[ObjectProto] = memoryManager->alloc<ObjectPrototype>(emptyClass, (QV4::Object *)0);
+ jsObjects[ObjectProto] = memoryManager->allocObject<ObjectPrototype>(emptyClass);
arrayClass = emptyClass->addMember(id_length(), Attr_NotConfigurable|Attr_NotEnumerable);
jsObjects[ArrayProto] = memoryManager->allocObject<ArrayPrototype>(arrayClass, objectPrototype());
@@ -359,10 +359,10 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
jsObjects[TypeErrorProto] = memoryManager->alloc<TypeErrorPrototype>(emptyClass, errorPrototype());
jsObjects[URIErrorProto] = memoryManager->alloc<URIErrorPrototype>(emptyClass, errorPrototype());
- jsObjects[VariantProto] = memoryManager->alloc<VariantPrototype>(emptyClass, objectPrototype());
+ jsObjects[VariantProto] = memoryManager->allocObject<VariantPrototype>(emptyClass, objectPrototype());
Q_ASSERT(variantPrototype()->prototype() == objectPrototype()->d());
- jsObjects[SequenceProto] = ScopedValue(scope, memoryManager->alloc<SequencePrototype>(arrayClass, arrayPrototype()));
+ jsObjects[SequenceProto] = ScopedValue(scope, memoryManager->allocObject<SequencePrototype>(arrayClass, arrayPrototype()));
ExecutionContext *global = rootContext();
jsObjects[Object_Ctor] = memoryManager->alloc<ObjectCtor>(global);
@@ -723,9 +723,7 @@ Heap::Object *ExecutionEngine::newURIErrorObject(const Value &message)
Heap::Object *ExecutionEngine::newVariantObject(const QVariant &v)
{
- Scope scope(this);
- ScopedObject o(scope, memoryManager->alloc<VariantObject>(this, v));
- return o->d();
+ return memoryManager->allocObject<VariantObject>(emptyClass, variantPrototype(), v);
}
Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o)
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index a6c2a25b91..f052efe03e 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -63,7 +63,6 @@ using namespace QV4;
Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype)
: Heap::Object(ic, prototype)
- , stack(Q_NULLPTR)
{
Scope scope(ic->engine);
Scoped<QV4::ErrorObject> e(scope, this);
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index f9e26efe71..4609373cc9 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -43,12 +43,15 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(VariantObject);
-Heap::VariantObject::VariantObject(QV4::ExecutionEngine *engine, const QVariant &value)
- : Heap::Object(engine->emptyClass, engine->variantPrototype())
+Heap::VariantObject::VariantObject()
+{
+}
+
+Heap::VariantObject::VariantObject(const QVariant &value)
{
data = value;
if (isScarce())
- engine->scarceResources.insert(this);
+ internalClass->engine->scarceResources.insert(this);
}
bool VariantObject::Data::isScarce() const
diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h
index b19f12bb98..40a45f8eb5 100644
--- a/src/qml/jsruntime/qv4variantobject_p.h
+++ b/src/qml/jsruntime/qv4variantobject_p.h
@@ -60,10 +60,8 @@ namespace Heap {
struct VariantObject : Object, public ExecutionEngine::ScarceResourceData
{
- VariantObject(InternalClass *ic, QV4::Object *prototype)
- : Object(ic, prototype)
- {}
- VariantObject(QV4::ExecutionEngine *engine, const QVariant &value);
+ VariantObject();
+ VariantObject(const QVariant &value);
~VariantObject() {
if (isScarce())
node.remove();
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 6b6b502b95..d2071766e8 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -102,6 +102,19 @@ public:
}
template <typename ObjectType>
+ typename ObjectType::Data *allocObject(InternalClass *ic)
+ {
+ Scope scope(engine());
+ const int size = (sizeof(typename ObjectType::Data) + (sizeof(Value) - 1)) & ~(sizeof(Value) - 1);
+ Scoped<ObjectType> t(scope, allocManaged<ObjectType>(size + ic->size*sizeof(Value)));
+ t->d()->internalClass = ic;
+ t->d()->inlineMemberSize = ic->size;
+ t->d()->inlineMemberOffset = size/sizeof(Value);
+ (void)new (t->d()) typename ObjectType::Data();
+ return t->d();
+ }
+
+ template <typename ObjectType>
typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype)
{
Scope scope(engine());