aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-12-08 21:01:51 +0100
committerLars Knoll <lars.knoll@qt.io>2016-12-09 08:30:41 +0000
commit9f4cfec74517f7ff3f65037ad04abac33e2104ba (patch)
tree52fb2f553cb0ee47dafc13d8e594e0cbf3b0fcb3
parent260f45d539b3ec1b28f593706ce7c164836f814c (diff)
Avoid some copies of Values on the JS stack
Change-Id: I1c7dca6e8d17da9f3d76b68d072370b087840f2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp18
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h4
2 files changed, 10 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 02ea763b30..66549ffd3e 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -216,8 +216,7 @@ Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlCont
runtimeFunction->updateInternalClass(engine, signalParameters);
}
- QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction));
- return function->d();
+ return QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction);
}
@@ -344,11 +343,11 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
{
- Scope scope(ctx);
- ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>());
+ FunctionObject *o = ctx->thisObject().as<FunctionObject>();
if (!o)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedValue arg(scope, ctx->argument(1));
ScopedObject arr(scope, arg);
@@ -387,12 +386,11 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
{
- Scope scope(ctx);
-
- ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>());
+ FunctionObject *o = ctx->thisObject().as<FunctionObject>();
if (!o)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0);
if (ctx->argc()) {
for (int i = 1; i < ctx->argc(); ++i)
@@ -406,11 +404,11 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
{
- Scope scope(ctx);
- ScopedFunctionObject target(scope, ctx->thisObject());
+ FunctionObject *target = ctx->thisObject().as<FunctionObject>();
if (!target)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedValue boundThis(scope, ctx->argument(0));
Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)0);
if (ctx->argc() > 1) {
@@ -601,7 +599,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal
QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
}
-Heap::Object *SimpleScriptFunction::protoForConstructor()
+Heap::Object *SimpleScriptFunction::protoForConstructor() const
{
Scope scope(engine());
ScopedObject p(scope, protoProperty());
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 3dcc7ab482..5c176b88b4 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -154,7 +154,7 @@ struct Q_QML_EXPORT FunctionObject: Object {
static Heap::FunctionObject *createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction,
const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
- ReturnedValue protoProperty() { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); }
+ ReturnedValue protoProperty() const { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); }
bool needsActivation() const { return d()->needsActivation(); }
bool strictMode() const { return d()->function ? d()->function->isStrict() : false; }
@@ -232,7 +232,7 @@ struct SimpleScriptFunction: FunctionObject {
static void construct(const Managed *, Scope &scope, CallData *callData);
static void call(const Managed *that, Scope &scope, CallData *callData);
- Heap::Object *protoForConstructor();
+ Heap::Object *protoForConstructor() const;
};
struct ScriptFunction: SimpleScriptFunction {