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