diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2012-11-14 12:18:50 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2012-11-14 13:40:24 +0100 |
commit | 4ebd6f29822f33da30e055daebb287d23404167e (patch) | |
tree | 454df3334f6bce65d8199f8b9346f1324ac941d8 /moth | |
parent | b233a73fea9bc34c97ef0fcd6d8088288394f643 (diff) |
Fix optimisation for passing a single argument to a call.
Change-Id: I57a881ccd9f86a36d2d2ea5451046652ac0aca21
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'moth')
-rw-r--r-- | moth/qv4isel_moth.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index 9550bb6f8e..d66673d0be 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -244,15 +244,22 @@ void InstructionSelection::prepareCallArgs(IR::ExprList *e, quint32 &argc, quint argc = 0; args = 0; - /* - int locals = _function->tempCount - _function->locals.size() + _function->maxNumberOfArguments; + bool singleArgIsTemp = false; + if (e && e->next == 0) { + // ok, only 1 argument in the cal... + const int idx = e->expr->asTemp()->index; + if (idx >= 0) { + // not an argument to this function... + // so if it's not a local, we're in: + singleArgIsTemp = idx >= _function->locals.size(); + } + } - The condition for this case is wrong: the locals check is incorrect: - if (e && e->next == 0 && e->expr->asTemp()->index >= 0 && e->expr->asTemp()->index < locals) { - // We pass single arguments as references to the stack + if (singleArgIsTemp) { + // We pass single arguments as references to the stack, but only if it's not a local or an argument. argc = 1; args = e->expr->asTemp()->index; - } else */if (e) { + } else if (e) { // We need to move all the temps into the function arg array int argLocation = _function->tempCount - _function->locals.size(); assert(argLocation >= 0); |