summaryrefslogtreecommitdiff
path: root/deps/v8/src/maglev/maglev-basic-block.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/maglev/maglev-basic-block.h')
-rw-r--r--deps/v8/src/maglev/maglev-basic-block.h47
1 files changed, 46 insertions, 1 deletions
diff --git a/deps/v8/src/maglev/maglev-basic-block.h b/deps/v8/src/maglev/maglev-basic-block.h
index 7f583e5bb2..d40b3c5c2e 100644
--- a/deps/v8/src/maglev/maglev-basic-block.h
+++ b/deps/v8/src/maglev/maglev-basic-block.h
@@ -7,6 +7,7 @@
#include <vector>
+#include "src/base/small-vector.h"
#include "src/codegen/label.h"
#include "src/maglev/maglev-interpreter-frame-state.h"
#include "src/maglev/maglev-ir.h"
@@ -26,7 +27,14 @@ class BasicBlock {
uint32_t first_id() const {
if (has_phi()) return phis()->first()->id();
- return nodes_.is_empty() ? control_node()->id() : nodes_.first()->id();
+ if (nodes_.is_empty()) {
+ return control_node()->id();
+ }
+ auto node = nodes_.first();
+ while (node && node->Is<Identity>()) {
+ node = node->NextNode();
+ }
+ return node ? node->id() : control_node()->id();
}
uint32_t FirstNonGapMoveId() const {
@@ -34,6 +42,7 @@ class BasicBlock {
if (!nodes_.is_empty()) {
for (const Node* node : nodes_) {
if (IsGapMoveNode(node->opcode())) continue;
+ if (node->Is<Identity>()) continue;
return node->id();
}
}
@@ -52,11 +61,17 @@ class BasicBlock {
bool is_edge_split_block() const { return is_edge_split_block_; }
+ bool is_loop() const { return has_state() && state()->is_loop(); }
+
MergePointRegisterState& edge_split_block_register_state() {
DCHECK(is_edge_split_block());
return *edge_split_block_register_state_;
}
+ bool contains_node_id(NodeIdT id) const {
+ return id >= first_id() && id <= control_node()->id();
+ }
+
void set_edge_split_block_register_state(
MergePointRegisterState* register_state) {
DCHECK(is_edge_split_block());
@@ -73,6 +88,13 @@ class BasicBlock {
edge_split_block_register_state_ = nullptr;
}
+ bool is_start_block_of_switch_case() const {
+ return is_start_block_of_switch_case_;
+ }
+ void set_start_block_of_switch_case(bool value) {
+ is_start_block_of_switch_case_ = value;
+ }
+
Phi::List* phis() const {
DCHECK(has_phi());
return state_->phis();
@@ -90,6 +112,8 @@ class BasicBlock {
control_node()->Cast<UnconditionalControlNode>()->set_predecessor_id(id);
}
+ base::SmallVector<BasicBlock*, 2> successors() const;
+
Label* label() { return &label_; }
MergePointInterpreterFrameState* state() const {
DCHECK(has_state());
@@ -103,6 +127,7 @@ class BasicBlock {
private:
bool is_edge_split_block_ = false;
+ bool is_start_block_of_switch_case_ = false;
Node::List nodes_;
ControlNode* control_node_;
union {
@@ -112,6 +137,26 @@ class BasicBlock {
Label label_;
};
+inline base::SmallVector<BasicBlock*, 2> BasicBlock::successors() const {
+ ControlNode* control = control_node();
+ if (auto node = control->TryCast<UnconditionalControlNode>()) {
+ return {node->target()};
+ } else if (auto node = control->TryCast<BranchControlNode>()) {
+ return {node->if_true(), node->if_false()};
+ } else if (auto node = control->TryCast<Switch>()) {
+ base::SmallVector<BasicBlock*, 2> succs;
+ for (int i = 0; i < node->size(); i++) {
+ succs.push_back(node->targets()[i].block_ptr());
+ }
+ if (node->has_fallthrough()) {
+ succs.push_back(node->fallthrough());
+ }
+ return succs;
+ } else {
+ return base::SmallVector<BasicBlock*, 2>();
+ }
+}
+
} // namespace maglev
} // namespace internal
} // namespace v8