Avoid usage of temporary MachineOperatorBuilder.

R=titzer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23982 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cc66fb85
...@@ -1931,9 +1931,8 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value, ...@@ -1931,9 +1931,8 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
// TODO(sigurds) Use simplified load here once it is ready. // TODO(sigurds) Use simplified load here once it is ready.
MachineOperatorBuilder machine; Node* field_load = NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
Node* field_load = NewNode(machine.Load(kMachAnyTagged), object, jsgraph()->Int32Constant(offset - kHeapObjectTag));
jsgraph_->Int32Constant(offset - kHeapObjectTag));
return field_load; return field_load;
} }
......
...@@ -79,7 +79,7 @@ class ChangeLoweringTest : public GraphTest { ...@@ -79,7 +79,7 @@ class ChangeLoweringTest : public GraphTest {
JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine); JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine);
CompilationInfo info(isolate(), zone()); CompilationInfo info(isolate(), zone());
Linkage linkage(&info); Linkage linkage(&info);
ChangeLowering reducer(&jsgraph, &linkage, &machine); ChangeLowering reducer(&jsgraph, &linkage);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -246,6 +246,11 @@ CommonOperatorBuilder* ChangeLowering::common() const { ...@@ -246,6 +246,11 @@ CommonOperatorBuilder* ChangeLowering::common() const {
return jsgraph()->common(); return jsgraph()->common();
} }
MachineOperatorBuilder* ChangeLowering::machine() const {
return jsgraph()->machine();
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -19,9 +19,8 @@ class MachineOperatorBuilder; ...@@ -19,9 +19,8 @@ class MachineOperatorBuilder;
class ChangeLowering FINAL : public Reducer { class ChangeLowering FINAL : public Reducer {
public: public:
ChangeLowering(JSGraph* jsgraph, Linkage* linkage, ChangeLowering(JSGraph* jsgraph, Linkage* linkage)
MachineOperatorBuilder* machine) : jsgraph_(jsgraph), linkage_(linkage) {}
: jsgraph_(jsgraph), linkage_(linkage), machine_(machine) {}
virtual ~ChangeLowering(); virtual ~ChangeLowering();
virtual Reduction Reduce(Node* node) OVERRIDE; virtual Reduction Reduce(Node* node) OVERRIDE;
...@@ -50,11 +49,10 @@ class ChangeLowering FINAL : public Reducer { ...@@ -50,11 +49,10 @@ class ChangeLowering FINAL : public Reducer {
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
Linkage* linkage() const { return linkage_; } Linkage* linkage() const { return linkage_; }
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const { return machine_; } MachineOperatorBuilder* machine() const;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Linkage* linkage_; Linkage* linkage_;
MachineOperatorBuilder* machine_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -51,11 +51,10 @@ class JSTypedLowering FINAL : public Reducer { ...@@ -51,11 +51,10 @@ class JSTypedLowering FINAL : public Reducer {
JSOperatorBuilder* javascript() { return jsgraph_->javascript(); } JSOperatorBuilder* javascript() { return jsgraph_->javascript(); }
CommonOperatorBuilder* common() { return jsgraph_->common(); } CommonOperatorBuilder* common() { return jsgraph_->common(); }
SimplifiedOperatorBuilder* simplified() { return &simplified_; } SimplifiedOperatorBuilder* simplified() { return &simplified_; }
MachineOperatorBuilder* machine() { return &machine_; } MachineOperatorBuilder* machine() { return jsgraph_->machine(); }
JSGraph* jsgraph_; JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_; SimplifiedOperatorBuilder simplified_;
MachineOperatorBuilder machine_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -477,6 +477,11 @@ CommonOperatorBuilder* MachineOperatorReducer::common() const { ...@@ -477,6 +477,11 @@ CommonOperatorBuilder* MachineOperatorReducer::common() const {
} }
MachineOperatorBuilder* MachineOperatorReducer::machine() const {
return jsgraph()->machine();
}
Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
} // namespace compiler } // namespace compiler
......
...@@ -47,10 +47,9 @@ class MachineOperatorReducer FINAL : public Reducer { ...@@ -47,10 +47,9 @@ class MachineOperatorReducer FINAL : public Reducer {
Graph* graph() const; Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() { return &machine_; } MachineOperatorBuilder* machine() const;
JSGraph* jsgraph_; JSGraph* jsgraph_;
MachineOperatorBuilder machine_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -259,8 +259,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -259,8 +259,8 @@ Handle<Code> Pipeline::GenerateCode() {
SourcePosition::Unknown()); SourcePosition::Unknown());
Linkage linkage(info()); Linkage linkage(info());
ValueNumberingReducer vn_reducer(zone()); ValueNumberingReducer vn_reducer(zone());
SimplifiedOperatorReducer simple_reducer(&jsgraph, &machine); SimplifiedOperatorReducer simple_reducer(&jsgraph);
ChangeLowering lowering(&jsgraph, &linkage, &machine); ChangeLowering lowering(&jsgraph, &linkage);
MachineOperatorReducer mach_reducer(&jsgraph); MachineOperatorReducer mach_reducer(&jsgraph);
GraphReducer graph_reducer(&graph); GraphReducer graph_reducer(&graph);
// TODO(titzer): Figure out if we should run all reducers at once here. // TODO(titzer): Figure out if we should run all reducers at once here.
......
...@@ -21,10 +21,9 @@ namespace compiler { ...@@ -21,10 +21,9 @@ namespace compiler {
class RepresentationChanger { class RepresentationChanger {
public: public:
RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified, RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified,
MachineOperatorBuilder* machine, Isolate* isolate) Isolate* isolate)
: jsgraph_(jsgraph), : jsgraph_(jsgraph),
simplified_(simplified), simplified_(simplified),
machine_(machine),
isolate_(isolate), isolate_(isolate),
testing_type_errors_(false), testing_type_errors_(false),
type_error_(false) {} type_error_(false) {}
...@@ -309,7 +308,6 @@ class RepresentationChanger { ...@@ -309,7 +308,6 @@ class RepresentationChanger {
private: private:
JSGraph* jsgraph_; JSGraph* jsgraph_;
SimplifiedOperatorBuilder* simplified_; SimplifiedOperatorBuilder* simplified_;
MachineOperatorBuilder* machine_;
Isolate* isolate_; Isolate* isolate_;
friend class RepresentationChangerTester; // accesses the below fields. friend class RepresentationChangerTester; // accesses the below fields.
...@@ -339,7 +337,7 @@ class RepresentationChanger { ...@@ -339,7 +337,7 @@ class RepresentationChanger {
JSGraph* jsgraph() { return jsgraph_; } JSGraph* jsgraph() { return jsgraph_; }
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
SimplifiedOperatorBuilder* simplified() { return simplified_; } SimplifiedOperatorBuilder* simplified() { return simplified_; }
MachineOperatorBuilder* machine() { return machine_; } MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
}; };
} }
} }
......
...@@ -764,7 +764,7 @@ Node* SimplifiedLowering::IsTagged(Node* node) { ...@@ -764,7 +764,7 @@ Node* SimplifiedLowering::IsTagged(Node* node) {
void SimplifiedLowering::LowerAllNodes() { void SimplifiedLowering::LowerAllNodes() {
SimplifiedOperatorBuilder simplified(graph()->zone()); SimplifiedOperatorBuilder simplified(graph()->zone());
RepresentationChanger changer(jsgraph(), &simplified, machine(), RepresentationChanger changer(jsgraph(), &simplified,
graph()->zone()->isolate()); graph()->zone()->isolate());
RepresentationSelector selector(jsgraph(), zone(), &changer); RepresentationSelector selector(jsgraph(), zone(), &changer);
selector.Run(this); selector.Run(this);
...@@ -805,7 +805,7 @@ static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, ...@@ -805,7 +805,7 @@ static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
void SimplifiedLowering::DoLoadField(Node* node) { void SimplifiedLowering::DoLoadField(Node* node) {
const FieldAccess& access = FieldAccessOf(node->op()); const FieldAccess& access = FieldAccessOf(node->op());
node->set_op(machine_.Load(access.machine_type)); node->set_op(machine()->Load(access.machine_type));
Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
node->InsertInput(zone(), 1, offset); node->InsertInput(zone(), 1, offset);
} }
...@@ -815,7 +815,8 @@ void SimplifiedLowering::DoStoreField(Node* node) { ...@@ -815,7 +815,8 @@ void SimplifiedLowering::DoStoreField(Node* node) {
const FieldAccess& access = FieldAccessOf(node->op()); const FieldAccess& access = FieldAccessOf(node->op());
WriteBarrierKind kind = ComputeWriteBarrierKind( WriteBarrierKind kind = ComputeWriteBarrierKind(
access.base_is_tagged, access.machine_type, access.type); access.base_is_tagged, access.machine_type, access.type);
node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind))); node->set_op(
machine()->Store(StoreRepresentation(access.machine_type, kind)));
Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
node->InsertInput(zone(), 1, offset); node->InsertInput(zone(), 1, offset);
} }
...@@ -837,7 +838,7 @@ Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, ...@@ -837,7 +838,7 @@ Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access,
void SimplifiedLowering::DoLoadElement(Node* node) { void SimplifiedLowering::DoLoadElement(Node* node) {
const ElementAccess& access = ElementAccessOf(node->op()); const ElementAccess& access = ElementAccessOf(node->op());
node->set_op(machine_.Load(access.machine_type)); node->set_op(machine()->Load(access.machine_type));
node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
} }
...@@ -846,7 +847,8 @@ void SimplifiedLowering::DoStoreElement(Node* node) { ...@@ -846,7 +847,8 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
const ElementAccess& access = ElementAccessOf(node->op()); const ElementAccess& access = ElementAccessOf(node->op());
WriteBarrierKind kind = ComputeWriteBarrierKind( WriteBarrierKind kind = ComputeWriteBarrierKind(
access.base_is_tagged, access.machine_type, access.type); access.base_is_tagged, access.machine_type, access.type);
node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind))); node->set_op(
machine()->Store(StoreRepresentation(access.machine_type, kind)));
node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
} }
......
...@@ -33,7 +33,6 @@ class SimplifiedLowering { ...@@ -33,7 +33,6 @@ class SimplifiedLowering {
private: private:
JSGraph* jsgraph_; JSGraph* jsgraph_;
MachineOperatorBuilder machine_;
Node* SmiTag(Node* node); Node* SmiTag(Node* node);
Node* IsTagged(Node* node); Node* IsTagged(Node* node);
...@@ -48,7 +47,7 @@ class SimplifiedLowering { ...@@ -48,7 +47,7 @@ class SimplifiedLowering {
JSGraph* jsgraph() { return jsgraph_; } JSGraph* jsgraph() { return jsgraph_; }
Graph* graph() { return jsgraph()->graph(); } Graph* graph() { return jsgraph()->graph(); }
CommonOperatorBuilder* common() { return jsgraph()->common(); } CommonOperatorBuilder* common() { return jsgraph()->common(); }
MachineOperatorBuilder* machine() { return &machine_; } MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
}; };
} // namespace compiler } // namespace compiler
......
...@@ -25,7 +25,7 @@ class SimplifiedOperatorReducerTest : public GraphTest { ...@@ -25,7 +25,7 @@ class SimplifiedOperatorReducerTest : public GraphTest {
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine); JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine);
SimplifiedOperatorReducer reducer(&jsgraph, &machine); SimplifiedOperatorReducer reducer(&jsgraph);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -137,6 +137,11 @@ Factory* SimplifiedOperatorReducer::factory() const { ...@@ -137,6 +137,11 @@ Factory* SimplifiedOperatorReducer::factory() const {
return jsgraph()->isolate()->factory(); return jsgraph()->isolate()->factory();
} }
MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
return jsgraph()->machine();
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -21,8 +21,7 @@ class MachineOperatorBuilder; ...@@ -21,8 +21,7 @@ class MachineOperatorBuilder;
class SimplifiedOperatorReducer FINAL : public Reducer { class SimplifiedOperatorReducer FINAL : public Reducer {
public: public:
SimplifiedOperatorReducer(JSGraph* jsgraph, MachineOperatorBuilder* machine) explicit SimplifiedOperatorReducer(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
: jsgraph_(jsgraph), machine_(machine) {}
virtual ~SimplifiedOperatorReducer(); virtual ~SimplifiedOperatorReducer();
virtual Reduction Reduce(Node* node) OVERRIDE; virtual Reduction Reduce(Node* node) OVERRIDE;
...@@ -40,10 +39,9 @@ class SimplifiedOperatorReducer FINAL : public Reducer { ...@@ -40,10 +39,9 @@ class SimplifiedOperatorReducer FINAL : public Reducer {
Graph* graph() const; Graph* graph() const;
Factory* factory() const; Factory* factory() const;
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
MachineOperatorBuilder* machine() const { return machine_; } MachineOperatorBuilder* machine() const;
JSGraph* jsgraph_; JSGraph* jsgraph_;
MachineOperatorBuilder* machine_;
DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer); DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
}; };
......
...@@ -149,7 +149,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -149,7 +149,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
// Run the graph reducer with changes lowering on a single node. // Run the graph reducer with changes lowering on a single node.
CompilationInfo info(this->isolate(), this->zone()); CompilationInfo info(this->isolate(), this->zone());
Linkage linkage(&info); Linkage linkage(&info);
ChangeLowering lowering(&jsgraph, &linkage, this->machine()); ChangeLowering lowering(&jsgraph, &linkage);
GraphReducer reducer(this->graph()); GraphReducer reducer(this->graph());
reducer.AddReducer(&lowering); reducer.AddReducer(&lowering);
reducer.ReduceNode(change); reducer.ReduceNode(change);
......
...@@ -28,7 +28,7 @@ class RepresentationChangerTester : public HandleAndZoneScope, ...@@ -28,7 +28,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
javascript_(main_zone()), javascript_(main_zone()),
jsgraph_(main_graph_, &main_common_, &javascript_, &typer_, jsgraph_(main_graph_, &main_common_, &javascript_, &typer_,
&main_machine_), &main_machine_),
changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) { changer_(&jsgraph_, &main_simplified_, main_isolate()) {
Node* s = graph()->NewNode(common()->Start(num_parameters)); Node* s = graph()->NewNode(common()->Start(num_parameters));
graph()->SetStart(s); graph()->SetStart(s);
} }
......
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