aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-11-21 13:15:46 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-04 09:45:45 +0100
commitfbcd0a22f643f0b0ec1404507d63bdf35cd9a195 (patch)
treeb759029b5ca0f9db8d3bf1863ca319a92edb6baf /src/qml/jsruntime/qv4engine.cpp
parent5e8bee55aa78551c2d31b24228227c0bbbdc1d8d (diff)
Move the vtable pointer from the object to the internal class
This saves one pointer per object, and willmake other optimizations easier in the future. Change-Id: I1324cad31998896b5dc76af3c8a7ee9d86283bfe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 50db0e09fb..b50d4d87e5 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qv4engine_p.h>
+#include <qv4context_p.h>
#include <qv4value_p.h>
#include <qv4object_p.h>
#include <qv4objectproto_p.h>
@@ -215,16 +216,22 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
id_valueOf = newIdentifier(QStringLiteral("valueOf"));
ObjectPrototype *objectPrototype = new (memoryManager) ObjectPrototype(emptyClass);
- objectClass = emptyClass->changePrototype(objectPrototype);
+ objectClass = emptyClass->changeVTable(&Object::static_vtbl);
+ objectClass = objectClass->changePrototype(objectPrototype);
+ Q_ASSERT(objectClass->vtable == &Object::static_vtbl);
arrayClass = objectClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable);
ArrayPrototype *arrayPrototype = new (memoryManager) ArrayPrototype(arrayClass);
arrayClass = arrayClass->changePrototype(arrayPrototype);
- InternalClass *argsClass = objectClass->addMember(id_length, Attr_NotEnumerable);
+ InternalClass *argsClass = objectClass->changeVTable(&ArgumentsObject::static_vtbl);
+ argsClass = argsClass->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::static_vtbl);
+ Q_ASSERT(strictArgumentsObjectClass->vtable == &ArgumentsObject::static_vtbl);
+
initRootContext();
StringPrototype *stringPrototype = new (memoryManager) StringPrototype(objectClass);
@@ -391,10 +398,9 @@ void ExecutionEngine::enableDebugger()
void ExecutionEngine::initRootContext()
{
rootContext = static_cast<GlobalContext *>(memoryManager->allocManaged(sizeof(GlobalContext) + sizeof(CallData)));
- rootContext->init();
+ new (rootContext) GlobalContext(this);
current = rootContext;
current->parent = 0;
- rootContext->initGlobalContext(this);
}
InternalClass *ExecutionEngine::newClass(const InternalClass &other)
@@ -404,11 +410,10 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other)
ExecutionContext *ExecutionEngine::pushGlobalContext()
{
- GlobalContext *g = new (memoryManager) GlobalContext;
+ GlobalContext *g = new (memoryManager) GlobalContext(this, current);
ExecutionContext *oldNext = g->next;
memcpy(g, rootContext, sizeof(GlobalContext));
g->next = oldNext;
- g->parent = current;
current = g;
return current;