diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-07 08:37:45 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-10 08:18:56 +0000 |
commit | 30e3664bf3668bda9a211fe7d1404f8f806dbf7b (patch) | |
tree | bd119839af7db0f6f9119401d478b37b44051c8b /src/qml/jsruntime/qv4functionobject.cpp | |
parent | eb2c08f57493aa12850e6cddff2cc3527e7cbfd7 (diff) |
Avoid creating a CallContext for simple functions
This cuts out quite a bit of overhead when entering
and leaving functions.
Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index f314d02912..f175e2cd5d 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -359,28 +359,28 @@ ReturnedValue ScriptFunction::construct(const Managed *that, CallData *callData) return Encode::undefined(); CHECK_STACK_LIMITS(v4); - Scope scope(v4); - Scoped<ScriptFunction> f(scope, static_cast<const ScriptFunction *>(that)); + const ScriptFunction *f = static_cast<const ScriptFunction *>(that); InternalClass *ic = f->classForConstructor(); - ScopedObject proto(scope, ic->prototype); - callData->thisObject = v4->newObject(ic, proto); + Scope scope(v4); + callData->thisObject = v4->memoryManager->allocObject<Object>(ic); QV4::Function *v4Function = f->function(); Q_ASSERT(v4Function); - ScopedContext c(scope, f->scope()); - ScopedValue result(scope); + Value s = Value::fromHeapObject(f->scope()); + ExecutionContext *outer = static_cast<ExecutionContext *>(&s); + ReturnedValue result; if (v4Function->canUseSimpleCall) - result = c->simpleCall(scope.engine, callData, v4Function); + result = outer->simpleCall(scope.engine, callData, v4Function); else - result = c->call(scope.engine, callData, v4Function, f); + result = outer->call(scope.engine, callData, v4Function, f); if (Q_UNLIKELY(v4->hasException)) return Encode::undefined(); - else if (!result->isObject()) + else if (!Value::fromReturnedValue(result).isObject()) return callData->thisObject.asReturnedValue(); - return result->asReturnedValue(); + return result; } ReturnedValue ScriptFunction::call(const Managed *that, CallData *callData) |