Deprecate LoweringBuilder in favor of Reducer.
R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/476733002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23128 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
0caf06dbd2
commit
3adac582b0
2
BUILD.gn
2
BUILD.gn
@ -505,8 +505,6 @@ source_set("v8_base") {
|
|||||||
"src/compiler/linkage-impl.h",
|
"src/compiler/linkage-impl.h",
|
||||||
"src/compiler/linkage.cc",
|
"src/compiler/linkage.cc",
|
||||||
"src/compiler/linkage.h",
|
"src/compiler/linkage.h",
|
||||||
"src/compiler/lowering-builder.cc",
|
|
||||||
"src/compiler/lowering-builder.h",
|
|
||||||
"src/compiler/machine-node-factory.h",
|
"src/compiler/machine-node-factory.h",
|
||||||
"src/compiler/machine-operator-reducer.cc",
|
"src/compiler/machine-operator-reducer.cc",
|
||||||
"src/compiler/machine-operator-reducer.h",
|
"src/compiler/machine-operator-reducer.h",
|
||||||
|
@ -156,10 +156,8 @@ class KeyedStoreICStubShim : public HydrogenCodeStub {
|
|||||||
|
|
||||||
|
|
||||||
JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph,
|
JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph,
|
||||||
MachineOperatorBuilder* machine,
|
MachineOperatorBuilder* machine)
|
||||||
SourcePositionTable* source_positions)
|
: info_(info),
|
||||||
: LoweringBuilder(jsgraph->graph(), source_positions),
|
|
||||||
info_(info),
|
|
||||||
jsgraph_(jsgraph),
|
jsgraph_(jsgraph),
|
||||||
linkage_(new (jsgraph->zone()) Linkage(info)),
|
linkage_(new (jsgraph->zone()) Linkage(info)),
|
||||||
machine_(machine) {}
|
machine_(machine) {}
|
||||||
@ -200,7 +198,7 @@ Node* JSGenericLowering::ExternalConstant(ExternalReference ref) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSGenericLowering::Lower(Node* node) {
|
Reduction JSGenericLowering::Reduce(Node* node) {
|
||||||
Node* replacement = NULL;
|
Node* replacement = NULL;
|
||||||
// Dispatch according to the opcode.
|
// Dispatch according to the opcode.
|
||||||
switch (node->opcode()) {
|
switch (node->opcode()) {
|
||||||
@ -213,14 +211,10 @@ void JSGenericLowering::Lower(Node* node) {
|
|||||||
#undef DECLARE_CASE
|
#undef DECLARE_CASE
|
||||||
default:
|
default:
|
||||||
// Nothing to see.
|
// Nothing to see.
|
||||||
return;
|
return NoChange();
|
||||||
}
|
}
|
||||||
|
DCHECK_EQ(node, replacement);
|
||||||
// Nothing to do if lowering was done by patching the existing node.
|
return Changed(replacement);
|
||||||
if (replacement == node) return;
|
|
||||||
|
|
||||||
// Iterate through uses of the original node and replace uses accordingly.
|
|
||||||
UNIMPLEMENTED();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
#include "src/allocation.h"
|
#include "src/allocation.h"
|
||||||
#include "src/compiler/graph.h"
|
#include "src/compiler/graph.h"
|
||||||
|
#include "src/compiler/graph-reducer.h"
|
||||||
#include "src/compiler/js-graph.h"
|
#include "src/compiler/js-graph.h"
|
||||||
#include "src/compiler/lowering-builder.h"
|
|
||||||
#include "src/compiler/opcodes.h"
|
#include "src/compiler/opcodes.h"
|
||||||
#include "src/unique.h"
|
#include "src/unique.h"
|
||||||
|
|
||||||
@ -28,14 +28,13 @@ class MachineOperatorBuilder;
|
|||||||
class Linkage;
|
class Linkage;
|
||||||
|
|
||||||
// Lowers JS-level operators to runtime and IC calls in the "generic" case.
|
// Lowers JS-level operators to runtime and IC calls in the "generic" case.
|
||||||
class JSGenericLowering : public LoweringBuilder {
|
class JSGenericLowering : public Reducer {
|
||||||
public:
|
public:
|
||||||
JSGenericLowering(CompilationInfo* info, JSGraph* graph,
|
JSGenericLowering(CompilationInfo* info, JSGraph* graph,
|
||||||
MachineOperatorBuilder* machine,
|
MachineOperatorBuilder* machine);
|
||||||
SourcePositionTable* source_positions);
|
|
||||||
virtual ~JSGenericLowering() {}
|
virtual ~JSGenericLowering() {}
|
||||||
|
|
||||||
virtual void Lower(Node* node);
|
virtual Reduction Reduce(Node* node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Dispatched depending on opcode.
|
// Dispatched depending on opcode.
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "src/compiler/graph-reducer.h"
|
#include "src/compiler/graph-reducer.h"
|
||||||
#include "src/compiler/js-graph.h"
|
#include "src/compiler/js-graph.h"
|
||||||
#include "src/compiler/lowering-builder.h"
|
|
||||||
#include "src/compiler/machine-operator.h"
|
#include "src/compiler/machine-operator.h"
|
||||||
#include "src/compiler/node.h"
|
#include "src/compiler/node.h"
|
||||||
#include "src/compiler/simplified-operator.h"
|
#include "src/compiler/simplified-operator.h"
|
||||||
@ -17,18 +16,15 @@ namespace internal {
|
|||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
// Lowers JS-level operators to simplified operators based on types.
|
// Lowers JS-level operators to simplified operators based on types.
|
||||||
class JSTypedLowering : public LoweringBuilder {
|
class JSTypedLowering : public Reducer {
|
||||||
public:
|
public:
|
||||||
explicit JSTypedLowering(JSGraph* jsgraph,
|
explicit JSTypedLowering(JSGraph* jsgraph)
|
||||||
SourcePositionTable* source_positions)
|
: jsgraph_(jsgraph),
|
||||||
: LoweringBuilder(jsgraph->graph(), source_positions),
|
|
||||||
jsgraph_(jsgraph),
|
|
||||||
simplified_(jsgraph->zone()),
|
simplified_(jsgraph->zone()),
|
||||||
machine_(jsgraph->zone()) {}
|
machine_(jsgraph->zone()) {}
|
||||||
virtual ~JSTypedLowering() {}
|
virtual ~JSTypedLowering() {}
|
||||||
|
|
||||||
Reduction Reduce(Node* node);
|
virtual Reduction Reduce(Node* node);
|
||||||
virtual void Lower(Node* node) { Reduce(node); }
|
|
||||||
|
|
||||||
JSGraph* jsgraph() { return jsgraph_; }
|
JSGraph* jsgraph() { return jsgraph_; }
|
||||||
Graph* graph() { return jsgraph_->graph(); }
|
Graph* graph() { return jsgraph_->graph(); }
|
||||||
@ -40,9 +36,7 @@ class JSTypedLowering : public LoweringBuilder {
|
|||||||
MachineOperatorBuilder machine_;
|
MachineOperatorBuilder machine_;
|
||||||
|
|
||||||
Reduction ReplaceEagerly(Node* old, Node* node);
|
Reduction ReplaceEagerly(Node* old, Node* node);
|
||||||
Reduction NoChange() { return Reducer::NoChange(); }
|
|
||||||
Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); }
|
Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); }
|
||||||
Reduction Changed(Node* node) { return Reducer::Changed(node); }
|
|
||||||
Reduction ReduceJSAdd(Node* node);
|
Reduction ReduceJSAdd(Node* node);
|
||||||
Reduction ReduceJSComparison(Node* node);
|
Reduction ReduceJSComparison(Node* node);
|
||||||
Reduction ReduceJSEqual(Node* node, bool invert);
|
Reduction ReduceJSEqual(Node* node, bool invert);
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "src/compiler/graph-inl.h"
|
|
||||||
#include "src/compiler/lowering-builder.h"
|
|
||||||
#include "src/compiler/node-aux-data-inl.h"
|
|
||||||
#include "src/compiler/node-properties-inl.h"
|
|
||||||
|
|
||||||
namespace v8 {
|
|
||||||
namespace internal {
|
|
||||||
namespace compiler {
|
|
||||||
|
|
||||||
class LoweringBuilder::NodeVisitor : public NullNodeVisitor {
|
|
||||||
public:
|
|
||||||
explicit NodeVisitor(LoweringBuilder* lowering) : lowering_(lowering) {}
|
|
||||||
|
|
||||||
GenericGraphVisit::Control Post(Node* node) {
|
|
||||||
if (lowering_->source_positions_ != NULL) {
|
|
||||||
SourcePositionTable::Scope pos(lowering_->source_positions_, node);
|
|
||||||
lowering_->Lower(node);
|
|
||||||
} else {
|
|
||||||
lowering_->Lower(node);
|
|
||||||
}
|
|
||||||
return GenericGraphVisit::CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
LoweringBuilder* lowering_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
LoweringBuilder::LoweringBuilder(Graph* graph,
|
|
||||||
SourcePositionTable* source_positions)
|
|
||||||
: graph_(graph), source_positions_(source_positions) {}
|
|
||||||
|
|
||||||
|
|
||||||
void LoweringBuilder::LowerAllNodes() {
|
|
||||||
NodeVisitor visitor(this);
|
|
||||||
graph()->VisitNodeInputsFromEnd(&visitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace compiler
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace v8
|
|
@ -1,38 +0,0 @@
|
|||||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#ifndef V8_COMPILER_LOWERING_BUILDER_H_
|
|
||||||
#define V8_COMPILER_LOWERING_BUILDER_H_
|
|
||||||
|
|
||||||
#include "src/v8.h"
|
|
||||||
|
|
||||||
#include "src/compiler/graph.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace v8 {
|
|
||||||
namespace internal {
|
|
||||||
namespace compiler {
|
|
||||||
|
|
||||||
// TODO(dcarney): rename this class.
|
|
||||||
class LoweringBuilder {
|
|
||||||
public:
|
|
||||||
explicit LoweringBuilder(Graph* graph, SourcePositionTable* source_positions);
|
|
||||||
virtual ~LoweringBuilder() {}
|
|
||||||
|
|
||||||
void LowerAllNodes();
|
|
||||||
virtual void Lower(Node* node) = 0; // Exposed for testing.
|
|
||||||
|
|
||||||
Graph* graph() const { return graph_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
class NodeVisitor;
|
|
||||||
Graph* graph_;
|
|
||||||
SourcePositionTable* source_positions_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace compiler
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace v8
|
|
||||||
|
|
||||||
#endif // V8_COMPILER_LOWERING_BUILDER_H_
|
|
@ -211,8 +211,12 @@ Handle<Code> Pipeline::GenerateCode() {
|
|||||||
// Lower JSOperators where we can determine types.
|
// Lower JSOperators where we can determine types.
|
||||||
PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
|
PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
|
||||||
"typed lowering");
|
"typed lowering");
|
||||||
JSTypedLowering lowering(&jsgraph, &source_positions);
|
SourcePositionTable::Scope pos(&source_positions,
|
||||||
lowering.LowerAllNodes();
|
SourcePosition::Unknown());
|
||||||
|
JSTypedLowering lowering(&jsgraph);
|
||||||
|
GraphReducer graph_reducer(&graph);
|
||||||
|
graph_reducer.AddReducer(&lowering);
|
||||||
|
graph_reducer.ReduceGraph();
|
||||||
|
|
||||||
VerifyAndPrintGraph(&graph, "Lowered typed");
|
VerifyAndPrintGraph(&graph, "Lowered typed");
|
||||||
}
|
}
|
||||||
@ -224,9 +228,13 @@ Handle<Code> Pipeline::GenerateCode() {
|
|||||||
// Lower any remaining generic JSOperators.
|
// Lower any remaining generic JSOperators.
|
||||||
PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
|
PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
|
||||||
"generic lowering");
|
"generic lowering");
|
||||||
|
SourcePositionTable::Scope pos(&source_positions,
|
||||||
|
SourcePosition::Unknown());
|
||||||
MachineOperatorBuilder machine(zone());
|
MachineOperatorBuilder machine(zone());
|
||||||
JSGenericLowering lowering(info(), &jsgraph, &machine, &source_positions);
|
JSGenericLowering lowering(info(), &jsgraph, &machine);
|
||||||
lowering.LowerAllNodes();
|
GraphReducer graph_reducer(&graph);
|
||||||
|
graph_reducer.AddReducer(&lowering);
|
||||||
|
graph_reducer.ReduceGraph();
|
||||||
|
|
||||||
VerifyAndPrintGraph(&graph, "Lowered generic");
|
VerifyAndPrintGraph(&graph, "Lowered generic");
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,9 @@ void SimplifiedLowering::LowerAllNodes() {
|
|||||||
RepresentationSelector selector(jsgraph(), zone(), &changer);
|
RepresentationSelector selector(jsgraph(), zone(), &changer);
|
||||||
selector.Run(this);
|
selector.Run(this);
|
||||||
|
|
||||||
LoweringBuilder::LowerAllNodes();
|
GraphReducer graph_reducer(graph());
|
||||||
|
graph_reducer.AddReducer(this);
|
||||||
|
graph_reducer.ReduceGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -963,7 +965,7 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SimplifiedLowering::Lower(Node* node) {}
|
Reduction SimplifiedLowering::Reduce(Node* node) { return NoChange(); }
|
||||||
|
|
||||||
|
|
||||||
void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) {
|
void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) {
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "src/compiler/graph-reducer.h"
|
#include "src/compiler/graph-reducer.h"
|
||||||
#include "src/compiler/js-graph.h"
|
#include "src/compiler/js-graph.h"
|
||||||
#include "src/compiler/lowering-builder.h"
|
|
||||||
#include "src/compiler/machine-operator.h"
|
#include "src/compiler/machine-operator.h"
|
||||||
#include "src/compiler/node.h"
|
#include "src/compiler/node.h"
|
||||||
#include "src/compiler/simplified-operator.h"
|
#include "src/compiler/simplified-operator.h"
|
||||||
@ -16,18 +15,15 @@ namespace v8 {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
class SimplifiedLowering : public LoweringBuilder {
|
class SimplifiedLowering : public Reducer {
|
||||||
public:
|
public:
|
||||||
explicit SimplifiedLowering(JSGraph* jsgraph,
|
explicit SimplifiedLowering(JSGraph* jsgraph)
|
||||||
SourcePositionTable* source_positions)
|
: jsgraph_(jsgraph), machine_(jsgraph->zone()) {}
|
||||||
: LoweringBuilder(jsgraph->graph(), source_positions),
|
|
||||||
jsgraph_(jsgraph),
|
|
||||||
machine_(jsgraph->zone()) {}
|
|
||||||
virtual ~SimplifiedLowering() {}
|
virtual ~SimplifiedLowering() {}
|
||||||
|
|
||||||
void LowerAllNodes();
|
void LowerAllNodes();
|
||||||
|
|
||||||
virtual void Lower(Node* node);
|
virtual Reduction Reduce(Node* node);
|
||||||
void LowerChange(Node* node, Node* effect, Node* control);
|
void LowerChange(Node* node, Node* effect, Node* control);
|
||||||
|
|
||||||
// TODO(titzer): These are exposed for direct testing. Use a friend class.
|
// TODO(titzer): These are exposed for direct testing. Use a friend class.
|
||||||
|
@ -30,13 +30,11 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
|
|||||||
explicit ChangesLoweringTester(MachineType p0 = kMachNone)
|
explicit ChangesLoweringTester(MachineType p0 = kMachNone)
|
||||||
: GraphBuilderTester<ReturnType>(p0),
|
: GraphBuilderTester<ReturnType>(p0),
|
||||||
typer(this->zone()),
|
typer(this->zone()),
|
||||||
source_positions(this->graph()),
|
|
||||||
jsgraph(this->graph(), this->common(), &typer),
|
jsgraph(this->graph(), this->common(), &typer),
|
||||||
lowering(&jsgraph, &source_positions),
|
lowering(&jsgraph),
|
||||||
function(Handle<JSFunction>::null()) {}
|
function(Handle<JSFunction>::null()) {}
|
||||||
|
|
||||||
Typer typer;
|
Typer typer;
|
||||||
SourcePositionTable source_positions;
|
|
||||||
JSGraph jsgraph;
|
JSGraph jsgraph;
|
||||||
SimplifiedLowering lowering;
|
SimplifiedLowering lowering;
|
||||||
Handle<JSFunction> function;
|
Handle<JSFunction> function;
|
||||||
|
@ -26,7 +26,6 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
|
|||||||
common(main_zone()),
|
common(main_zone()),
|
||||||
graph(main_zone()),
|
graph(main_zone()),
|
||||||
typer(main_zone()),
|
typer(main_zone()),
|
||||||
source_positions(&graph),
|
|
||||||
context_node(NULL) {
|
context_node(NULL) {
|
||||||
typer.DecorateGraph(&graph);
|
typer.DecorateGraph(&graph);
|
||||||
Node* s = graph.NewNode(common.Start(num_parameters));
|
Node* s = graph.NewNode(common.Start(num_parameters));
|
||||||
@ -42,7 +41,6 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
|
|||||||
CommonOperatorBuilder common;
|
CommonOperatorBuilder common;
|
||||||
Graph graph;
|
Graph graph;
|
||||||
Typer typer;
|
Typer typer;
|
||||||
SourcePositionTable source_positions;
|
|
||||||
Node* context_node;
|
Node* context_node;
|
||||||
|
|
||||||
Node* Parameter(Type* t, int32_t index = 0) {
|
Node* Parameter(Type* t, int32_t index = 0) {
|
||||||
@ -53,7 +51,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
|
|||||||
|
|
||||||
Node* reduce(Node* node) {
|
Node* reduce(Node* node) {
|
||||||
JSGraph jsgraph(&graph, &common, &typer);
|
JSGraph jsgraph(&graph, &common, &typer);
|
||||||
JSTypedLowering reducer(&jsgraph, &source_positions);
|
JSTypedLowering reducer(&jsgraph);
|
||||||
Reduction reduction = reducer.Reduce(node);
|
Reduction reduction = reducer.Reduce(node);
|
||||||
if (reduction.Changed()) return reduction.replacement();
|
if (reduction.Changed()) return reduction.replacement();
|
||||||
return node;
|
return node;
|
||||||
|
@ -36,12 +36,10 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
|
|||||||
MachineType p4 = kMachNone)
|
MachineType p4 = kMachNone)
|
||||||
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
|
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
|
||||||
typer(this->zone()),
|
typer(this->zone()),
|
||||||
source_positions(this->graph()),
|
|
||||||
jsgraph(this->graph(), this->common(), &typer),
|
jsgraph(this->graph(), this->common(), &typer),
|
||||||
lowering(&jsgraph, &source_positions) {}
|
lowering(&jsgraph) {}
|
||||||
|
|
||||||
Typer typer;
|
Typer typer;
|
||||||
SourcePositionTable source_positions;
|
|
||||||
JSGraph jsgraph;
|
JSGraph jsgraph;
|
||||||
SimplifiedLowering lowering;
|
SimplifiedLowering lowering;
|
||||||
|
|
||||||
@ -645,7 +643,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Lower() {
|
void Lower() {
|
||||||
SimplifiedLowering lowering(&jsgraph, NULL);
|
SimplifiedLowering lowering(&jsgraph);
|
||||||
lowering.LowerAllNodes();
|
lowering.LowerAllNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,8 +390,6 @@
|
|||||||
'../../src/compiler/linkage-impl.h',
|
'../../src/compiler/linkage-impl.h',
|
||||||
'../../src/compiler/linkage.cc',
|
'../../src/compiler/linkage.cc',
|
||||||
'../../src/compiler/linkage.h',
|
'../../src/compiler/linkage.h',
|
||||||
'../../src/compiler/lowering-builder.cc',
|
|
||||||
'../../src/compiler/lowering-builder.h',
|
|
||||||
'../../src/compiler/machine-node-factory.h',
|
'../../src/compiler/machine-node-factory.h',
|
||||||
'../../src/compiler/machine-operator-reducer.cc',
|
'../../src/compiler/machine-operator-reducer.cc',
|
||||||
'../../src/compiler/machine-operator-reducer.h',
|
'../../src/compiler/machine-operator-reducer.h',
|
||||||
|
Loading…
Reference in New Issue
Block a user