diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-15 13:15:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-23 13:19:01 +0000 |
commit | 6f1e2722b9eef73a4fe19951b47c4b172642a2ba (patch) | |
tree | 01e58c038a7d63ed9206c834c4f6df1fb51db142 /src/qml/compiler/qv4compilercontrolflow_p.h | |
parent | 3e6d5d9cd1de1373f67f2ff31373a59c37f7b576 (diff) |
Simplify Push and PopContext instructions
There's no need for a temp register to store the old context in,
as PopContext can simply retrieve the old context from
the current one.
Change-Id: Ife9cfdff7fa8e47fc71e844a7798de88dbc79e26
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilercontrolflow_p.h')
-rw-r--r-- | src/qml/compiler/qv4compilercontrolflow_p.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h index 89791330f9..db109533eb 100644 --- a/src/qml/compiler/qv4compilercontrolflow_p.h +++ b/src/qml/compiler/qv4compilercontrolflow_p.h @@ -306,11 +306,9 @@ struct ControlFlowWith : public ControlFlowUnwind : ControlFlowUnwind(cg, With) { setupExceptionHandler(); - savedContextRegister = Moth::StackSlot::createRegister(generator()->newRegister()); // assumes the with object is in the accumulator Instruction::PushWithContext pushScope; - pushScope.reg = savedContextRegister; generator()->addInstruction(pushScope); generator()->setExceptionHandler(&unwindLabel); } @@ -321,12 +319,10 @@ struct ControlFlowWith : public ControlFlowUnwind generator()->setExceptionHandler(parentExceptionHandler()); Instruction::PopContext pop; - pop.reg = savedContextRegister; generator()->addInstruction(pop); emitUnwindHandler(); } - Moth::StackSlot savedContextRegister; }; struct ControlFlowBlock : public ControlFlowUnwind @@ -335,9 +331,9 @@ struct ControlFlowBlock : public ControlFlowUnwind : ControlFlowUnwind(cg, Block) { block = cg->enterBlock(ast); - savedContextRegister = block->emitBlockHeader(cg); + block->emitBlockHeader(cg); - if (savedContextRegister != -1) { + if (block->requiresExecutionContext) { setupExceptionHandler(); generator()->setExceptionHandler(&unwindLabel); } @@ -345,24 +341,23 @@ struct ControlFlowBlock : public ControlFlowUnwind virtual ~ControlFlowBlock() { // emit code for unwinding - if (savedContextRegister != -1) { + if (block->requiresExecutionContext ) { unwindLabel.link(); generator()->setExceptionHandler(parentExceptionHandler()); } - block->emitBlockFooter(cg, savedContextRegister); + block->emitBlockFooter(cg); - if (savedContextRegister != -1) + if (block->requiresExecutionContext ) emitUnwindHandler(); cg->leaveBlock(); } virtual Handler getHandler(HandlerType type, const QString &label = QString()) { - if (savedContextRegister == -1) + if (!block->requiresExecutionContext ) return getParentHandler(type, label); return ControlFlowUnwind::getHandler(type, label); } - int savedContextRegister = -1; Context *block; }; @@ -414,7 +409,7 @@ struct ControlFlowCatch : public ControlFlowUnwind Context *block = cg->enterBlock(catchExpression); - int savedContextReg = block->emitBlockHeader(cg); + block->emitBlockHeader(cg); // clear the unwind temp for exceptions, we want to resume normal code flow afterwards Reference::storeConstOnStack(cg, QV4::Encode::undefined(), controlFlowTemp); @@ -430,7 +425,7 @@ struct ControlFlowCatch : public ControlFlowUnwind // exceptions inside catch and break/return statements go here catchUnwindLabel.link(); - block->emitBlockFooter(cg, savedContextReg); + block->emitBlockFooter(cg); cg->leaveBlock(); |