diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-10-10 11:51:42 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-30 08:29:49 +0100 |
commit | b59751b146ecdf7a4b387845d9be19e4600e2911 (patch) | |
tree | dddca88f6544adbf0de3ef05fbf56cbd0bdac095 /src/qml/compiler/qv4isel_moth.cpp | |
parent | 928a7d3e3edb278281641b6928ba046b123548ca (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/compiler/qv4isel_moth.cpp')
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index 11a22dd910..a2e702dac4 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -360,14 +360,24 @@ void InstructionSelection::callValue(V4IR::Temp *value, V4IR::ExprList *args, V4 void InstructionSelection::callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result) { - // call the property on the loaded base - Instruction::CallProperty call; - call.base = getParam(base); - call.name = registerString(name); - prepareCallArgs(args, call.argc); - call.callData = callDataStart(); - call.result = getResultParam(result); - addInstruction(call); + if (useFastLookups) { + Instruction::CallPropertyLookup call; + call.base = getParam(base); + call.lookupIndex = registerGetterLookup(name); + prepareCallArgs(args, call.argc); + call.callData = callDataStart(); + call.result = getResultParam(result); + addInstruction(call); + } else { + // call the property on the loaded base + Instruction::CallProperty call; + call.base = getParam(base); + call.name = registerString(name); + prepareCallArgs(args, call.argc); + call.callData = callDataStart(); + call.result = getResultParam(result); + addInstruction(call); + } } void InstructionSelection::callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args, @@ -399,6 +409,15 @@ void InstructionSelection::constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result) { + if (useFastLookups && func->global) { + Instruction::ConstructGlobalLookup call; + call.index = registerGlobalGetterLookup(*func->id); + prepareCallArgs(args, call.argc); + call.callData = callDataStart(); + call.result = getResultParam(result); + addInstruction(call); + return; + } Instruction::CreateActivationProperty create; create.name = registerString(*func->id); prepareCallArgs(args, create.argc); @@ -471,6 +490,13 @@ void InstructionSelection::loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *ta void InstructionSelection::getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp) { + if (useFastLookups && name->global) { + Instruction::GetGlobalLookup load; + load.index = registerGlobalGetterLookup(*name->id); + load.result = getResultParam(temp); + addInstruction(load); + return; + } Instruction::LoadName load; load.name = registerString(*name->id); load.result = getResultParam(temp); @@ -496,6 +522,14 @@ void InstructionSelection::initClosure(V4IR::Closure *closure, V4IR::Temp *targe void InstructionSelection::getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target) { + if (useFastLookups) { + Instruction::GetLookup load; + load.base = getParam(base); + load.index = registerGetterLookup(name); + load.result = getResultParam(target); + addInstruction(load); + return; + } Instruction::LoadProperty load; load.base = getParam(base); load.name = registerString(name); @@ -506,6 +540,14 @@ void InstructionSelection::getProperty(V4IR::Expr *base, const QString &name, V4 void InstructionSelection::setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName) { + if (useFastLookups) { + Instruction::SetLookup store; + store.base = getParam(targetBase); + store.index = registerSetterLookup(targetName); + store.source = getParam(source); + addInstruction(store); + return; + } Instruction::StoreProperty store; store.base = getParam(targetBase); store.name = registerString(targetName); @@ -856,6 +898,15 @@ void InstructionSelection::visitRet(V4IR::Ret *s) void InstructionSelection::callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result) { + if (useFastLookups && func->global) { + Instruction::CallGlobalLookup call; + call.index = registerGlobalGetterLookup(*func->id); + prepareCallArgs(args, call.argc); + call.callData = callDataStart(); + call.result = getResultParam(result); + addInstruction(call); + return; + } Instruction::CallActivationProperty call; call.name = registerString(*func->id); prepareCallArgs(args, call.argc); |