Chromium Code Reviews| Index: src/interpreter/control-flow-builders.h |
| diff --git a/src/interpreter/control-flow-builders.h b/src/interpreter/control-flow-builders.h |
| index c9be6dcdc73ef57a59de53f78aaac99b227f80f2..bd3df092e7cddd5af85100cdef448149a6cdeefb 100644 |
| --- a/src/interpreter/control-flow-builders.h |
| +++ b/src/interpreter/control-flow-builders.h |
| @@ -44,14 +44,18 @@ class BreakableControlFlowBuilder : public ControlFlowBuilder { |
| // SetBreakTarget is called. |
| void Break() { EmitJump(&break_sites_); } |
| void BreakIfTrue() { EmitJumpIfTrue(&break_sites_); } |
| + void BreakIfFalse() { EmitJumpIfFalse(&break_sites_); } |
| void BreakIfUndefined() { EmitJumpIfUndefined(&break_sites_); } |
| void BreakIfNull() { EmitJumpIfNull(&break_sites_); } |
| + |
|
Michael Starzinger
2015/12/16 12:40:12
nit: Stray empty newline.
oth
2015/12/16 14:17:06
Done.
|
| protected: |
| void EmitJump(ZoneVector<BytecodeLabel>* labels); |
| void EmitJump(ZoneVector<BytecodeLabel>* labels, int index); |
| void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels); |
| void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels, int index); |
| + void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels); |
| + void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels, int index); |
| void EmitJumpIfUndefined(ZoneVector<BytecodeLabel>* labels); |
| void EmitJumpIfNull(ZoneVector<BytecodeLabel>* labels); |
| @@ -64,7 +68,6 @@ class BreakableControlFlowBuilder : public ControlFlowBuilder { |
| // A class to help with co-ordinating break and continue statements with |
| // their loop. |
| -// TODO(oth): add support for TF branch/merge info. |
| class LoopBuilder final : public BreakableControlFlowBuilder { |
| public: |
| explicit LoopBuilder(BytecodeArrayBuilder* builder) |
| @@ -72,9 +75,12 @@ class LoopBuilder final : public BreakableControlFlowBuilder { |
| continue_sites_(builder->zone()) {} |
| ~LoopBuilder(); |
| - // This methods should be called by the LoopBuilder owner before |
| - // destruction to update sites that emit jumps for continue. |
| - void SetContinueTarget(const BytecodeLabel& continue_target); |
| + void LoopHeader() { builder()->Bind(&loop_header_); } |
| + void Condition() { builder()->Bind(&condition_); } |
| + void Next() { builder()->Bind(&next_); } |
| + void JumpToHeader() { builder()->Jump(&loop_header_); } |
| + void JumpToHeaderIfTrue() { builder()->JumpIfTrue(&loop_header_); } |
| + void LoopEnd(); |
| // This method is called when visiting continue statements in the AST. |
| // Inserts a jump to a unbound label that is patched when the corresponding |
| @@ -85,6 +91,13 @@ class LoopBuilder final : public BreakableControlFlowBuilder { |
| void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); } |
| private: |
| + void SetContinueTarget(const BytecodeLabel& continue_target); |
| + |
| + BytecodeLabel loop_header_; |
| + BytecodeLabel condition_; |
| + BytecodeLabel next_; |
| + BytecodeLabel loop_end_; |
| + |
| // Unbound labels that identify jumps for continue statements in the code. |
| ZoneVector<BytecodeLabel> continue_sites_; |
| }; |