| 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/zone-containers.h" | 10 #include "src/zone-containers.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 BytecodeLabel block_end_; | 77 BytecodeLabel block_end_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 | 80 |
| 81 // A class to help with co-ordinating break and continue statements with | 81 // A class to help with co-ordinating break and continue statements with |
| 82 // their loop. | 82 // their loop. |
| 83 class LoopBuilder final : public BreakableControlFlowBuilder { | 83 class LoopBuilder final : public BreakableControlFlowBuilder { |
| 84 public: | 84 public: |
| 85 explicit LoopBuilder(BytecodeArrayBuilder* builder) | 85 explicit LoopBuilder(BytecodeArrayBuilder* builder, int yield_count) |
| 86 : BreakableControlFlowBuilder(builder), | 86 : BreakableControlFlowBuilder(builder), |
| 87 yield_count(yield_count), |
| 87 continue_sites_(builder->zone()) {} | 88 continue_sites_(builder->zone()) {} |
| 88 ~LoopBuilder(); | 89 ~LoopBuilder(); |
| 89 | 90 |
| 90 void LoopHeader(); | 91 void LoopHeader(); |
| 91 void Condition() { builder()->Bind(&condition_); } | 92 void Condition() { builder()->Bind(&condition_); } |
| 92 void Next() { builder()->Bind(&next_); } | 93 void Next() { builder()->Bind(&next_); } |
| 93 void JumpToHeader() { builder()->Jump(&loop_header_); } | 94 void JumpToHeader(); |
| 94 void JumpToHeaderIfTrue() { builder()->JumpIfTrue(&loop_header_); } | 95 void JumpToHeaderIfTrue() { |
| 96 BytecodeLabel no_jump; |
| 97 builder()->JumpIfFalse(&no_jump); |
| 98 JumpToHeader(); |
| 99 builder()->Bind(&no_jump); |
| 100 } |
| 95 void EndLoop(); | 101 void EndLoop(); |
| 96 | 102 |
| 97 // This method is called when visiting continue statements in the AST. | 103 // This method is called when visiting continue statements in the AST. |
| 98 // Inserts a jump to a unbound label that is patched when the corresponding | 104 // Inserts a jump to a unbound label that is patched when the corresponding |
| 99 // SetContinueTarget is called. | 105 // SetContinueTarget is called. |
| 100 void Continue() { EmitJump(&continue_sites_); } | 106 void Continue() { EmitJump(&continue_sites_); } |
| 101 void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); } | 107 void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); } |
| 102 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); } | 108 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); } |
| 103 void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); } | 109 void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); } |
| 104 | 110 |
| 111 // Number of yields inside the loop. |
| 112 const int yield_count; |
| 113 |
| 105 private: | 114 private: |
| 106 void SetContinueTarget(const BytecodeLabel& continue_target); | 115 void SetContinueTarget(const BytecodeLabel& continue_target); |
| 107 | 116 |
| 108 BytecodeLabel loop_header_; | 117 BytecodeLabel loop_header_; |
| 109 BytecodeLabel condition_; | 118 BytecodeLabel condition_; |
| 110 BytecodeLabel next_; | 119 BytecodeLabel next_; |
| 111 BytecodeLabel loop_end_; | 120 BytecodeLabel loop_end_; |
| 112 | 121 |
| 113 // Unbound labels that identify jumps for continue statements in the code. | 122 // Unbound labels that identify jumps for continue statements in the code. |
| 114 ZoneVector<BytecodeLabel> continue_sites_; | 123 ZoneVector<BytecodeLabel> continue_sites_; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // this finally block will be caught. Note that such a prediction depends on | 198 // this finally block will be caught. Note that such a prediction depends on |
| 190 // whether this try-finally is nested inside a surrounding try-catch. | 199 // whether this try-finally is nested inside a surrounding try-catch. |
| 191 bool will_catch_; | 200 bool will_catch_; |
| 192 }; | 201 }; |
| 193 | 202 |
| 194 } // namespace interpreter | 203 } // namespace interpreter |
| 195 } // namespace internal | 204 } // namespace internal |
| 196 } // namespace v8 | 205 } // namespace v8 |
| 197 | 206 |
| 198 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 207 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| OLD | NEW |