aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-12-01 14:25:52 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2016-12-01 13:57:17 +0000
commitd3797d72a21269a7301b195b16c5c5936c586a44 (patch)
tree4b0e28052c52f4a3198a279c515c277959609b25 /src/qml/jsruntime
parentb8e5d7b98eeef61dccf229f6a7ad5c03f4d47e9f (diff)
V4: Prevent repeatedly loading a QV4::Function pointer
Even with LTO on, GCC6 will not optimize out the fact that a) the d() pointer won't change here, and that d()->function is constant and not need to be checked for nullptr all the time. Also prevents allocating 0 locals, which would still run most of the jsAlloca code for no good reason. Change-Id: Iaf5257743cb57d55bef5d334d1e4355590dae7c6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 6bff0bc5e8..2521ff32e1 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -538,22 +538,24 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData
callData->thisObject = v4->newObject(ic, proto);
CallContext::Data ctx = CallContext::Data::createOnStack(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
ctx.function = f->d();
- ctx.compilationUnit = f->function()->compilationUnit;
+ QV4::Function *ff = ctx.function->function;
+ ctx.strictMode = ff->isStrict();
+ ctx.callData = callData;
+ ctx.compilationUnit = ff->compilationUnit;
ctx.lookups = ctx.compilationUnit->runtimeLookups;
ctx.constantTable = ctx.compilationUnit->constants;
- ctx.outer = f->scope();
- ctx.locals = scope.alloc(f->varCount());
- for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i)
+ ctx.outer = ctx.function->scope;
+ if (unsigned varCount = f->varCount())
+ ctx.locals = scope.alloc(varCount);
+ for (int i = callData->argc; i < static_cast<int>(ff->nFormals); ++i)
callData->args[i] = Encode::undefined();
v4->pushContext(&ctx);
Q_ASSERT(v4->current == &ctx);
- scope.result = Q_V4_PROFILE(v4, f->function());
+ scope.result = Q_V4_PROFILE(v4, ff);
- if (f->function()->hasQmlDependencies)
+ if (ff->hasQmlDependencies)
QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
if (v4->hasException) {
@@ -577,22 +579,24 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal
Scoped<SimpleScriptFunction> f(scope, static_cast<const SimpleScriptFunction *>(that));
CallContext::Data ctx = CallContext::Data::createOnStack(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
ctx.function = f->d();
- ctx.compilationUnit = f->function()->compilationUnit;
+ QV4::Function *ff = ctx.function->function;
+ ctx.strictMode = ff->isStrict();
+ ctx.callData = callData;
+ ctx.compilationUnit = ff->compilationUnit;
ctx.lookups = ctx.compilationUnit->runtimeLookups;
ctx.constantTable = ctx.compilationUnit->constants;
- ctx.outer = f->scope();
- ctx.locals = scope.alloc(f->varCount());
- for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i)
+ ctx.outer = ctx.function->scope;
+ if (unsigned varCount = f->varCount())
+ ctx.locals = scope.alloc(varCount);
+ for (int i = callData->argc; i < static_cast<int>(ff->nFormals); ++i)
callData->args[i] = Encode::undefined();
v4->pushContext(&ctx);
Q_ASSERT(v4->current == &ctx);
- scope.result = Q_V4_PROFILE(v4, f->function());
+ scope.result = Q_V4_PROFILE(v4, ff);
- if (f->function()->hasQmlDependencies)
+ if (ff->hasQmlDependencies)
QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
}