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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // This method is called when all cases comparisons have been emitted if there | 137 // This method is called when all cases comparisons have been emitted if there |
138 // is a default case statement. Inserts a Jump to a unbound label that is | 138 // is a default case statement. Inserts a Jump to a unbound label that is |
139 // patched when the corresponding SetCaseTarget is called. | 139 // patched when the corresponding SetCaseTarget is called. |
140 void DefaultAt(int index) { EmitJump(&case_sites_, index); } | 140 void DefaultAt(int index) { EmitJump(&case_sites_, index); } |
141 | 141 |
142 private: | 142 private: |
143 // Unbound labels that identify jumps for case statements in the code. | 143 // Unbound labels that identify jumps for case statements in the code. |
144 ZoneVector<BytecodeLabel> case_sites_; | 144 ZoneVector<BytecodeLabel> case_sites_; |
145 }; | 145 }; |
146 | 146 |
| 147 |
| 148 // A class to help with co-ordinating control flow in try-catch statements. |
| 149 class TryCatchBuilder final : public ControlFlowBuilder { |
| 150 public: |
| 151 explicit TryCatchBuilder(BytecodeArrayBuilder* builder) |
| 152 : ControlFlowBuilder(builder), handler_id_(builder->NewHandlerEntry()) {} |
| 153 |
| 154 void BeginTry(Register context); |
| 155 void EndTry(); |
| 156 void EndCatch(); |
| 157 |
| 158 private: |
| 159 int handler_id_; |
| 160 BytecodeLabel handler_; |
| 161 BytecodeLabel exit_; |
| 162 }; |
| 163 |
| 164 |
| 165 // A class to help with co-ordinating control flow in try-finally statements. |
| 166 class TryFinallyBuilder final : public ControlFlowBuilder { |
| 167 public: |
| 168 explicit TryFinallyBuilder(BytecodeArrayBuilder* builder) |
| 169 : ControlFlowBuilder(builder), handler_id_(builder->NewHandlerEntry()) {} |
| 170 |
| 171 void BeginTry(Register context); |
| 172 void EndTry(); |
| 173 void EndFinally(); |
| 174 |
| 175 private: |
| 176 int handler_id_; |
| 177 BytecodeLabel handler_; |
| 178 }; |
| 179 |
147 } // namespace interpreter | 180 } // namespace interpreter |
148 } // namespace internal | 181 } // namespace internal |
149 } // namespace v8 | 182 } // namespace v8 |
150 | 183 |
151 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 184 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
OLD | NEW |