Remove the remaining bit of code that use the vtable in the internalClass
authorLars Knoll <lars.knoll@theqtcompany.com>
Sat, 10 Jan 2015 19:35:18 +0000 (20:35 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 21 Jan 2015 12:18:38 +0000 (13:18 +0100)
Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
25 files changed:
src/qml/compiler/qv4compileddata.cpp
src/qml/jsruntime/qv4arraybuffer.cpp
src/qml/jsruntime/qv4arraydata_p.h
src/qml/jsruntime/qv4dataview.cpp
src/qml/jsruntime/qv4dateobject.cpp
src/qml/jsruntime/qv4dateobject_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4engine_p.h
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4internalclass.cpp
src/qml/jsruntime/qv4internalclass_p.h
src/qml/jsruntime/qv4jsonobject.cpp
src/qml/jsruntime/qv4managed.cpp
src/qml/jsruntime/qv4mathobject.cpp
src/qml/jsruntime/qv4memberdata.cpp
src/qml/jsruntime/qv4object_p.h
src/qml/jsruntime/qv4regexp.cpp
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4regexpobject_p.h
src/qml/jsruntime/qv4sequenceobject.cpp
src/qml/jsruntime/qv4string.cpp
src/qml/jsruntime/qv4stringobject.cpp
src/qml/jsruntime/qv4typedarray.cpp
src/qml/jsruntime/qv4variantobject.cpp

index 65a14a3..8ac9a15 100644 (file)
@@ -120,7 +120,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
         for (uint i = 0; i < data->jsClassTableSize; ++i) {
             int memberCount = 0;
             const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount);
-            QV4::InternalClass *klass = engine->objectClass;
+            QV4::InternalClass *klass = engine->emptyClass;
             for (int j = 0; j < memberCount; ++j, ++member)
                 klass = klass->addMember(runtimeStrings[member->nameOffset]->identifier, member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
 
index f54161e..665d7cf 100644 (file)
@@ -84,7 +84,7 @@ ReturnedValue ArrayBufferCtor::method_isView(CallContext *ctx)
 
 
 Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, int length)
-    : Heap::Object(e->arrayBufferClass, e->arrayBufferPrototype.asObject())
+    : Heap::Object(e->emptyClass, e->arrayBufferPrototype.asObject())
 {
     data = QTypedArrayData<char>::allocate(length + 1);
     if (!data) {
index 2ba6ced..e32aea7 100644 (file)
@@ -119,7 +119,7 @@ struct ArrayData : public Base {
 
 struct SimpleArrayData : public ArrayData {
     SimpleArrayData(ExecutionEngine *engine)
-        : ArrayData(engine->simpleArrayDataClass)
+        : ArrayData(engine->emptyClass)
     {}
 
     uint mappedIndex(uint index) const { return (index + offset) % alloc; }
index 36d597f..6bbf9ee 100644 (file)
@@ -77,7 +77,7 @@ ReturnedValue DataViewCtor::call(Managed *that, CallData *callData)
 
 
 Heap::DataView::DataView(ExecutionEngine *e)
-    : Heap::Object(e->dataViewClass, e->dataViewPrototype.asObject()),
+    : Heap::Object(e->emptyClass, e->dataViewPrototype.asObject()),
       buffer(0),
       byteLength(0),
       byteOffset(0)
index 4379e3f..7c845fd 100644 (file)
@@ -631,7 +631,7 @@ static double getLocalTZA()
 DEFINE_OBJECT_VTABLE(DateObject);
 
 Heap::DateObject::DateObject(QV4::ExecutionEngine *engine, const QDateTime &date)
-    : Heap::Object(engine->dateClass, engine->datePrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->datePrototype.asObject())
 {
     setVTable(QV4::DateObject::staticVTable());
     value.setDouble(date.isValid() ? date.toMSecsSinceEpoch() : qSNaN());
index b164de6..9b0eb91 100644 (file)
@@ -53,7 +53,7 @@ struct DateObject : Object {
     }
 
     DateObject(QV4::ExecutionEngine *engine, const ValueRef date)
-        : Object(engine->dateClass, engine->datePrototype.asObject())
+        : Object(engine->emptyClass, engine->datePrototype.asObject())
     {
         value = date;
     }
index 0ee4daf..a48a78b 100644 (file)
@@ -244,9 +244,6 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     classPool = new InternalClassPool;
 
     emptyClass =  new (classPool) InternalClass(this);
-    executionContextClass = InternalClass::create(this, ExecutionContext::staticVTable());
-    stringClass = InternalClass::create(this, String::staticVTable());
-    regExpValueClass = InternalClass::create(this, RegExp::staticVTable());
 
     id_empty = newIdentifier(QString());
     id_undefined = newIdentifier(QStringLiteral("undefined"));
@@ -285,77 +282,49 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     id_buffer = newIdentifier(QStringLiteral("buffer"));
     id_lastIndex = newIdentifier(QStringLiteral("lastIndex"));
 
-    memberDataClass = InternalClass::create(this, MemberData::staticVTable());
+    objectPrototype = memoryManager->alloc<ObjectPrototype>(emptyClass, (QV4::Object *)0);
 
-    objectPrototype = memoryManager->alloc<ObjectPrototype>(InternalClass::create(this, ObjectPrototype::staticVTable()), (QV4::Object *)0);
-    objectClass = InternalClass::create(this, Object::staticVTable());
-    Q_ASSERT(objectClass->vtable == Object::staticVTable());
-
-    arrayClass = InternalClass::create(this, ArrayObject::staticVTable());
-    arrayClass = arrayClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable);
+    arrayClass = emptyClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable);
     arrayPrototype = memoryManager->alloc<ArrayPrototype>(arrayClass, objectPrototype.asObject());
 
-    simpleArrayDataClass = InternalClass::create(this, SimpleArrayData::staticVTable());
-
-    InternalClass *argsClass = InternalClass::create(this, ArgumentsObject::staticVTable());
-    argsClass = argsClass->addMember(id_length, Attr_NotEnumerable);
+    InternalClass *argsClass = emptyClass->addMember(id_length, Attr_NotEnumerable);
     argumentsObjectClass = argsClass->addMember(id_callee, Attr_Data|Attr_NotEnumerable);
     strictArgumentsObjectClass = argsClass->addMember(id_callee, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
     strictArgumentsObjectClass = strictArgumentsObjectClass->addMember(id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
-    Q_ASSERT(argumentsObjectClass->vtable == ArgumentsObject::staticVTable());
-    Q_ASSERT(strictArgumentsObjectClass->vtable == ArgumentsObject::staticVTable());
 
     m_globalObject = newObject();
     Q_ASSERT(globalObject()->d()->vtable);
     initRootContext();
 
-    stringPrototype = memoryManager->alloc<StringPrototype>(InternalClass::create(this, StringPrototype::staticVTable()), objectPrototype.asObject());
-    stringObjectClass = InternalClass::create(this, String::staticVTable());
-
-    numberPrototype = memoryManager->alloc<NumberPrototype>(InternalClass::create(this, NumberPrototype::staticVTable()), objectPrototype.asObject());
-    numberClass = InternalClass::create(this, NumberObject::staticVTable());
+    stringPrototype = memoryManager->alloc<StringPrototype>(emptyClass, objectPrototype.asObject());
+    numberPrototype = memoryManager->alloc<NumberPrototype>(emptyClass, objectPrototype.asObject());
+    booleanPrototype = memoryManager->alloc<BooleanPrototype>(emptyClass, objectPrototype.asObject());
+    datePrototype = memoryManager->alloc<DatePrototype>(emptyClass, objectPrototype.asObject());
 
-    booleanPrototype = memoryManager->alloc<BooleanPrototype>(InternalClass::create(this, BooleanPrototype::staticVTable()), objectPrototype.asObject());
-    booleanClass = InternalClass::create(this, BooleanObject::staticVTable());
-
-    datePrototype = memoryManager->alloc<DatePrototype>(InternalClass::create(this, DatePrototype::staticVTable()), objectPrototype.asObject());
-    dateClass = InternalClass::create(this, DateObject::staticVTable());
-
-    InternalClass *functionProtoClass = InternalClass::create(this, FunctionObject::staticVTable());
     uint index;
-    functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index);
+    InternalClass *functionProtoClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable, &index);
     Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
     functionPrototype = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype.asObject());
-    functionClass = InternalClass::create(this, FunctionObject::staticVTable());
-    functionClass = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
+    functionClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
     Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
-    protoClass = objectClass->addMember(id_constructor, Attr_NotEnumerable, &index);
+    protoClass = emptyClass->addMember(id_constructor, Attr_NotEnumerable, &index);
     Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
 
     regExpPrototype = memoryManager->alloc<RegExpPrototype>(this);
-    regExpClass = InternalClass::create(this, RegExpObject::staticVTable());
     regExpExecArrayClass = arrayClass->addMember(id_index, Attr_Data, &index);
     Q_ASSERT(index == RegExpObject::Index_ArrayIndex);
     regExpExecArrayClass = regExpExecArrayClass->addMember(id_input, Attr_Data, &index);
     Q_ASSERT(index == RegExpObject::Index_ArrayInput);
 
-    errorPrototype = memoryManager->alloc<ErrorPrototype>(InternalClass::create(this, ErrorObject::staticVTable()), objectPrototype.asObject());
-    errorClass = InternalClass::create(this, ErrorObject::staticVTable());
-    evalErrorPrototype = memoryManager->alloc<EvalErrorPrototype>(errorClass, errorPrototype.asObject());
-    evalErrorClass = InternalClass::create(this, EvalErrorObject::staticVTable());
-    rangeErrorPrototype = memoryManager->alloc<RangeErrorPrototype>(errorClass, errorPrototype.asObject());
-    rangeErrorClass = InternalClass::create(this, RangeErrorObject::staticVTable());
-    referenceErrorPrototype = memoryManager->alloc<ReferenceErrorPrototype>(errorClass, errorPrototype.asObject());
-    referenceErrorClass = InternalClass::create(this, ReferenceErrorObject::staticVTable());
-    syntaxErrorPrototype = memoryManager->alloc<SyntaxErrorPrototype>(errorClass, errorPrototype.asObject());
-    syntaxErrorClass = InternalClass::create(this, SyntaxErrorObject::staticVTable());
-    typeErrorPrototype = memoryManager->alloc<TypeErrorPrototype>(errorClass, errorPrototype.asObject());
-    typeErrorClass = InternalClass::create(this, TypeErrorObject::staticVTable());
-    uRIErrorPrototype = memoryManager->alloc<URIErrorPrototype>(errorClass, errorPrototype.asObject());
-    uriErrorClass = InternalClass::create(this, URIErrorObject::staticVTable());
-
-    variantPrototype = memoryManager->alloc<VariantPrototype>(InternalClass::create(this, VariantPrototype::staticVTable()), objectPrototype.asObject());
-    variantClass = InternalClass::create(this, VariantObject::staticVTable());
+    errorPrototype = memoryManager->alloc<ErrorPrototype>(emptyClass, objectPrototype.asObject());
+    evalErrorPrototype = memoryManager->alloc<EvalErrorPrototype>(emptyClass, errorPrototype.asObject());
+    rangeErrorPrototype = memoryManager->alloc<RangeErrorPrototype>(emptyClass, errorPrototype.asObject());
+    referenceErrorPrototype = memoryManager->alloc<ReferenceErrorPrototype>(emptyClass, errorPrototype.asObject());
+    syntaxErrorPrototype = memoryManager->alloc<SyntaxErrorPrototype>(emptyClass, errorPrototype.asObject());
+    typeErrorPrototype = memoryManager->alloc<TypeErrorPrototype>(emptyClass, errorPrototype.asObject());
+    uRIErrorPrototype = memoryManager->alloc<URIErrorPrototype>(emptyClass, errorPrototype.asObject());
+
+    variantPrototype = memoryManager->alloc<VariantPrototype>(emptyClass, objectPrototype.asObject());
     Q_ASSERT(variantPrototype.asObject()->prototype() == objectPrototype.asObject()->d());
 
     sequencePrototype = ScopedValue(scope, memoryManager->alloc<SequencePrototype>(arrayClass, arrayPrototype.asObject()));
@@ -400,20 +369,17 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     // typed arrays
 
     arrayBufferCtor = memoryManager->alloc<ArrayBufferCtor>(global);
-    arrayBufferPrototype = memoryManager->alloc<ArrayBufferPrototype>(objectClass, objectPrototype.asObject());
+    arrayBufferPrototype = memoryManager->alloc<ArrayBufferPrototype>(emptyClass, objectPrototype.asObject());
     static_cast<ArrayBufferPrototype *>(arrayBufferPrototype.asObject())->init(this, arrayBufferCtor.asObject());
-    arrayBufferClass = InternalClass::create(this, ArrayBuffer::staticVTable());
 
     dataViewCtor = memoryManager->alloc<DataViewCtor>(global);
-    dataViewPrototype = memoryManager->alloc<DataViewPrototype>(objectClass, objectPrototype.asObject());
+    dataViewPrototype = memoryManager->alloc<DataViewPrototype>(emptyClass, objectPrototype.asObject());
     static_cast<DataViewPrototype *>(dataViewPrototype.asObject())->init(this, dataViewCtor.asObject());
-    dataViewClass = InternalClass::create(this, DataView::staticVTable());
 
     for (int i = 0; i < Heap::TypedArray::NTypes; ++i) {
         typedArrayCtors[i] = memoryManager->alloc<TypedArrayCtor>(global, Heap::TypedArray::Type(i));
         typedArrayPrototype[i] = memoryManager->alloc<TypedArrayPrototype>(this, Heap::TypedArray::Type(i));
         typedArrayPrototype[i].as<TypedArrayPrototype>()->init(this, static_cast<TypedArrayCtor *>(typedArrayCtors[i].asObject()));
-        typedArrayClasses[i] = InternalClass::create(this, TypedArray::staticVTable());
     }
 
     //
@@ -662,7 +628,7 @@ Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re)
 Heap::Object *ExecutionEngine::newErrorObject(const ValueRef value)
 {
     Scope scope(this);
-    ScopedObject object(scope, memoryManager->alloc<ErrorObject>(errorClass, errorPrototype.asObject(), value));
+    ScopedObject object(scope, memoryManager->alloc<ErrorObject>(emptyClass, errorPrototype.asObject(), value));
     return object->d();
 }
 
index 8b813ea..081124f 100644 (file)
@@ -165,41 +165,17 @@ public:
 
     InternalClassPool *classPool;
     InternalClass *emptyClass;
-    InternalClass *executionContextClass;
-    InternalClass *stringClass;
 
-    InternalClass *objectClass;
     InternalClass *arrayClass;
-    InternalClass *simpleArrayDataClass;
-    InternalClass *stringObjectClass;
-    InternalClass *booleanClass;
-    InternalClass *numberClass;
-    InternalClass *dateClass;
 
     InternalClass *functionClass;
     InternalClass *protoClass;
 
-    InternalClass *regExpClass;
     InternalClass *regExpExecArrayClass;
-    InternalClass *regExpValueClass;
-
-    InternalClass *errorClass;
-    InternalClass *evalErrorClass;
-    InternalClass *rangeErrorClass;
-    InternalClass *referenceErrorClass;
-    InternalClass *syntaxErrorClass;
-    InternalClass *typeErrorClass;
-    InternalClass *uriErrorClass;
+
     InternalClass *argumentsObjectClass;
     InternalClass *strictArgumentsObjectClass;
 
-    InternalClass *variantClass;
-    InternalClass *memberDataClass;
-
-    InternalClass *arrayBufferClass;
-    InternalClass *dataViewClass;
-    InternalClass *typedArrayClasses[NTypedArrayTypes]; // TypedArray::NValues, avoid including the header here
-
     Heap::EvalFunction *evalFunction;
     Heap::FunctionObject *thrower;
 
@@ -382,7 +358,7 @@ inline Heap::ExecutionContext *ExecutionEngine::popContext()
 
 inline
 Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t)
-    : Heap::Base(engine->executionContextClass)
+    : Heap::Base(engine->emptyClass)
     , type(t)
     , strictMode(false)
     , engine(engine)
index eda3714..2eceab9 100644 (file)
@@ -183,57 +183,57 @@ DEFINE_OBJECT_VTABLE(ErrorObject);
 DEFINE_OBJECT_VTABLE(SyntaxErrorObject);
 
 Heap::SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const ValueRef msg)
-    : Heap::ErrorObject(engine->syntaxErrorClass, engine->syntaxErrorPrototype.asObject(), msg, SyntaxError)
+    : Heap::ErrorObject(engine->emptyClass, engine->syntaxErrorPrototype.asObject(), msg, SyntaxError)
 {
 }
 
 Heap::SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber)
-    : Heap::ErrorObject(engine->syntaxErrorClass, engine->syntaxErrorPrototype.asObject(), msg, fileName, lineNumber, columnNumber, SyntaxError)
+    : Heap::ErrorObject(engine->emptyClass, engine->syntaxErrorPrototype.asObject(), msg, fileName, lineNumber, columnNumber, SyntaxError)
 {
 }
 
 Heap::EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const ValueRef message)
-    : Heap::ErrorObject(engine->evalErrorClass, engine->evalErrorPrototype.asObject(), message, EvalError)
+    : Heap::ErrorObject(engine->emptyClass, engine->evalErrorPrototype.asObject(), message, EvalError)
 {
 }
 
 Heap::RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const ValueRef message)
-    : Heap::ErrorObject(engine->rangeErrorClass, engine->rangeErrorPrototype.asObject(), message, RangeError)
+    : Heap::ErrorObject(engine->emptyClass, engine->rangeErrorPrototype.asObject(), message, RangeError)
 {
 }
 
 Heap::RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const QString &message)
-    : Heap::ErrorObject(engine->rangeErrorClass, engine->rangeErrorPrototype.asObject(), message, RangeError)
+    : Heap::ErrorObject(engine->emptyClass, engine->rangeErrorPrototype.asObject(), message, RangeError)
 {
 }
 
 Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const ValueRef message)
-    : Heap::ErrorObject(engine->referenceErrorClass, engine->referenceErrorPrototype.asObject(), message, ReferenceError)
+    : Heap::ErrorObject(engine->emptyClass, engine->referenceErrorPrototype.asObject(), message, ReferenceError)
 {
 }
 
 Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &message)
-    : Heap::ErrorObject(engine->referenceErrorClass, engine->referenceErrorPrototype.asObject(), message, ReferenceError)
+    : Heap::ErrorObject(engine->emptyClass, engine->referenceErrorPrototype.asObject(), message, ReferenceError)
 {
 }
 
 Heap::ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber)
-    : Heap::ErrorObject(engine->referenceErrorClass, engine->referenceErrorPrototype.asObject(), msg, fileName, lineNumber, columnNumber, ReferenceError)
+    : Heap::ErrorObject(engine->emptyClass, engine->referenceErrorPrototype.asObject(), msg, fileName, lineNumber, columnNumber, ReferenceError)
 {
 }
 
 Heap::TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const ValueRef message)
-    : Heap::ErrorObject(engine->typeErrorClass, engine->typeErrorPrototype.asObject(), message, TypeError)
+    : Heap::ErrorObject(engine->emptyClass, engine->typeErrorPrototype.asObject(), message, TypeError)
 {
 }
 
 Heap::TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const QString &message)
-    : Heap::ErrorObject(engine->typeErrorClass, engine->typeErrorPrototype.asObject(), message, TypeError)
+    : Heap::ErrorObject(engine->emptyClass, engine->typeErrorPrototype.asObject(), message, TypeError)
 {
 }
 
 Heap::URIErrorObject::URIErrorObject(ExecutionEngine *engine, const ValueRef message)
-    : Heap::ErrorObject(engine->uriErrorClass, engine->uRIErrorPrototype.asObject(), message, URIError)
+    : Heap::ErrorObject(engine->emptyClass, engine->uRIErrorPrototype.asObject(), message, URIError)
 {
 }
 
index 3f06776..3f1f9e1 100644 (file)
@@ -403,7 +403,7 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
     Scope scope(v4);
     Scoped<ScriptFunction> f(scope, static_cast<ScriptFunction *>(that));
 
-    InternalClass *ic = scope.engine->objectClass;
+    InternalClass *ic = scope.engine->emptyClass;
     ScopedObject proto(scope, f->protoForConstructor());
     ScopedObject obj(scope, v4->newObject(ic, proto));
 
@@ -487,7 +487,7 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
     Scope scope(v4);
     Scoped<SimpleScriptFunction> f(scope, static_cast<SimpleScriptFunction *>(that));
 
-    InternalClass *ic = scope.engine->objectClass;
+    InternalClass *ic = scope.engine->emptyClass;
     ScopedObject proto(scope, f->protoForConstructor());
     callData->thisObject = v4->newObject(ic, proto);
 
index 82c7133..e1d5746 100644 (file)
@@ -112,7 +112,6 @@ uint PropertyHash::lookup(const Identifier *identifier) const
 
 InternalClass::InternalClass(ExecutionEngine *engine)
     : engine(engine)
-    , vtable(&QV4::Managed::static_vtbl)
     , m_sealed(0)
     , m_frozen(0)
     , size(0)
@@ -124,7 +123,6 @@ InternalClass::InternalClass(ExecutionEngine *engine)
 InternalClass::InternalClass(const QV4::InternalClass &other)
     : QQmlJS::Managed()
     , engine(other.engine)
-    , vtable(other.vtable)
     , propertyTable(other.propertyTable)
     , nameMap(other.nameMap)
     , propertyData(other.propertyData)
@@ -176,13 +174,13 @@ InternalClass *InternalClass::changeMember(Identifier *identifier, PropertyAttri
     if (data == propertyData.at(idx))
         return this;
 
-    Transition temp = { { identifier }, 0, (int)data.flags() };
+    Transition temp = { identifier, 0, (int)data.flags() };
     Transition &t = lookupOrInsertTransition(temp);
     if (t.lookup)
         return t.lookup;
 
     // create a new class and add it to the tree
-    InternalClass *newClass = engine->emptyClass->changeVTable(vtable);
+    InternalClass *newClass = engine->emptyClass;
     for (uint i = 0; i < size; ++i) {
         if (i == idx) {
             newClass = newClass->addMember(nameMap.at(i), data);
@@ -196,50 +194,12 @@ InternalClass *InternalClass::changeMember(Identifier *identifier, PropertyAttri
     return newClass;
 }
 
-InternalClass *InternalClass::create(ExecutionEngine *engine, const ManagedVTable *vtable)
-{
-    return engine->emptyClass->changeVTable(vtable);
-}
-
-InternalClass *InternalClass::changeVTable(const ManagedVTable *vt)
-{
-    if (vtable == vt)
-        return this;
-
-    Transition temp;
-    temp.vtable = vt;
-    temp.lookup = 0;
-    temp.flags = Transition::VTableChange;
-
-    Transition &t = lookupOrInsertTransition(temp);
-    if (t.lookup)
-        return t.lookup;
-
-    // create a new class and add it to the tree
-    InternalClass *newClass;
-    if (this == engine->emptyClass) {
-        newClass = engine->newClass(*this);
-        newClass->vtable = vt;
-    } else {
-        newClass = engine->emptyClass->changeVTable(vt);
-        for (uint i = 0; i < size; ++i) {
-            if (!propertyData.at(i).isEmpty())
-                newClass = newClass->addMember(nameMap.at(i), propertyData.at(i));
-        }
-    }
-
-    t.lookup = newClass;
-    Q_ASSERT(t.lookup);
-    return newClass;
-}
-
 InternalClass *InternalClass::nonExtensible()
 {
     if (!extensible)
         return this;
 
     Transition temp;
-    temp.vtable = 0;
     temp.lookup = 0;
     temp.flags = Transition::NotExtensible;
 
@@ -290,7 +250,7 @@ InternalClass *InternalClass::addMember(Identifier *identifier, PropertyAttribut
 
 InternalClass *InternalClass::addMemberImpl(Identifier *identifier, PropertyAttributes data, uint *index)
 {
-    Transition temp = { { identifier }, 0, (int)data.flags() };
+    Transition temp = { identifier, 0, (int)data.flags() };
     Transition &t = lookupOrInsertTransition(temp);
 
     if (index)
@@ -326,14 +286,14 @@ void InternalClass::removeMember(Object *object, Identifier *id)
     uint propIdx = oldClass->propertyTable.lookup(id);
     Q_ASSERT(propIdx < oldClass->size);
 
-    Transition temp = { { id }, 0, -1 };
+    Transition temp = { id, 0, -1 };
     Transition &t = object->internalClass()->lookupOrInsertTransition(temp);
 
     if (t.lookup) {
         object->setInternalClass(t.lookup);
     } else {
         // create a new class and add it to the tree
-        InternalClass *newClass = oldClass->engine->emptyClass->changeVTable(oldClass->vtable);
+        InternalClass *newClass = oldClass->engine->emptyClass;
         for (uint i = 0; i < oldClass->size; ++i) {
             if (i == propIdx)
                 continue;
@@ -377,7 +337,6 @@ InternalClass *InternalClass::sealed()
         return m_sealed;
 
     m_sealed = engine->emptyClass;
-    m_sealed = m_sealed->changeVTable(vtable);
     for (uint i = 0; i < size; ++i) {
         PropertyAttributes attrs = propertyData.at(i);
         if (attrs.isEmpty())
@@ -397,7 +356,6 @@ InternalClass *InternalClass::frozen()
         return m_frozen;
 
     m_frozen = engine->emptyClass;
-    m_frozen = m_frozen->changeVTable(vtable);
     for (uint i = 0; i < size; ++i) {
         PropertyAttributes attrs = propertyData.at(i);
         if (attrs.isEmpty())
index b92bee3..b3d3a66 100644 (file)
@@ -189,16 +189,12 @@ private:
 
 struct InternalClassTransition
 {
-    union {
-        Identifier *id;
-        const ManagedVTable *vtable;
-    };
+    Identifier *id;
     InternalClass *lookup;
     int flags;
     enum {
         // range 0-0xff is reserved for attribute changes
-        VTableChange = 0x100,
-        NotExtensible = 0x200
+        NotExtensible = 0x100
     };
 
     bool operator==(const InternalClassTransition &other) const
@@ -210,7 +206,6 @@ struct InternalClassTransition
 
 struct InternalClass : public QQmlJS::Managed {
     ExecutionEngine *engine;
-    const ManagedVTable *vtable;
 
     PropertyHash propertyTable; // id to valueIndex
     SharedInternalClassData<Identifier *> nameMap;
@@ -226,8 +221,6 @@ struct InternalClass : public QQmlJS::Managed {
     uint size;
     bool extensible;
 
-    static InternalClass *create(ExecutionEngine *engine, const ManagedVTable *vtable);
-    InternalClass *changeVTable(const ManagedVTable *vt);
     InternalClass *nonExtensible();
     static void addMember(Object *object, String *string, PropertyAttributes data, uint *index);
     InternalClass *addMember(String *string, PropertyAttributes data, uint *index = 0);
index 0de2aa7..aa16b62 100644 (file)
@@ -880,7 +880,7 @@ QString Stringify::JA(ArrayObject *a)
 
 
 Heap::JsonObject::JsonObject(ExecutionEngine *e)
-    : Heap::Object(QV4::InternalClass::create(e, QV4::JsonObject::staticVTable()), e->objectPrototype.asObject())
+    : Heap::Object(e->emptyClass, e->objectPrototype.asObject())
 {
     Scope scope(e);
     ScopedObject o(scope, this);
index f784f4a..9aaf73d 100644 (file)
@@ -148,14 +148,12 @@ void Managed::setVTable(const ManagedVTable *vt)
 {
     d()->vtable = vt;
     Q_ASSERT(internalClass());
-    d()->internalClass = internalClass()->changeVTable(vt);
 }
 
 void Heap::Base::setVTable(const ManagedVTable *vt)
 {
     vtable = vt;
     Q_ASSERT(internalClass);
-    internalClass = internalClass->changeVTable(vt);
 }
 
 
index 222a6fd..b0b5049 100644 (file)
@@ -48,7 +48,7 @@ DEFINE_OBJECT_VTABLE(MathObject);
 static const double qt_PI = 2.0 * ::asin(1.0);
 
 Heap::MathObject::MathObject(ExecutionEngine *e)
-    : Heap::Object(QV4::InternalClass::create(e, QV4::MathObject::staticVTable()), e->objectPrototype.asObject())
+    : Heap::Object(e->emptyClass, e->objectPrototype.asObject())
 {
     Scope scope(e);
     ScopedObject m(scope, this);
index 2cdf901..3f9584d 100644 (file)
@@ -58,7 +58,7 @@ Heap::MemberData *MemberData::reallocate(ExecutionEngine *e, Heap::MemberData *o
     if (old)
         memcpy(newMemberData->d(), old, sizeof(Heap::MemberData) + s*sizeof(Value));
     else
-        new (newMemberData->d()) Heap::MemberData(e->memberDataClass);
+        new (newMemberData->d()) Heap::MemberData(e->emptyClass);
     newMemberData->d()->size = newAlloc;
     return newMemberData->d();
 }
index 939b14f..3d100b5 100644 (file)
@@ -45,7 +45,7 @@ namespace Heap {
 
 struct Object : Base {
     Object(ExecutionEngine *engine)
-        : Base(engine->objectClass),
+        : Base(engine->emptyClass),
           prototype(static_cast<Object *>(engine->objectPrototype.m))
     {
     }
@@ -275,7 +275,7 @@ struct BooleanObject : Object {
     }
 
     BooleanObject(ExecutionEngine *engine, const ValueRef val)
-        : Object(engine->booleanClass, engine->booleanPrototype.asObject())
+        : Object(engine->emptyClass, engine->booleanPrototype.asObject())
     {
         value = val;
     }
@@ -290,7 +290,7 @@ struct NumberObject : Object {
     }
 
     NumberObject(ExecutionEngine *engine, const ValueRef val)
-        : Object(engine->numberClass, engine->numberPrototype.asObject())
+        : Object(engine->emptyClass, engine->numberPrototype.asObject())
     {
         value = val;
     }
index 2f1ede1..c9c220f 100644 (file)
@@ -86,7 +86,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
 }
 
 Heap::RegExp::RegExp(ExecutionEngine* engine, const QString &pattern, bool ignoreCase, bool multiline)
-    : Base(engine->regExpValueClass)
+    : Base(engine->emptyClass)
     , pattern(pattern)
     , ignoreCase(ignoreCase)
     , multiLine(multiline)
index 4a843d8..0081664 100644 (file)
@@ -78,7 +78,7 @@ Heap::RegExpObject::RegExpObject(InternalClass *ic, QV4::Object *prototype)
 }
 
 Heap::RegExpObject::RegExpObject(QV4::ExecutionEngine *engine, QV4::RegExp *value, bool global)
-    : Heap::Object(engine->regExpClass, engine->regExpPrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->regExpPrototype.asObject())
     , value(value->d())
     , global(global)
 {
@@ -93,7 +93,7 @@ Heap::RegExpObject::RegExpObject(QV4::ExecutionEngine *engine, QV4::RegExp *valu
 // 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(QV4::ExecutionEngine *engine, const QRegExp &re)
-    : Heap::Object(engine->regExpClass, engine->regExpPrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->regExpPrototype.asObject())
 {
     setVTable(QV4::RegExpObject::staticVTable());
 
index 1320527..0cdd678 100644 (file)
@@ -146,7 +146,7 @@ struct RegExpPrototype: RegExpObject
 };
 
 inline Heap::RegExpPrototype::RegExpPrototype(ExecutionEngine *e)
-    : RegExpObject(InternalClass::create(e, QV4::RegExpPrototype::staticVTable()), e->objectPrototype.asObject())
+    : RegExpObject(e->emptyClass, e->objectPrototype.asObject())
 {
 }
 
index 8c6d283..496a794 100644 (file)
@@ -500,7 +500,7 @@ public:
 
 template <typename Container>
 Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, const Container &container)
-    : Heap::Object(InternalClass::create(engine, QV4::QQmlSequence<Container>::staticVTable()), engine->sequencePrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->sequencePrototype.asObject())
     , container(container)
     , propertyIndex(-1)
     , isReference(false)
@@ -513,7 +513,7 @@ Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, const
 
 template <typename Container>
 Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, QObject *object, int propertyIndex)
-    : Heap::Object(InternalClass::create(engine, QV4::QQmlSequence<Container>::staticVTable()), engine->sequencePrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->sequencePrototype.asObject())
     , object(object)
     , propertyIndex(propertyIndex)
     , isReference(true)
index 86624b2..ce47fc4 100644 (file)
@@ -118,7 +118,7 @@ bool String::isEqualTo(Managed *t, Managed *o)
 
 
 Heap::String::String(ExecutionEngine *engine, const QString &t)
-    : Heap::Base(engine->stringClass)
+    : Heap::Base(engine->emptyClass)
 {
     subtype = String::StringType_Unknown;
 
@@ -131,7 +131,7 @@ Heap::String::String(ExecutionEngine *engine, const QString &t)
 }
 
 Heap::String::String(ExecutionEngine *engine, String *l, String *r)
-    : Heap::Base(engine->stringClass)
+    : Heap::Base(engine->emptyClass)
 {
     subtype = String::StringType_Unknown;
 
index b5efdfa..617670e 100644 (file)
@@ -83,7 +83,7 @@ Heap::StringObject::StringObject(InternalClass *ic, QV4::Object *prototype)
 }
 
 Heap::StringObject::StringObject(ExecutionEngine *engine, const ValueRef val)
-    : Heap::Object(engine->stringObjectClass, engine->stringPrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->stringPrototype.asObject())
 {
     value = val;
     Q_ASSERT(value.isString());
index 74adc2e..7aff0b8 100644 (file)
@@ -334,7 +334,7 @@ ReturnedValue TypedArrayCtor::call(Managed *that, CallData *callData)
 }
 
 Heap::TypedArray::TypedArray(ExecutionEngine *e, Type t)
-    : Heap::Object(e->typedArrayClasses[t], e->typedArrayPrototype[t].asObject()),
+    : Heap::Object(e->emptyClass, e->typedArrayPrototype[t].asObject()),
       type(operations + t)
 {
 }
index 5397b96..a1339bb 100644 (file)
@@ -44,7 +44,7 @@ using namespace QV4;
 DEFINE_OBJECT_VTABLE(VariantObject);
 
 Heap::VariantObject::VariantObject(QV4::ExecutionEngine *engine, const QVariant &value)
-    : Heap::Object(engine->variantClass, engine->variantPrototype.asObject())
+    : Heap::Object(engine->emptyClass, engine->variantPrototype.asObject())
 {
     data = value;
     if (isScarce())