| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 5 #ifndef V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| 6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| 7 | 7 |
| 8 #include "src/interpreter/bytecode-array-builder.h" | 8 #include "src/interpreter/bytecode-array-builder.h" |
| 9 | 9 |
| 10 #include "src/interpreter/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // their loop. | 79 // their loop. |
| 80 class LoopBuilder final : public BreakableControlFlowBuilder { | 80 class LoopBuilder final : public BreakableControlFlowBuilder { |
| 81 public: | 81 public: |
| 82 explicit LoopBuilder(BytecodeArrayBuilder* builder) | 82 explicit LoopBuilder(BytecodeArrayBuilder* builder) |
| 83 : BreakableControlFlowBuilder(builder), | 83 : BreakableControlFlowBuilder(builder), |
| 84 continue_labels_(builder->zone()), | 84 continue_labels_(builder->zone()), |
| 85 header_labels_(builder->zone()) {} | 85 header_labels_(builder->zone()) {} |
| 86 ~LoopBuilder(); | 86 ~LoopBuilder(); |
| 87 | 87 |
| 88 void LoopHeader(ZoneVector<BytecodeLabel>* additional_labels); | 88 void LoopHeader(ZoneVector<BytecodeLabel>* additional_labels); |
| 89 void JumpToHeader(); | 89 void JumpToHeader(int loop_depth); |
| 90 void JumpToHeaderIfTrue(); | |
| 91 void BindContinueTarget(); | 90 void BindContinueTarget(); |
| 92 void EndLoop(); | 91 void EndLoop(); |
| 93 | 92 |
| 94 // This method is called when visiting continue statements in the AST. | 93 // This method is called when visiting continue statements in the AST. |
| 95 // Inserts a jump to an unbound label that is patched when BindContinueTarget | 94 // Inserts a jump to an unbound label that is patched when BindContinueTarget |
| 96 // is called. | 95 // is called. |
| 97 void Continue() { EmitJump(&continue_labels_); } | 96 void Continue() { EmitJump(&continue_labels_); } |
| 98 void ContinueIfTrue() { EmitJumpIfTrue(&continue_labels_); } | 97 void ContinueIfTrue() { EmitJumpIfTrue(&continue_labels_); } |
| 99 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_labels_); } | 98 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_labels_); } |
| 100 void ContinueIfNull() { EmitJumpIfNull(&continue_labels_); } | 99 void ContinueIfNull() { EmitJumpIfNull(&continue_labels_); } |
| 101 | 100 |
| 102 BytecodeLabels* header_labels() { return &header_labels_; } | |
| 103 BytecodeLabels* continue_labels() { return &continue_labels_; } | |
| 104 | |
| 105 private: | 101 private: |
| 106 BytecodeLabel loop_header_; | 102 BytecodeLabel loop_header_; |
| 107 | 103 |
| 108 // Unbound labels that identify jumps for continue statements in the code and | 104 // Unbound labels that identify jumps for continue statements in the code and |
| 109 // jumps from checking the loop condition to the header for do-while loops. | 105 // jumps from checking the loop condition to the header for do-while loops. |
| 110 BytecodeLabels continue_labels_; | 106 BytecodeLabels continue_labels_; |
| 111 BytecodeLabels header_labels_; | 107 BytecodeLabels header_labels_; |
| 112 }; | 108 }; |
| 113 | 109 |
| 114 | 110 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 183 |
| 188 // Unbound labels that identify jumps to the finally block in the code. | 184 // Unbound labels that identify jumps to the finally block in the code. |
| 189 BytecodeLabels finalization_sites_; | 185 BytecodeLabels finalization_sites_; |
| 190 }; | 186 }; |
| 191 | 187 |
| 192 } // namespace interpreter | 188 } // namespace interpreter |
| 193 } // namespace internal | 189 } // namespace internal |
| 194 } // namespace v8 | 190 } // namespace v8 |
| 195 | 191 |
| 196 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 192 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| OLD | NEW |