[turbofan] Simplify escape analysis VerifyReplacement.
R=jarin@chromium.org Review-Url: https://codereview.chromium.org/1984203002 Cr-Commit-Position: refs/heads/master@{#36285}
This commit is contained in:
parent
101e076b34
commit
639ce6027b
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "src/compiler/escape-analysis-reducer.h"
|
#include "src/compiler/escape-analysis-reducer.h"
|
||||||
|
|
||||||
|
#include "src/compiler/all-nodes.h"
|
||||||
#include "src/compiler/js-graph.h"
|
#include "src/compiler/js-graph.h"
|
||||||
#include "src/counters.h"
|
#include "src/counters.h"
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
|
|||||||
fully_reduced_.Add(node->id());
|
fully_reduced_.Add(node->id());
|
||||||
}
|
}
|
||||||
if (Node* rep = escape_analysis()->GetReplacement(node)) {
|
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(),
|
TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(),
|
||||||
node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
|
node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
|
||||||
ReplaceWithValue(node, rep);
|
ReplaceWithValue(node, rep);
|
||||||
@ -137,7 +138,7 @@ Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) {
|
|||||||
}
|
}
|
||||||
if (escape_analysis()->IsVirtual(node)) {
|
if (escape_analysis()->IsVirtual(node)) {
|
||||||
RelaxEffectsAndControls(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());
|
TRACE("Removed allocate #%d from effect chain\n", node->id());
|
||||||
return Changed(node);
|
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 {
|
void EscapeAnalysisReducer::VerifyReplacement() const {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
GraphReducer graph_reducer(zone(), jsgraph()->graph());
|
AllNodes all(zone(), jsgraph()->graph());
|
||||||
EscapeAnalysisVerifier verifier(&graph_reducer, escape_analysis());
|
for (Node* node : all.live) {
|
||||||
graph_reducer.AddReducer(&verifier);
|
if (node->opcode() == IrOpcode::kAllocate) {
|
||||||
graph_reducer.ReduceGraph();
|
CHECK(!escape_analysis_->IsVirtual(node));
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); }
|
||||||
|
|
||||||
} // namespace compiler
|
} // namespace compiler
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
@ -9,26 +9,22 @@
|
|||||||
#include "src/compiler/escape-analysis.h"
|
#include "src/compiler/escape-analysis.h"
|
||||||
#include "src/compiler/graph-reducer.h"
|
#include "src/compiler/graph-reducer.h"
|
||||||
|
|
||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Forward declarations.
|
|
||||||
class Counters;
|
|
||||||
|
|
||||||
|
|
||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class JSGraph;
|
class JSGraph;
|
||||||
|
|
||||||
|
|
||||||
class EscapeAnalysisReducer final : public AdvancedReducer {
|
class EscapeAnalysisReducer final : public AdvancedReducer {
|
||||||
public:
|
public:
|
||||||
EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
|
EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
|
||||||
EscapeAnalysis* escape_analysis, Zone* zone);
|
EscapeAnalysis* escape_analysis, Zone* zone);
|
||||||
|
|
||||||
Reduction Reduce(Node* node) final;
|
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;
|
void VerifyReplacement() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -47,12 +43,12 @@ class EscapeAnalysisReducer final : public AdvancedReducer {
|
|||||||
JSGraph* jsgraph() const { return jsgraph_; }
|
JSGraph* jsgraph() const { return jsgraph_; }
|
||||||
EscapeAnalysis* escape_analysis() const { return escape_analysis_; }
|
EscapeAnalysis* escape_analysis() const { return escape_analysis_; }
|
||||||
Zone* zone() const { return zone_; }
|
Zone* zone() const { return zone_; }
|
||||||
Counters* counters() const;
|
Isolate* isolate() const;
|
||||||
|
|
||||||
JSGraph* const jsgraph_;
|
JSGraph* const jsgraph_;
|
||||||
EscapeAnalysis* escape_analysis_;
|
EscapeAnalysis* escape_analysis_;
|
||||||
Zone* const zone_;
|
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.
|
// and nodes that do not need a visit from ReduceDeoptState etc.
|
||||||
BitVector fully_reduced_;
|
BitVector fully_reduced_;
|
||||||
bool exists_virtual_allocate_;
|
bool exists_virtual_allocate_;
|
||||||
|
Loading…
Reference in New Issue
Block a user