Commit dbae315a authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Remove locally constructed simplified builders.

This removes all locally constructed SimplifiedOperatorBuilder instances
and uses the one passed along the JSGraph. It ensures that the correct
zone is used to allocate operators, no matter where the reducer is used.

R=bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31355}
parent 66ca9c83
......@@ -7,6 +7,7 @@
#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/objects-inl.h"
#include "src/types.h"
......@@ -87,9 +88,7 @@ class JSCallReduction {
JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
simplified_(jsgraph->zone()) {}
: AdvancedReducer(editor), jsgraph_(jsgraph) {}
// ECMA-262, section 15.8.2.11.
......@@ -184,6 +183,11 @@ MachineOperatorBuilder* JSBuiltinReducer::machine() const {
return jsgraph()->machine();
}
SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
return jsgraph()->simplified();
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -6,7 +6,6 @@
#define V8_COMPILER_JS_BUILTIN_REDUCER_H_
#include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -16,6 +15,7 @@ namespace compiler {
class CommonOperatorBuilder;
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
class JSBuiltinReducer final : public AdvancedReducer {
......@@ -34,10 +34,9 @@ class JSBuiltinReducer final : public AdvancedReducer {
Graph* graph() const;
CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SimplifiedOperatorBuilder* simplified() const;
JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_;
};
} // namespace compiler
......
......@@ -20,10 +20,7 @@ namespace compiler {
JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph,
DeoptimizationMode mode)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
mode_(mode),
simplified_(jsgraph->zone()) {}
: AdvancedReducer(editor), jsgraph_(jsgraph), mode_(mode) {}
Reduction JSIntrinsicLowering::Reduce(Node* node) {
......@@ -608,6 +605,11 @@ MachineOperatorBuilder* JSIntrinsicLowering::machine() const {
return jsgraph()->machine();
}
SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
return jsgraph()->simplified();
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -7,7 +7,6 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -18,6 +17,7 @@ class CommonOperatorBuilder;
class JSOperatorBuilder;
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
// Lowers certain JS-level runtime calls.
......@@ -72,12 +72,11 @@ class JSIntrinsicLowering final : public AdvancedReducer {
CommonOperatorBuilder* common() const;
JSOperatorBuilder* javascript() const;
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() const;
DeoptimizationMode mode() const { return mode_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
JSGraph* const jsgraph_;
DeoptimizationMode const mode_;
SimplifiedOperatorBuilder simplified_;
};
} // namespace compiler
......
......@@ -16,10 +16,7 @@ namespace compiler {
JSTypeFeedbackLowering::JSTypeFeedbackLowering(Editor* editor, Flags flags,
JSGraph* jsgraph)
: AdvancedReducer(editor),
flags_(flags),
jsgraph_(jsgraph),
simplified_(graph()->zone()) {}
: AdvancedReducer(editor), flags_(flags), jsgraph_(jsgraph) {}
Reduction JSTypeFeedbackLowering::Reduce(Node* node) {
......@@ -114,6 +111,11 @@ MachineOperatorBuilder* JSTypeFeedbackLowering::machine() const {
return jsgraph()->machine();
}
SimplifiedOperatorBuilder* JSTypeFeedbackLowering::simplified() const {
return jsgraph()->simplified();
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -7,7 +7,6 @@
#include "src/base/flags.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -21,6 +20,7 @@ namespace compiler {
class CommonOperatorBuilder;
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
// Lowers JS-level operators to simplified operators based on type feedback.
......@@ -48,11 +48,10 @@ class JSTypeFeedbackLowering final : public AdvancedReducer {
JSGraph* jsgraph() const { return jsgraph_; }
CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SimplifiedOperatorBuilder* simplified() const;
Flags const flags_;
JSGraph* const jsgraph_;
SimplifiedOperatorBuilder simplified_;
DISALLOW_COPY_AND_ASSIGN(JSTypeFeedbackLowering);
};
......
......@@ -10,7 +10,6 @@
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-aux-data.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -70,7 +69,6 @@ class JSTypeFeedbackSpecializer : public AdvancedReducer {
CompilationDependencies* dependencies)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
simplified_(jsgraph->graph()->zone()),
js_type_feedback_(js_type_feedback),
oracle_(oracle),
global_object_(global_object),
......@@ -90,7 +88,6 @@ class JSTypeFeedbackSpecializer : public AdvancedReducer {
private:
JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_;
JSTypeFeedbackTable* js_type_feedback_;
TypeFeedbackOracle* oracle_;
Handle<GlobalObject> global_object_;
......@@ -101,8 +98,8 @@ class JSTypeFeedbackSpecializer : public AdvancedReducer {
Graph* graph() { return jsgraph_->graph(); }
JSGraph* jsgraph() { return jsgraph_; }
CommonOperatorBuilder* common() { return jsgraph_->common(); }
SimplifiedOperatorBuilder* simplified() { return jsgraph_->simplified(); }
DeoptimizationMode mode() const { return mode_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
void BuildMapCheck(Node* receiver, Handle<Map> map, bool smi_check,
Node* effect, Node* control, Node** success, Node** fail);
......
......@@ -22,7 +22,7 @@ namespace compiler {
JSTypedLowering::JSTypedLowering(Editor* editor, JSGraph* jsgraph, Zone* zone)
: AdvancedReducer(editor), jsgraph_(jsgraph), simplified_(graph()->zone()) {
: AdvancedReducer(editor), jsgraph_(jsgraph) {
for (size_t k = 0; k < arraysize(shifted_int32_ranges_); ++k) {
double min = kMinInt / (1 << k);
double max = kMaxInt / (1 << k);
......@@ -1836,6 +1836,11 @@ CommonOperatorBuilder* JSTypedLowering::common() const {
}
SimplifiedOperatorBuilder* JSTypedLowering::simplified() const {
return jsgraph()->simplified();
}
MachineOperatorBuilder* JSTypedLowering::machine() const {
return jsgraph()->machine();
}
......
......@@ -7,7 +7,6 @@
#include "src/compiler/graph-reducer.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -23,6 +22,7 @@ class CommonOperatorBuilder;
class JSGraph;
class JSOperatorBuilder;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
// Lowers JS-level operators to simplified operators based on types.
......@@ -81,7 +81,7 @@ class JSTypedLowering final : public AdvancedReducer {
Isolate* isolate() const;
JSOperatorBuilder* javascript() const;
CommonOperatorBuilder* common() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SimplifiedOperatorBuilder* simplified() const;
MachineOperatorBuilder* machine() const;
// Limits up to which context allocations are inlined.
......@@ -89,7 +89,6 @@ class JSTypedLowering final : public AdvancedReducer {
static const int kBlockContextAllocationLimit = 16;
JSGraph* jsgraph_;
SimplifiedOperatorBuilder simplified_;
Type* shifted_int32_ranges_[4];
};
......
......@@ -1163,8 +1163,8 @@ SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
void SimplifiedLowering::LowerAllNodes() {
SimplifiedOperatorBuilder simplified(graph()->zone());
RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate());
RepresentationChanger changer(jsgraph(), jsgraph()->simplified(),
jsgraph()->isolate());
RepresentationSelector selector(jsgraph(), zone_, &changer,
source_positions_);
selector.Run(this);
......
......@@ -15,7 +15,7 @@ namespace internal {
namespace compiler {
SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph)
: jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
: jsgraph_(jsgraph) {}
SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
......
......@@ -6,7 +6,6 @@
#define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
#include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 {
namespace internal {
......@@ -15,6 +14,7 @@ namespace compiler {
// Forward declarations.
class JSGraph;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
class SimplifiedOperatorReducer final : public Reducer {
......@@ -37,10 +37,9 @@ class SimplifiedOperatorReducer final : public Reducer {
Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; }
MachineOperatorBuilder* machine() const;
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SimplifiedOperatorBuilder* simplified() const;
JSGraph* const jsgraph_;
SimplifiedOperatorBuilder simplified_;
DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
};
......
......@@ -8,6 +8,7 @@
#include "src/compiler/node-properties.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/typer.h"
#include "test/cctest/cctest.h"
......
......@@ -38,7 +38,7 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
typer(this->isolate(), this->graph()),
javascript(this->zone()),
jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
nullptr, this->machine()),
this->simplified(), this->machine()),
source_positions(jsgraph.graph()),
lowering(&jsgraph, this->zone(), &source_positions) {}
......@@ -676,7 +676,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
: GraphAndBuilders(main_zone()),
typer(main_isolate(), graph()),
javascript(main_zone()),
jsgraph(main_isolate(), graph(), common(), &javascript, nullptr,
jsgraph(main_isolate(), graph(), common(), &javascript, simplified(),
machine()) {
start = graph()->NewNode(common()->Start(2));
graph()->SetStart(start);
......
......@@ -5,6 +5,7 @@
#include "src/compiler/js-builtin-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/typer.h"
#include "src/isolate-inl.h"
#include "test/unittests/compiler/graph-unittest.h"
......@@ -26,7 +27,8 @@ class JSBuiltinReducerTest : public TypedGraphTest {
Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::Flag::kNoFlags) {
MachineOperatorBuilder machine(zone(), kMachPtr, flags);
JSGraph jsgraph(isolate(), graph(), common(), javascript(), nullptr,
SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine);
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
......
......@@ -32,7 +32,8 @@ class JSIntrinsicLoweringTest : public GraphTest {
Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::kNoFlags) {
MachineOperatorBuilder machine(zone(), kMachPtr, flags);
JSGraph jsgraph(isolate(), graph(), common(), javascript(), nullptr,
SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine);
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
......
......@@ -40,7 +40,8 @@ class JSTypeFeedbackTest : public TypedGraphTest {
isolate()->native_context()->global_object(), isolate());
MachineOperatorBuilder machine(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), nullptr,
SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine);
JSTypeFeedbackTable table(zone());
// TODO(titzer): mock the GraphReducer here for better unit testing.
......
......@@ -80,7 +80,8 @@ class JSTypedLoweringTest : public TypedGraphTest {
protected:
Reduction Reduce(Node* node) {
MachineOperatorBuilder machine(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), nullptr,
SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine);
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
......
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