OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/raw-machine-assembler.h" | 5 #include "src/compiler/raw-machine-assembler.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 #include "src/compiler/scheduler.h" | 10 #include "src/compiler/scheduler.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 | 79 |
80 void RawMachineAssembler::Branch(Node* condition, RawMachineLabel* true_val, | 80 void RawMachineAssembler::Branch(Node* condition, RawMachineLabel* true_val, |
81 RawMachineLabel* false_val) { | 81 RawMachineLabel* false_val) { |
82 DCHECK(current_block_ != schedule()->end()); | 82 DCHECK(current_block_ != schedule()->end()); |
83 Node* branch = MakeNode(common()->Branch(), 1, &condition); | 83 Node* branch = MakeNode(common()->Branch(), 1, &condition); |
84 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); | 84 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); |
85 current_block_ = nullptr; | 85 current_block_ = nullptr; |
86 } | 86 } |
87 | 87 |
| 88 void RawMachineAssembler::BranchIfException(Node* node, |
| 89 RawMachineLabel* if_exception) { |
| 90 RawMachineLabel success, call, exception; |
| 91 DCHECK_NE(schedule()->end(), current_block_); |
| 92 DCHECK(!node->op()->HasProperty(Operator::kNoThrow)); |
| 93 |
| 94 Goto(&call); |
| 95 Bind(&call); |
| 96 schedule()->AddCall(CurrentBlock(), node, Use(&success), Use(&exception)); |
| 97 current_block_ = nullptr; |
| 98 |
| 99 Bind(&exception); |
| 100 { |
| 101 const Operator* op = common()->IfException(); |
| 102 Node* args[] = {node, node}; |
| 103 Node* on_exception = MakeNode(op, arraysize(args), args); |
| 104 schedule()->AddNode(CurrentBlock(), on_exception); |
| 105 Goto(if_exception); |
| 106 } |
| 107 |
| 108 Bind(&success); |
| 109 } |
| 110 |
88 void RawMachineAssembler::Switch(Node* index, RawMachineLabel* default_label, | 111 void RawMachineAssembler::Switch(Node* index, RawMachineLabel* default_label, |
89 const int32_t* case_values, | 112 const int32_t* case_values, |
90 RawMachineLabel** case_labels, | 113 RawMachineLabel** case_labels, |
91 size_t case_count) { | 114 size_t case_count) { |
92 DCHECK_NE(schedule()->end(), current_block_); | 115 DCHECK_NE(schedule()->end(), current_block_); |
93 size_t succ_count = case_count + 1; | 116 size_t succ_count = case_count + 1; |
94 Node* switch_node = AddNode(common()->Switch(succ_count), index); | 117 Node* switch_node = AddNode(common()->Switch(succ_count), index); |
95 BasicBlock** succ_blocks = zone()->NewArray<BasicBlock*>(succ_count); | 118 BasicBlock** succ_blocks = zone()->NewArray<BasicBlock*>(succ_count); |
96 for (size_t index = 0; index < case_count; ++index) { | 119 for (size_t index = 0; index < case_count; ++index) { |
97 int32_t case_value = case_values[index]; | 120 int32_t case_value = case_values[index]; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // The raw machine assembler nodes do not have effect and control inputs, | 535 // The raw machine assembler nodes do not have effect and control inputs, |
513 // so we disable checking input counts here. | 536 // so we disable checking input counts here. |
514 return graph()->NewNodeUnchecked(op, input_count, inputs); | 537 return graph()->NewNodeUnchecked(op, input_count, inputs); |
515 } | 538 } |
516 | 539 |
517 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } | 540 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } |
518 | 541 |
519 } // namespace compiler | 542 } // namespace compiler |
520 } // namespace internal | 543 } // namespace internal |
521 } // namespace v8 | 544 } // namespace v8 |
OLD | NEW |