aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-11-24 15:38:41 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-12-11 15:52:13 +0100
commit8afc1f7fe24c625cdb84406cc7665f1dcabf88c4 (patch)
tree04c5d73167544182e509ce7e40bd18c29909d0a7 /src/qml/jsruntime/qv4object.cpp
parent4322c8d7686c7cbbdf348146d32d705007b21d56 (diff)
Move prototype back from the vtable into Object
This is the only way we can support a GC that moves objects around in memory. Change-Id: I1d168fae4aa9f575b730e469e762bc5b5549b886 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index a9ce9b42f2..70152274e4 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -50,8 +50,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(Object);
-Heap::Object::Object(InternalClass *internalClass)
- : Heap::Base(internalClass)
+Heap::Object::Object(InternalClass *internalClass, QV4::Object *prototype)
+ : Heap::Base(internalClass),
+ prototype(prototype->d())
{
if (internalClass->size) {
Scope scope(internalClass->engine);
@@ -62,13 +63,13 @@ Heap::Object::Object(InternalClass *internalClass)
bool Object::setPrototype(Object *proto)
{
- Object *pp = proto;
+ Heap::Object *pp = proto->d();
while (pp) {
- if (pp == this)
+ if (pp == d())
return false;
- pp = pp->prototype();
+ pp = pp->prototype;
}
- setInternalClass(internalClass()->changePrototype(proto));
+ d()->prototype = proto->d();
return true;
}
@@ -187,6 +188,8 @@ void Object::markObjects(Heap::Base *that, ExecutionEngine *e)
o->memberData->mark(e);
if (o->arrayData)
o->arrayData->mark(e);
+ if (o->prototype)
+ o->prototype->mark(e);
}
void Object::ensureMemberIndex(uint idx)
@@ -1135,7 +1138,7 @@ void Object::initSparseArray()
DEFINE_OBJECT_VTABLE(ArrayObject);
Heap::ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list)
- : Heap::Object(engine->arrayClass)
+ : Heap::Object(engine->arrayClass, engine->arrayPrototype.asObject())
{
init();
Scope scope(engine);