5 #ifndef V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ 6 #define V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_ 8 #include "src/interpreter/bytecode-array-builder.h" 10 #include "src/ast/ast-source-ranges.h" 11 #include "src/interpreter/block-coverage-builder.h" 12 #include "src/interpreter/bytecode-label.h" 13 #include "src/zone/zone-containers.h" 17 namespace interpreter {
22 : builder_(builder) {}
41 break_labels_(builder->zone()),
43 block_coverage_builder_(block_coverage_builder) {}
49 void Break() { EmitJump(&break_labels_); }
50 void BreakIfTrue(BytecodeArrayBuilder::ToBooleanMode mode) {
51 EmitJumpIfTrue(mode, &break_labels_);
53 void BreakIfFalse(BytecodeArrayBuilder::ToBooleanMode mode) {
54 EmitJumpIfFalse(mode, &break_labels_);
56 void BreakIfUndefined() { EmitJumpIfUndefined(&break_labels_); }
57 void BreakIfNull() { EmitJumpIfNull(&break_labels_); }
61 void set_needs_continuation_counter() { needs_continuation_counter_ =
true; }
62 bool needs_continuation_counter()
const {
63 return needs_continuation_counter_;
68 void EmitJumpIfTrue(BytecodeArrayBuilder::ToBooleanMode mode,
70 void EmitJumpIfFalse(BytecodeArrayBuilder::ToBooleanMode mode,
76 void BindBreakTarget();
84 bool needs_continuation_counter_ =
false;
108 continue_labels_(builder->zone()) {
109 if (block_coverage_builder_ !=
nullptr) {
110 set_needs_continuation_counter();
111 block_coverage_body_slot_ =
112 block_coverage_builder_->AllocateBlockCoverageSlot(
113 node, SourceRangeKind::kBody);
120 void JumpToHeader(
int loop_depth);
121 void BindContinueTarget();
126 void Continue() { EmitJump(&continue_labels_); }
127 void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_labels_); }
128 void ContinueIfNull() { EmitJumpIfNull(&continue_labels_); }
137 int block_coverage_body_slot_;
149 case_sites_(builder->zone()) {
150 case_sites_.resize(number_of_cases);
156 void SetCaseTarget(
int index,
CaseClause* clause);
161 void Case(BytecodeArrayBuilder::ToBooleanMode mode,
int index) {
162 builder()->JumpIfTrue(mode, &case_sites_.at(index));
168 void DefaultAt(
int index) { builder()->Jump(&case_sites_.at(index)); }
182 HandlerTable::CatchPrediction catch_prediction)
184 handler_id_(builder->NewHandlerEntry()),
185 catch_prediction_(catch_prediction),
186 block_coverage_builder_(block_coverage_builder),
187 statement_(statement) {}
197 HandlerTable::CatchPrediction catch_prediction_;
212 HandlerTable::CatchPrediction catch_prediction)
214 handler_id_(builder->NewHandlerEntry()),
215 catch_prediction_(catch_prediction),
216 finalization_sites_(builder->zone()),
217 block_coverage_builder_(block_coverage_builder),
218 statement_(statement) {}
231 HandlerTable::CatchPrediction catch_prediction_;
248 end_labels_(builder->zone()),
249 then_labels_(builder->zone()),
250 else_labels_(builder->zone()),
252 block_coverage_builder_(block_coverage_builder) {
253 DCHECK(node->IsIfStatement() || node->IsConditional());
254 if (block_coverage_builder !=
nullptr) {
255 block_coverage_then_slot_ =
256 block_coverage_builder->AllocateBlockCoverageSlot(
257 node, SourceRangeKind::kThen);
258 block_coverage_else_slot_ =
259 block_coverage_builder->AllocateBlockCoverageSlot(
260 node, SourceRangeKind::kElse);
279 int block_coverage_then_slot_;
280 int block_coverage_else_slot_;
288 #endif // V8_INTERPRETER_CONTROL_FLOW_BUILDERS_H_