aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-03 17:07:29 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-04 07:08:13 +0000
commitb46b2e28b39443f6250c0d751a593b35af1c8c1e (patch)
treec15f6db0d87ad48c405cbff62f72e624c8f1d81e
parent59f219d2df059d5fb1baf8751f830bb17816a307 (diff)
Keep order of arguments on the stack
Don't reverse the arguments order when copying them. In addition, copy the this object as well, so we don't need to access the context anymore to access it. Change-Id: I38055c55387c4253cb53dd12fa69126840fa1270 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen_p.h4
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h4
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp7
3 files changed, 8 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 56bed33c19..f55ef026a8 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -219,7 +219,7 @@ public:
}
static Reference fromArgument(Codegen *cg, int index) {
Reference r(cg, StackSlot);
- r.theStackSlot = Moth::StackSlot::createArgument(index);
+ r.theStackSlot = Moth::StackSlot::createArgument(cg->currentContext()->arguments.size(), index);
r.stackSlotIsLocalOrArgument = true;
return r;
}
@@ -614,6 +614,8 @@ public:
QQmlRefPointer<QV4::CompiledData::CompilationUnit> generateCompilationUnit(bool generateUnitData = true);
static QQmlRefPointer<QV4::CompiledData::CompilationUnit> createUnitForLoading();
+ Context *currentContext() const { return _context; }
+
protected:
friend class ScanFunctions;
friend struct ControlFlow;
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 19d521dbe3..87814775c0 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -192,10 +192,10 @@ public:
return t;
}
- static StackSlot createArgument(int index) {
+ static StackSlot createArgument(int nFormals, int index) {
Q_ASSERT(index >= 0);
StackSlot t;
- t.index = -index - 1;
+ t.index = index - nFormals;
return t;
}
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index c1787f4eec..e3a9815f54 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -458,10 +458,9 @@ QV4::ReturnedValue VME::exec(Function *function)
QV4::Scope scope(engine);
{
int nFormals = function->nFormals;
- stack = scope.alloc(function->compiledFunction->nRegisters + nFormals) + nFormals;
- auto cc = engine->current;
- for (int i = 0, ei = std::min<int>(cc->callData->argc, nFormals); i != ei; ++i)
- stack[-i-1] = cc->callData->args[i];
+ stack = scope.alloc(function->compiledFunction->nRegisters + nFormals + 1);
+ memcpy(stack, &engine->current->callData->thisObject, (nFormals + 1)*sizeof(Value));
+ stack += nFormals + 1;
}
if (QV4::Debugging::Debugger *debugger = engine->debugger())