From 55101d6937880f4dfd8d8eb79fbb15a8e7bb508a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Nov 2016 15:35:16 +0100 Subject: Move the check whether a function is simple to QV4::Function This allows re-using the check in the QQmlJavascriptExpression code. Change-Id: I647a6edb4844911f540f08c4a067d055676dd0ed Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4function_p.h | 9 +++++++++ src/qml/jsruntime/qv4functionobject.cpp | 9 +++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index beba5a1fd6..802af43cdc 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -91,6 +91,15 @@ struct Q_QML_EXPORT Function { inline bool needsActivation() const { return activationRequired; } + inline bool canUseSimpleFunction() const { + if (needsActivation() || + compiledFunction->flags & CompiledData::Function::HasCatchOrWith || + compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || + isNamedExpression()) + return false; + return true; + } + QQmlSourceLocation sourceLocation() const { return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 66549ffd3e..21edf1d8d3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -195,12 +195,9 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e) Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) { - if (function->needsActivation() || - function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith || - function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || - function->isNamedExpression()) - return scope->d()->engine->memoryManager->allocObject(scope, function); - return scope->d()->engine->memoryManager->allocObject(scope, function, createProto); + if (function->canUseSimpleFunction()) + return scope->d()->engine->memoryManager->allocObject(scope, function, createProto); + return scope->d()->engine->memoryManager->allocObject(scope, function); } Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, Function *runtimeFunction, const QList &signalParameters, QString *error) -- cgit v1.2.3