aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-01-27 09:05:54 +0100
committerLars Knoll <lars.knoll@qt.io>2017-03-09 08:58:12 +0000
commit58b882ad42f99e03ac8dca13ff9c0d39fcafbaa0 (patch)
treee518e549f6410ac521ec0506bfca3dc918381e49
parent4de7e48ab160dacc7a09360e80264eac4945a8f4 (diff)
Avoid one indirection when looking up local variables
Simple CallContext's never have locals, as they get converted to temps in the compiler. For regular CallContext's, local variables always got appended to the callcontext. So there was no need to have an additional indirect pointer to them in the CallContext. This speeds up v8-bench by 1-2%. Change-Id: I3def7ba653aea5bc5761076f398450ae30c62823 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/jit/qv4assembler.cpp3
-rw-r--r--src/qml/jsruntime/qv4context.cpp4
-rw-r--r--src/qml/jsruntime/qv4context_p.h2
-rw-r--r--src/qml/jsruntime/qv4function.cpp3
4 files changed, 5 insertions, 7 deletions
diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp
index e658977da1..0b3d0bd0cc 100644
--- a/src/qml/jit/qv4assembler.cpp
+++ b/src/qml/jit/qv4assembler.cpp
@@ -286,8 +286,7 @@ typename Assembler<TargetConfiguration>::Pointer Assembler<TargetConfiguration>:
} break;
case IR::ArgLocal::Local:
case IR::ArgLocal::ScopedLocal: {
- loadPtr(Address(baseReg, qOffsetOf(CallContext::Data, locals)), baseReg);
- offset = al->index * sizeof(Value);
+ offset = qOffsetOf(CallContext::Data, locals) + al->index * sizeof(Value);
} break;
default:
Q_UNREACHABLE();
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index fe01b9abad..569523595c 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -61,7 +61,7 @@ DEFINE_MANAGED_VTABLE(GlobalContext);
/* Function *f, int argc */
#define requiredMemoryForExecutionContect(f, argc) \
- ((sizeof(CallContext::Data) + 7) & ~7) + \
+ sizeof(CallContext::Data) - sizeof(Value) + \
sizeof(Value) * (f->compiledFunction->nLocals + qMax((uint)argc, f->nFormals)) + sizeof(CallData)
Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData)
@@ -80,7 +80,6 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
c->compilationUnit = function->compilationUnit;
c->lookups = c->compilationUnit->runtimeLookups;
c->constantTable = c->compilationUnit->constants;
- c->locals = (Value *)((quintptr(c + 1) + 7) & ~7);
const CompiledData::Function *compiledFunction = function->compiledFunction;
int nLocals = compiledFunction->nLocals;
@@ -314,7 +313,6 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio
ctx->lookups = function->compilationUnit->runtimeLookups;
ctx->constantTable = function->compilationUnit->constants;
ctx->outer = this->d();
- ctx->locals = scope.alloc(function->compiledFunction->nLocals);
for (int i = callData->argc; i < (int)function->nFormals; ++i)
callData->args[i] = Encode::undefined();
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index cbf1ac9f7d..96cdb90db9 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -148,7 +148,7 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
inline unsigned int formalParameterCount() const;
QV4::Function *v4Function;
- Value *locals;
+ Value locals[1];
};
V4_ASSERT_IS_TRIVIAL(CallContext)
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 358c2d079c..dd3208c7e9 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -86,7 +86,8 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
activationRequired = compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject));
canUseSimpleCall = !needsActivation() && !(compiledFunction->flags & CompiledData::Function::HasCatchOrWith) &&
- !(compiledFunction->nFormals > QV4::Global::ReservedArgumentCount) && !isNamedExpression();
+ compiledFunction->nFormals <= QV4::Global::ReservedArgumentCount &&
+ compiledFunction->nLocals == 0 && !isNamedExpression();
}
Function::~Function()