Commit 5dad97b0 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm] Use vector for states in Int64Lowering

Using a map to store node states in Int64Lowering has proven slow.
Therefore, we change the data structure to a vector indexed by node ids.

Bug: v8:12166, chromium:1271179
Change-Id: I13b78091fe1a6a13c26afd706d3839b0c04390f4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3291308Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77971}
parent 026c972d
...@@ -31,7 +31,7 @@ Int64Lowering::Int64Lowering( ...@@ -31,7 +31,7 @@ Int64Lowering::Int64Lowering(
machine_(machine), machine_(machine),
common_(common), common_(common),
simplified_(simplified), simplified_(simplified),
state_(), state_(graph->NodeCount(), State::kUnvisited),
stack_(zone), stack_(zone),
replacements_(nullptr), replacements_(nullptr),
signature_(signature), signature_(signature),
...@@ -48,21 +48,19 @@ void Int64Lowering::LowerGraph() { ...@@ -48,21 +48,19 @@ void Int64Lowering::LowerGraph() {
return; return;
} }
stack_.push_back({graph()->end(), 0}); stack_.push_back({graph()->end(), 0});
state_[graph()->end()] = State::kOnStack; state_[graph()->end()->id()] = State::kOnStack;
while (!stack_.empty()) { while (!stack_.empty()) {
NodeState& top = stack_.back(); NodeState& top = stack_.back();
if (top.input_index == top.node->InputCount()) { if (top.input_index == top.node->InputCount()) {
// All inputs of top have already been lowered, now lower top. // All inputs of top have already been lowered, now lower top.
stack_.pop_back(); stack_.pop_back();
state_[top.node] = State::kVisited; state_[top.node->id()] = State::kVisited;
LowerNode(top.node); LowerNode(top.node);
} else { } else {
// Push the next input onto the stack. // Push the next input onto the stack.
Node* input = top.node->InputAt(top.input_index++); Node* input = top.node->InputAt(top.input_index++);
static_assert(State() == State::kUnvisited, if (state_[input->id()] == State::kUnvisited) {
"Default value for State has to be kUnvisited");
if (state_[input] == State::kUnvisited) {
if (input->opcode() == IrOpcode::kPhi) { if (input->opcode() == IrOpcode::kPhi) {
// To break cycles with phi nodes we push phis on a separate stack so // To break cycles with phi nodes we push phis on a separate stack so
// that they are processed after all other nodes. // that they are processed after all other nodes.
...@@ -74,7 +72,7 @@ void Int64Lowering::LowerGraph() { ...@@ -74,7 +72,7 @@ void Int64Lowering::LowerGraph() {
} else { } else {
stack_.push_back({input, 0}); stack_.push_back({input, 0});
} }
state_[input] = State::kOnStack; state_[input->id()] = State::kOnStack;
} }
} }
} }
......
...@@ -93,7 +93,7 @@ class V8_EXPORT_PRIVATE Int64Lowering { ...@@ -93,7 +93,7 @@ class V8_EXPORT_PRIVATE Int64Lowering {
MachineOperatorBuilder* machine_; MachineOperatorBuilder* machine_;
CommonOperatorBuilder* common_; CommonOperatorBuilder* common_;
SimplifiedOperatorBuilder* simplified_; SimplifiedOperatorBuilder* simplified_;
std::unordered_map<Node*, State> state_; std::vector<State> state_;
ZoneDeque<NodeState> stack_; ZoneDeque<NodeState> stack_;
Replacement* replacements_; Replacement* replacements_;
Signature<MachineRepresentation>* signature_; Signature<MachineRepresentation>* signature_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment