| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 // Unbound labels that identify jumps for case statements in the code. | 139 // Unbound labels that identify jumps for case statements in the code. |
| 140 ZoneVector<BytecodeLabel> case_sites_; | 140 ZoneVector<BytecodeLabel> case_sites_; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 | 143 |
| 144 // A class to help with co-ordinating control flow in try-catch statements. | 144 // A class to help with co-ordinating control flow in try-catch statements. |
| 145 class TryCatchBuilder final : public ControlFlowBuilder { | 145 class TryCatchBuilder final : public ControlFlowBuilder { |
| 146 public: | 146 public: |
| 147 explicit TryCatchBuilder(BytecodeArrayBuilder* builder) | 147 explicit TryCatchBuilder(BytecodeArrayBuilder* builder, bool catch_predicted) |
| 148 : ControlFlowBuilder(builder), handler_id_(builder->NewHandlerEntry()) {} | 148 : ControlFlowBuilder(builder), |
| 149 handler_id_(builder->NewHandlerEntry()), |
| 150 catch_predicted_(catch_predicted) {} |
| 149 | 151 |
| 150 void BeginTry(Register context); | 152 void BeginTry(Register context); |
| 151 void EndTry(); | 153 void EndTry(); |
| 152 void EndCatch(); | 154 void EndCatch(); |
| 153 | 155 |
| 154 private: | 156 private: |
| 155 int handler_id_; | 157 int handler_id_; |
| 158 bool catch_predicted_; |
| 156 BytecodeLabel handler_; | 159 BytecodeLabel handler_; |
| 157 BytecodeLabel exit_; | 160 BytecodeLabel exit_; |
| 158 }; | 161 }; |
| 159 | 162 |
| 160 | 163 |
| 161 // A class to help with co-ordinating control flow in try-finally statements. | 164 // A class to help with co-ordinating control flow in try-finally statements. |
| 162 class TryFinallyBuilder final : public ControlFlowBuilder { | 165 class TryFinallyBuilder final : public ControlFlowBuilder { |
| 163 public: | 166 public: |
| 164 explicit TryFinallyBuilder(BytecodeArrayBuilder* builder, bool will_catch) | 167 explicit TryFinallyBuilder(BytecodeArrayBuilder* builder, |
| 168 bool catch_predicted) |
| 165 : ControlFlowBuilder(builder), | 169 : ControlFlowBuilder(builder), |
| 166 handler_id_(builder->NewHandlerEntry()), | 170 handler_id_(builder->NewHandlerEntry()), |
| 167 finalization_sites_(builder->zone()), | 171 catch_predicted_(catch_predicted), |
| 168 will_catch_(will_catch) {} | 172 finalization_sites_(builder->zone()) {} |
| 169 | 173 |
| 170 void BeginTry(Register context); | 174 void BeginTry(Register context); |
| 171 void LeaveTry(); | 175 void LeaveTry(); |
| 172 void EndTry(); | 176 void EndTry(); |
| 173 void BeginHandler(); | 177 void BeginHandler(); |
| 174 void BeginFinally(); | 178 void BeginFinally(); |
| 175 void EndFinally(); | 179 void EndFinally(); |
| 176 | 180 |
| 177 private: | 181 private: |
| 178 int handler_id_; | 182 int handler_id_; |
| 183 bool catch_predicted_; |
| 179 BytecodeLabel handler_; | 184 BytecodeLabel handler_; |
| 180 | 185 |
| 181 // Unbound labels that identify jumps to the finally block in the code. | 186 // Unbound labels that identify jumps to the finally block in the code. |
| 182 ZoneVector<BytecodeLabel> finalization_sites_; | 187 ZoneVector<BytecodeLabel> finalization_sites_; |
| 183 | |
| 184 // Conservative prediction of whether exceptions thrown into the handler for | |
| 185 // this finally block will be caught. Note that such a prediction depends on | |
| 186 // whether this try-finally is nested inside a surrounding try-catch. | |
| 187 bool will_catch_; | |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 } // namespace interpreter | 190 } // namespace interpreter |
| 191 } // namespace internal | 191 } // namespace internal |
| 192 } // namespace v8 | 192 } // namespace v8 |
| 193 | 193 |
| 194 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 194 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| OLD | NEW |