Commit 5cefb367 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Turn LoadElimination into an AdvancedReducer.

This in turn allows usage of AdvancedReducer::ReplaceWithValue which
has access to the underlying graph reducer.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1158723005

Cr-Commit-Position: refs/heads/master@{#28817}
parent 050e8880
...@@ -36,7 +36,7 @@ Reduction LoadElimination::ReduceLoadField(Node* node) { ...@@ -36,7 +36,7 @@ Reduction LoadElimination::ReduceLoadField(Node* node) {
if (object == NodeProperties::GetValueInput(effect, 0) && if (object == NodeProperties::GetValueInput(effect, 0) &&
access == FieldAccessOf(effect->op())) { access == FieldAccessOf(effect->op())) {
Node* const value = effect; Node* const value = effect;
NodeProperties::ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} }
break; break;
...@@ -45,7 +45,7 @@ Reduction LoadElimination::ReduceLoadField(Node* node) { ...@@ -45,7 +45,7 @@ Reduction LoadElimination::ReduceLoadField(Node* node) {
if (access == FieldAccessOf(effect->op())) { if (access == FieldAccessOf(effect->op())) {
if (object == NodeProperties::GetValueInput(effect, 0)) { if (object == NodeProperties::GetValueInput(effect, 0)) {
Node* const value = NodeProperties::GetValueInput(effect, 1); Node* const value = NodeProperties::GetValueInput(effect, 1);
NodeProperties::ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} }
// TODO(turbofan): Alias analysis to the rescue? // TODO(turbofan): Alias analysis to the rescue?
......
...@@ -11,9 +11,9 @@ namespace v8 { ...@@ -11,9 +11,9 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
class LoadElimination final : public Reducer { class LoadElimination final : public AdvancedReducer {
public: public:
LoadElimination() {} explicit LoadElimination(Editor* editor) : AdvancedReducer(editor) {}
~LoadElimination() final; ~LoadElimination() final;
Reduction Reduce(Node* node) final; Reduction Reduce(Node* node) final;
......
...@@ -569,7 +569,7 @@ struct TypedLoweringPhase { ...@@ -569,7 +569,7 @@ struct TypedLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
LoadElimination load_elimination; LoadElimination load_elimination(&graph_reducer);
JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph()); JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph());
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone);
JSIntrinsicLowering intrinsic_lowering( JSIntrinsicLowering intrinsic_lowering(
......
...@@ -19,7 +19,9 @@ class LoadEliminationTest : public GraphTest { ...@@ -19,7 +19,9 @@ class LoadEliminationTest : public GraphTest {
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
LoadElimination reducer; // TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
LoadElimination reducer(&graph_reducer);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
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