aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-07 08:53:31 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-10 08:18:09 +0000
commitb960c796b741b3831b5eaafe583d92f362fdd498 (patch)
treeac84ef6ca2a6c53174875f158549d4bd1e122a6f
parentfd221cf6e056b7239fc2fa2faeccd9ddeb542199 (diff)
Load the this argument through LoadReg for simple calls
Change-Id: Iac0fb5c955354c8137b551196278b822acc1b324 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp11
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h5
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp13
3 files changed, 25 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 6505469a8b..a73414f7ce 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2994,8 +2994,15 @@ void Codegen::Reference::loadInAccumulator() const
codegen->_context->contextObjectPropertyDependencies.insert(qmlCoreIndex, qmlNotifyIndex);
} return;
case This: {
- Instruction::LoadThis load;
- codegen->bytecodeGenerator->addInstruction(load);
+ Context *c = codegen->currentContext();
+ if (c->canUseSimpleCall()) {
+ Instruction::LoadReg load;
+ load.reg = Moth::StackSlot::createArgument(c->arguments.size(), -1);
+ codegen->bytecodeGenerator->addInstruction(load);
+ } else {
+ Instruction::LoadThis load;
+ codegen->bytecodeGenerator->addInstruction(load);
+ }
} return;
case Invalid:
break;
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 19c358eef7..0a271001ed 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -197,7 +197,7 @@ public:
}
static StackSlot createArgument(int nFormals, int index) {
- Q_ASSERT(index >= 0);
+ Q_ASSERT(index >= -1);
StackSlot t;
t.index = index - nFormals;
return t;
@@ -217,6 +217,9 @@ public:
if (isRegister())
return QStringLiteral("r%1").arg(index);
+ if (nFormals + index == -1)
+ return QStringLiteral("(this)");
+
return QStringLiteral("a%1").arg(nFormals + index);
}
};
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 747101fef2..e3a91654f4 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -735,7 +735,18 @@ QV4::ReturnedValue VME::exec(Function *function, const FunctionObject *jsFunctio
MOTH_END_INSTR(CallBuiltinSetupArgumentsObject)
MOTH_BEGIN_INSTR(CallBuiltinConvertThisToObject)
- Runtime::method_convertThisToObject(engine);
+ if (function->canUseSimpleFunction()) {
+ Value *t = &stack[-(int)function->nFormals - 1];
+ if (!t->isObject()) {
+ if (t->isNullOrUndefined()) {
+ *t = engine->globalObject->asReturnedValue();
+ } else {
+ *t = t->toObject(engine)->asReturnedValue();
+ }
+ }
+ } else {
+ Runtime::method_convertThisToObject(engine);
+ }
CHECK_EXCEPTION;
MOTH_END_INSTR(CallBuiltinConvertThisToObject)