Index: src/interpreter/control-flow-builders.h |
diff --git a/src/interpreter/control-flow-builders.h b/src/interpreter/control-flow-builders.h |
index 209dad50327f22203aa6c39f0ea6c4d3dd25ffa0..5cd9b5bc99680a9822b57121eb0c07e840d68c56 100644 |
--- a/src/interpreter/control-flow-builders.h |
+++ b/src/interpreter/control-flow-builders.h |
@@ -32,37 +32,33 @@ class ControlFlowBuilder BASE_EMBEDDED { |
class BreakableControlFlowBuilder : public ControlFlowBuilder { |
public: |
explicit BreakableControlFlowBuilder(BytecodeArrayBuilder* builder) |
- : ControlFlowBuilder(builder), |
- break_sites_(builder->zone()) {} |
+ : ControlFlowBuilder(builder), break_labels_(builder->zone()) {} |
virtual ~BreakableControlFlowBuilder(); |
// This method should be called by the control flow owner before |
// destruction to update sites that emit jumps for break. |
- void SetBreakTarget(const BytecodeLabel& break_target); |
+ void BindBreakTarget(); |
// This method is called when visiting break statements in the AST. |
- // Inserts a jump to a unbound label that is patched when the corresponding |
- // 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_); } |
+ // Inserts a jump to an unbound label that is patched when the corresponding |
+ // BindBreakTarget is called. |
+ void Break() { EmitJump(&break_labels_); } |
+ void BreakIfTrue() { EmitJumpIfTrue(&break_labels_); } |
+ void BreakIfFalse() { EmitJumpIfFalse(&break_labels_); } |
+ void BreakIfUndefined() { EmitJumpIfUndefined(&break_labels_); } |
+ void BreakIfNull() { EmitJumpIfNull(&break_labels_); } |
- 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); |
+ BytecodeLabels* break_labels() { return &break_labels_; } |
- void BindLabels(const BytecodeLabel& target, ZoneVector<BytecodeLabel>* site); |
+ protected: |
+ void EmitJump(BytecodeLabels* labels); |
+ void EmitJumpIfTrue(BytecodeLabels* labels); |
+ void EmitJumpIfFalse(BytecodeLabels* labels); |
+ void EmitJumpIfUndefined(BytecodeLabels* labels); |
+ void EmitJumpIfNull(BytecodeLabels* labels); |
// Unbound labels that identify jumps for break statements in the code. |
- ZoneVector<BytecodeLabel> break_sites_; |
+ BytecodeLabels break_labels_; |
}; |
@@ -85,29 +81,34 @@ class LoopBuilder final : public BreakableControlFlowBuilder { |
public: |
explicit LoopBuilder(BytecodeArrayBuilder* builder) |
: BreakableControlFlowBuilder(builder), |
- continue_sites_(builder->zone()) {} |
+ continue_labels_(builder->zone()), |
+ header_labels_(builder->zone()) {} |
~LoopBuilder(); |
void LoopHeader(ZoneVector<BytecodeLabel>* additional_labels); |
void JumpToHeader(); |
void JumpToHeaderIfTrue(); |
- void SetContinueTarget(); |
+ void BindContinueTarget(); |
void EndLoop(); |
// This method is called when visiting continue statements in the AST. |
- // Inserts a jump to an unbound label that is patched when SetContinueTarget |
+ // Inserts a jump to an unbound label that is patched when BindContinueTarget |
// is called. |
- void Continue() { EmitJump(&continue_sites_); } |
- void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); } |
- void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); } |
- void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); } |
+ void Continue() { EmitJump(&continue_labels_); } |
+ void ContinueIfTrue() { EmitJumpIfTrue(&continue_labels_); } |
+ void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_labels_); } |
+ void ContinueIfNull() { EmitJumpIfNull(&continue_labels_); } |
+ |
+ BytecodeLabels* header_labels() { return &header_labels_; } |
+ BytecodeLabels* continue_labels() { return &continue_labels_; } |
private: |
BytecodeLabel loop_header_; |
- BytecodeLabel loop_end_; |
- // Unbound labels that identify jumps for continue statements in the code. |
- ZoneVector<BytecodeLabel> continue_sites_; |
+ // Unbound labels that identify jumps for continue statements in the code and |
+ // jumps from checking the loop condition to the header for do-while loops. |
+ BytecodeLabels continue_labels_; |
+ BytecodeLabels header_labels_; |
}; |
@@ -128,12 +129,12 @@ class SwitchBuilder final : public BreakableControlFlowBuilder { |
// This method is called when visiting case comparison operation for |index|. |
// Inserts a JumpIfTrue to a unbound label that is patched when the |
// corresponding SetCaseTarget is called. |
- void Case(int index) { EmitJumpIfTrue(&case_sites_, index); } |
+ void Case(int index) { builder()->JumpIfTrue(&case_sites_.at(index)); } |
// This method is called when all cases comparisons have been emitted if there |
// is a default case statement. Inserts a Jump to a unbound label that is |
// patched when the corresponding SetCaseTarget is called. |
- void DefaultAt(int index) { EmitJump(&case_sites_, index); } |
+ void DefaultAt(int index) { builder()->Jump(&case_sites_.at(index)); } |
private: |
// Unbound labels that identify jumps for case statements in the code. |
@@ -185,7 +186,7 @@ class TryFinallyBuilder final : public ControlFlowBuilder { |
BytecodeLabel handler_; |
// Unbound labels that identify jumps to the finally block in the code. |
- ZoneVector<BytecodeLabel> finalization_sites_; |
+ BytecodeLabels finalization_sites_; |
}; |
} // namespace interpreter |