Commit 639ce602 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Simplify escape analysis VerifyReplacement.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/1984203002
Cr-Commit-Position: refs/heads/master@{#36285}
parent 101e076b
......@@ -4,6 +4,7 @@
#include "src/compiler/escape-analysis-reducer.h"
#include "src/compiler/all-nodes.h"
#include "src/compiler/js-graph.h"
#include "src/counters.h"
......@@ -104,7 +105,7 @@ Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
fully_reduced_.Add(node->id());
}
if (Node* rep = escape_analysis()->GetReplacement(node)) {
counters()->turbo_escape_loads_replaced()->Increment();
isolate()->counters()->turbo_escape_loads_replaced()->Increment();
TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(),
node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
ReplaceWithValue(node, rep);
......@@ -137,7 +138,7 @@ Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) {
}
if (escape_analysis()->IsVirtual(node)) {
RelaxEffectsAndControls(node);
counters()->turbo_escape_allocs_replaced()->Increment();
isolate()->counters()->turbo_escape_allocs_replaced()->Increment();
TRACE("Removed allocate #%d from effect chain\n", node->id());
return Changed(node);
}
......@@ -327,40 +328,19 @@ Node* EscapeAnalysisReducer::ReduceStateValueInput(Node* node, int node_index,
}
Counters* EscapeAnalysisReducer::counters() const {
return jsgraph_->isolate()->counters();
}
class EscapeAnalysisVerifier final : public AdvancedReducer {
public:
EscapeAnalysisVerifier(Editor* editor, EscapeAnalysis* escape_analysis)
: AdvancedReducer(editor), escape_analysis_(escape_analysis) {}
Reduction Reduce(Node* node) final {
switch (node->opcode()) {
case IrOpcode::kAllocate:
CHECK(!escape_analysis_->IsVirtual(node));
break;
default:
break;
}
return NoChange();
}
private:
EscapeAnalysis* escape_analysis_;
};
void EscapeAnalysisReducer::VerifyReplacement() const {
#ifdef DEBUG
GraphReducer graph_reducer(zone(), jsgraph()->graph());
EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis());
graph_reducer.AddReducer(&verifier);
graph_reducer.ReduceGraph();
AllNodes all(zone(), jsgraph()->graph());
for (Node* node : all.live) {
if (node->opcode() == IrOpcode::kAllocate) {
CHECK(!escape_analysis_->IsVirtual(node));
}
}
#endif // DEBUG
}
Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); }
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -9,26 +9,22 @@
#include "src/compiler/escape-analysis.h"
#include "src/compiler/graph-reducer.h"
namespace v8 {
namespace internal {
// Forward declarations.
class Counters;
namespace compiler {
// Forward declarations.
class JSGraph;
class EscapeAnalysisReducer final : public AdvancedReducer {
public:
EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
EscapeAnalysis* escape_analysis, Zone* zone);
Reduction Reduce(Node* node) final;
// Verifies that all virtual allocation nodes have been dealt with. Run it
// after this reducer has been applied. Has no effect in release mode.
void VerifyReplacement() const;
private:
......@@ -47,12 +43,12 @@ class EscapeAnalysisReducer final : public AdvancedReducer {
JSGraph* jsgraph() const { return jsgraph_; }
EscapeAnalysis* escape_analysis() const { return escape_analysis_; }
Zone* zone() const { return zone_; }
Counters* counters() const;
Isolate* isolate() const;
JSGraph* const jsgraph_;
EscapeAnalysis* escape_analysis_;
Zone* const zone_;
// _visited marks nodes we already processed (allocs, loads, stores)
// This bit vector marks nodes we already processed (allocs, loads, stores)
// and nodes that do not need a visit from ReduceDeoptState etc.
BitVector fully_reduced_;
bool exists_virtual_allocate_;
......
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