aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-06-22 14:23:03 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-06-23 06:39:54 +0000
commitce7cb78a0f4b52c47d911f39c3d56d37492dcf7d (patch)
tree23d1ac2eb7457ba232de58b0d090dd76d62bcb27
parent1f056ae9e67a90cbbb6dc2a1c21ed7c361a5c108 (diff)
Clean up finally code gen
Instead of emitting GetException MoveReg <returnvaluetemp>, <returnaddress> StoreReg <exceptiontemp> ... LoadReg <exceptionTemp> MoveReg <returnvaluetemp>, <returnaddress> SetException and implicitly relying on MoveReg to not clobber the accumulator, it's cleaner to produce MoveReg <returnvaluetemp>, <returnaddress> GetException StoreReg <exceptiontemp> ... MoveReg <returnvaluetemp>, <returnaddress> LoadReg <exceptionTemp> SetException Change-Id: I3c392ba5fb75aa2ad3ef32aa776fa7acbc25317c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/compiler/qv4compilercontrolflow_p.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h
index 415a112ec5..1ef290ea56 100644
--- a/src/qml/compiler/qv4compilercontrolflow_p.h
+++ b/src/qml/compiler/qv4compilercontrolflow_p.h
@@ -389,9 +389,6 @@ struct ControlFlowFinally : public ControlFlowUnwind
Codegen::RegisterScope scope(cg);
insideFinally = true;
- int exceptionTemp = generator()->newRegister();
- Instruction::GetException instr;
- generator()->addInstruction(instr);
int returnValueTemp = -1;
if (cg->requiresReturnValue) {
returnValueTemp = generator()->newRegister();
@@ -400,20 +397,22 @@ struct ControlFlowFinally : public ControlFlowUnwind
move.destReg = returnValueTemp;
generator()->addInstruction(move);
}
+ int exceptionTemp = generator()->newRegister();
+ Instruction::GetException instr;
+ generator()->addInstruction(instr);
Reference::fromStackSlot(cg, exceptionTemp).storeConsumeAccumulator();
generator()->setUnwindHandler(parentUnwindHandler());
cg->statement(finally->statement);
insideFinally = false;
- Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator();
-
if (cg->requiresReturnValue) {
Instruction::MoveReg move;
move.srcReg = returnValueTemp;
move.destReg = cg->_returnAddress;
generator()->addInstruction(move);
}
+ Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator();
Instruction::SetException setException;
generator()->addInstruction(setException);