aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4vme_moth.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-10 11:51:42 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-30 08:29:49 +0100
commitb59751b146ecdf7a4b387845d9be19e4600e2911 (patch)
treedddca88f6544adbf0de3ef05fbf56cbd0bdac095 /src/qml/jsruntime/qv4vme_moth.cpp
parent928a7d3e3edb278281641b6928ba046b123548ca (diff)
Use lookups in the interpreter
Implement lookup calls for the interpreter. This significantly reduces overhead by avoiding repeated name lookups on the same object type. This doubles the speed of quite a few of the v8 benchmarks, and brings the interpreter up to close to 40% of the speed of the JIT. Change-Id: Ie8c2f5b1ca71a7329bc643c3d2158a6301a392ed Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4vme_moth.cpp')
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index d569e98325..5a7b33a5d5 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -45,6 +45,7 @@
#include <private/qv4debugging_p.h>
#include <private/qv4math_p.h>
#include <private/qv4scopedvalue_p.h>
+#include <private/qv4lookup_p.h>
#include <iostream>
#include "qv4alloca_p.h"
@@ -263,6 +264,12 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code,
STOREVALUE(instr.result, __qmljs_get_activation_property(context, runtimeStrings[instr.name]));
MOTH_END_INSTR(LoadName)
+ MOTH_BEGIN_INSTR(GetGlobalLookup)
+ TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
+ QV4::Lookup *l = context->lookups + instr.index;
+ STOREVALUE(instr.result, l->globalGetter(l, context));
+ MOTH_END_INSTR(GetGlobalLookup)
+
MOTH_BEGIN_INSTR(StoreName)
TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
__qmljs_set_activation_property(context, runtimeStrings[instr.name], VALUEPTR(instr.source));
@@ -282,11 +289,22 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code,
STOREVALUE(instr.result, __qmljs_get_property(context, VALUEPTR(instr.base), runtimeStrings[instr.name]));
MOTH_END_INSTR(LoadProperty)
+ MOTH_BEGIN_INSTR(GetLookup)
+ QV4::Lookup *l = context->lookups + instr.index;
+ STOREVALUE(instr.result, l->getter(l, VALUEPTR(instr.base)));
+ MOTH_END_INSTR(GetLookup)
+
MOTH_BEGIN_INSTR(StoreProperty)
__qmljs_set_property(context, VALUEPTR(instr.base), runtimeStrings[instr.name], VALUEPTR(instr.source));
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreProperty)
+ MOTH_BEGIN_INSTR(SetLookup)
+ QV4::Lookup *l = context->lookups + instr.index;
+ l->setter(l, VALUEPTR(instr.base), VALUEPTR(instr.source));
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(SetLookup)
+
MOTH_BEGIN_INSTR(Push)
TRACE(inline, "stack size: %u", instr.value);
stackSize = instr.value;
@@ -324,6 +342,16 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code,
STOREVALUE(instr.result, __qmljs_call_property(context, runtimeStrings[instr.name], callData));
MOTH_END_INSTR(CallProperty)
+ MOTH_BEGIN_INSTR(CallPropertyLookup)
+ TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
+ QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
+ callData->tag = QV4::Value::Integer_Type;
+ callData->argc = instr.argc;
+ callData->thisObject = VALUE(instr.base);
+ STOREVALUE(instr.result, __qmljs_call_property_lookup(context, instr.lookupIndex, callData));
+ MOTH_END_INSTR(CallPropertyLookup)
+
MOTH_BEGIN_INSTR(CallElement)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
@@ -343,6 +371,16 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code,
STOREVALUE(instr.result, __qmljs_call_activation_property(context, runtimeStrings[instr.name], callData));
MOTH_END_INSTR(CallActivationProperty)
+ MOTH_BEGIN_INSTR(CallGlobalLookup)
+ TRACE(args, "starting at %d, length %d", instr.args, instr.argc);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
+ QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
+ callData->tag = QV4::Value::Integer_Type;
+ callData->argc = instr.argc;
+ callData->thisObject = QV4::Primitive::undefinedValue();
+ STOREVALUE(instr.result, __qmljs_call_global_lookup(context, instr.index, callData));
+ MOTH_END_INSTR(CallGlobalLookup)
+
MOTH_BEGIN_INSTR(SetExceptionHandler)
exceptionHandler = instr.offset ? ((uchar *)&instr.offset) + instr.offset : 0;
MOTH_END_INSTR(SetExceptionHandler)
@@ -459,6 +497,16 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code,
STOREVALUE(instr.result, __qmljs_construct_activation_property(context, runtimeStrings[instr.name], callData));
MOTH_END_INSTR(CreateActivationProperty)
+ MOTH_BEGIN_INSTR(ConstructGlobalLookup)
+ TRACE(inline, "property name = %s, args = %d, argc = %d", runtimeStrings[instr.name]->toQString().toUtf8().constData(), instr.args, instr.argc);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
+ QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
+ callData->tag = QV4::Value::Integer_Type;
+ callData->argc = instr.argc;
+ callData->thisObject = QV4::Primitive::undefinedValue();
+ STOREVALUE(instr.result, __qmljs_construct_global_lookup(context, instr.index, callData));
+ MOTH_END_INSTR(ConstructGlobalLookup)
+
MOTH_BEGIN_INSTR(Jump)
code = ((uchar *)&instr.offset) + instr.offset;
MOTH_END_INSTR(Jump)