From ce7cb78a0f4b52c47d911f39c3d56d37492dcf7d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 22 Jun 2018 14:23:03 +0200 Subject: Clean up finally code gen Instead of emitting GetException MoveReg , StoreReg ... LoadReg MoveReg , SetException and implicitly relying on MoveReg to not clobber the accumulator, it's cleaner to produce MoveReg , GetException StoreReg ... MoveReg , LoadReg SetException Change-Id: I3c392ba5fb75aa2ad3ef32aa776fa7acbc25317c Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compilercontrolflow_p.h | 9 ++++----- 1 file 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); -- cgit v1.2.3