| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // patched when the corresponding SetCaseTarget is called. | 135 // patched when the corresponding SetCaseTarget is called. |
| 136 void DefaultAt(int index) { builder()->Jump(&case_sites_.at(index)); } | 136 void DefaultAt(int index) { builder()->Jump(&case_sites_.at(index)); } |
| 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 V8_EXPORT_PRIVATE TryCatchBuilder final : public ControlFlowBuilder { | 145 class V8_EXPORT_PRIVATE TryCatchBuilder : public ControlFlowBuilder { |
| 146 public: | 146 public: |
| 147 explicit TryCatchBuilder(BytecodeArrayBuilder* builder, | 147 explicit TryCatchBuilder(BytecodeArrayBuilder* builder, |
| 148 HandlerTable::CatchPrediction catch_prediction) | 148 HandlerTable::CatchPrediction catch_prediction) |
| 149 : ControlFlowBuilder(builder), | 149 : ControlFlowBuilder(builder), |
| 150 handler_id_(builder->NewHandlerEntry()), | 150 handler_id_(builder->NewHandlerEntry()), |
| 151 catch_prediction_(catch_prediction) {} | 151 catch_prediction_(catch_prediction) {} |
| 152 | 152 |
| 153 void BeginTry(Register context); | 153 void BeginTry(Register context); |
| 154 void EndTry(); | 154 void EndTry(); |
| 155 void EndCatch(); | 155 void EndCatch(); |
| 156 | 156 |
| 157 protected: |
| 158 HandlerTable::CatchPrediction catch_prediction() const { |
| 159 return catch_prediction_; |
| 160 } |
| 161 |
| 157 private: | 162 private: |
| 158 int handler_id_; | 163 int handler_id_; |
| 159 HandlerTable::CatchPrediction catch_prediction_; | 164 HandlerTable::CatchPrediction catch_prediction_; |
| 160 BytecodeLabel handler_; | 165 BytecodeLabel handler_; |
| 161 BytecodeLabel exit_; | 166 BytecodeLabel exit_; |
| 162 }; | 167 }; |
| 163 | 168 |
| 164 | |
| 165 // A class to help with co-ordinating control flow in try-finally statements. | 169 // A class to help with co-ordinating control flow in try-finally statements. |
| 166 class V8_EXPORT_PRIVATE TryFinallyBuilder final : public ControlFlowBuilder { | 170 class V8_EXPORT_PRIVATE TryFinallyBuilder : public ControlFlowBuilder { |
| 167 public: | 171 public: |
| 168 explicit TryFinallyBuilder(BytecodeArrayBuilder* builder, | 172 explicit TryFinallyBuilder(BytecodeArrayBuilder* builder, |
| 169 HandlerTable::CatchPrediction catch_prediction) | 173 HandlerTable::CatchPrediction catch_prediction) |
| 170 : ControlFlowBuilder(builder), | 174 : ControlFlowBuilder(builder), |
| 171 handler_id_(builder->NewHandlerEntry()), | 175 handler_id_(builder->NewHandlerEntry()), |
| 172 catch_prediction_(catch_prediction), | 176 catch_prediction_(catch_prediction), |
| 173 finalization_sites_(builder->zone()) {} | 177 finalization_sites_(builder->zone()) {} |
| 174 | 178 |
| 175 void BeginTry(Register context); | 179 void BeginTry(Register context); |
| 176 void LeaveTry(); | 180 void LeaveTry(); |
| 177 void EndTry(); | 181 void EndTry(); |
| 178 void BeginHandler(); | 182 void BeginHandler(); |
| 179 void BeginFinally(); | 183 void BeginFinally(); |
| 180 void EndFinally(); | 184 void EndFinally(); |
| 181 | 185 |
| 182 private: | 186 private: |
| 183 int handler_id_; | 187 int handler_id_; |
| 184 HandlerTable::CatchPrediction catch_prediction_; | 188 HandlerTable::CatchPrediction catch_prediction_; |
| 185 BytecodeLabel handler_; | 189 BytecodeLabel handler_; |
| 186 | 190 |
| 187 // Unbound labels that identify jumps to the finally block in the code. | 191 // Unbound labels that identify jumps to the finally block in the code. |
| 188 BytecodeLabels finalization_sites_; | 192 BytecodeLabels finalization_sites_; |
| 189 }; | 193 }; |
| 190 | 194 |
| 191 } // namespace interpreter | 195 } // namespace interpreter |
| 192 } // namespace internal | 196 } // namespace internal |
| 193 } // namespace v8 | 197 } // namespace v8 |
| 194 | 198 |
| 195 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ | 199 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ |
| OLD | NEW |