aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-06-13 15:19:14 +0200
committerLars Knoll <lars.knoll@qt.io>2017-06-20 09:44:14 +0000
commit8577b49c13576d9119e93321c713ff8fe8a1fbcc (patch)
treee1604ffcec5c78d754182bf7c95e33ab4186c0a4 /src/qml/compiler/qv4codegen.cpp
parent7800a5c11b9bb496c7209a67f92e5a7ca1422840 (diff)
Optimize constant to temp assignment
Change-Id: I20b7a4d6780522cb832f6110c8462834d3c5ed62 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index dbf1a43fa7..bac61c1cc8 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2354,8 +2354,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
unsigned returnAddress = entryBlock->newTemp();
- entryBlock->MOVE(entryBlock->TEMP(returnAddress), entryBlock->CONST(IR::UndefinedType, 0));
- setLocation(exitBlock->RET(exitBlock->TEMP(returnAddress)), ast->lastSourceLocation());
+//### setLocation(exitBlock->RET(exitBlock->TEMP(returnAddress)), ast->lastSourceLocation());
qSwap(_function, function);
qSwap(_block, entryBlock);
@@ -2363,6 +2362,16 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
qSwap(_returnAddress, returnAddress);
qSwap(_scopeAndFinally, scopeAndFinally);
+ {
+ auto retTemp = Reference::fromTemp(this, _returnAddress);
+ retTemp.store(Reference::fromConst(this, Encode::undefined()));
+ }
+
+ { // reserve space for outgoing call arguments
+ _function->tempCount += _variableEnvironment->maxNumberOfArguments;
+ _function->currentTemp = _function->tempCount;
+ }
+
for (FormalParameterList *it = formals; it; it = it->next) {
_function->RECEIVE(it->name.toString());
}
@@ -2392,11 +2401,6 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn), 0));
}
- { // reserve space for outgoing call arguments
- _function->tempCount += _variableEnvironment->maxNumberOfArguments;
- _function->currentTemp = _function->tempCount;
- }
-
beginFunctionBodyHook();
sourceElements(body);
@@ -3349,7 +3353,9 @@ void Codegen::Reference::store(const Reference &r) const
if (r.type == Const) {
QV4::Moth::Instruction::MoveConst move;
move.source = r.constant;
- move.result = base;
+ move.result = b;
+ codegen->bytecodeGenerator->addInstruction(move);
+ return;
}
Moth::Param x = r.asRValue();
Q_ASSERT(base != x);