diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-02-07 08:56:24 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-03-09 08:59:05 +0000 |
commit | 3e80f3bef90d35bc6c8cec32de875b694988d668 (patch) | |
tree | aea8531ae7892ab36289e5317703fad63fbf850c | |
parent | 38221427bc21a11b96de7fa7666264c34298c0c0 (diff) |
Make the decision about whether to use a Simple callcontext earlier
All required information is already available when creating the
CompiledData::Function, so determine at that point whether we
use a Simple or full CallContext.
Change-Id: Ife489ca2ca6eaf2ffc7843544a56e8bd86590e9d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 3 | ||||
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 7 |
4 files changed, 11 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 13a0c4b075..a1833f2937 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -211,7 +211,8 @@ struct Function HasDirectEval = 0x2, UsesArgumentsObject = 0x4, IsNamedExpression = 0x8, - HasCatchOrWith = 0x10 + HasCatchOrWith = 0x10, + CanUseSimpleCall = 0x20 }; // Absolute offset into file where the code for this function is located. Only used when the function diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 9cfac4a676..e9709f5fb4 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -296,6 +296,8 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::IR::Function *i function->flags |= CompiledData::Function::IsNamedExpression; if (irFunction->hasTry || irFunction->hasWith) function->flags |= CompiledData::Function::HasCatchOrWith; + if (irFunction->canUseSimpleCall()) + function->flags |= CompiledData::Function::CanUseSimpleCall; function->nFormals = irFunction->formals.size(); function->formalsOffset = currentOffset; currentOffset += function->nFormals * sizeof(quint32); diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index 23ebe0c962..da2c350393 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -1352,6 +1352,12 @@ struct Function { int getNewStatementId() { return _statementCount++; } int statementCount() const { return _statementCount; } + bool canUseSimpleCall() const { + return nestedFunctions.isEmpty() && + locals.isEmpty() && formals.size() <= QV4::Global::ReservedArgumentCount && + !hasTry && !hasWith && !isNamedExpression && !usesArgumentsObject && !hasDirectEval; + } + private: BasicBlock *getOrCreateBasicBlock(int index); void setStatementCount(int cnt); diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index b3feae4293..ed9e3699f2 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -83,12 +83,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, for (quint32 i = 0; i < compiledFunction->nLocals; ++i) internalClass = internalClass->addMember(compilationUnit->runtimeStrings[localsIndices[i]]->identifier, Attr_NotConfigurable); - canUseSimpleCall = compiledFunction->nInnerFunctions == 0 && - !(compiledFunction->flags & CompiledData::Function::HasDirectEval) && - !(compiledFunction->flags & CompiledData::Function::UsesArgumentsObject) && - !(compiledFunction->flags & CompiledData::Function::HasCatchOrWith) && - nFormals <= QV4::Global::ReservedArgumentCount && - compiledFunction->nLocals == 0 && !isNamedExpression(); + canUseSimpleCall = compiledFunction->flags & CompiledData::Function::CanUseSimpleCall; } Function::~Function() |