Commit 8322577e authored by sigurds@chromium.org's avatar sigurds@chromium.org

Make start node a value input to parameter nodes.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22851 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c608c2f0
...@@ -33,7 +33,7 @@ Node* AstGraphBuilder::GetFunctionClosure() { ...@@ -33,7 +33,7 @@ Node* AstGraphBuilder::GetFunctionClosure() {
if (!function_closure_.is_set()) { if (!function_closure_.is_set()) {
// Parameter -1 is special for the function closure // Parameter -1 is special for the function closure
Operator* op = common()->Parameter(-1); Operator* op = common()->Parameter(-1);
Node* node = NewNode(op); Node* node = NewNode(op, graph()->start());
function_closure_.set(node); function_closure_.set(node);
} }
return function_closure_.get(); return function_closure_.get();
...@@ -44,7 +44,7 @@ Node* AstGraphBuilder::GetFunctionContext() { ...@@ -44,7 +44,7 @@ Node* AstGraphBuilder::GetFunctionContext() {
if (!function_context_.is_set()) { if (!function_context_.is_set()) {
// Parameter (arity + 1) is special for the outer context of the function // Parameter (arity + 1) is special for the outer context of the function
Operator* op = common()->Parameter(info()->num_parameters() + 1); Operator* op = common()->Parameter(info()->num_parameters() + 1);
Node* node = NewNode(op); Node* node = NewNode(op, graph()->start());
function_context_.set(node); function_context_.set(node);
} }
return function_context_.get(); return function_context_.get();
...@@ -60,7 +60,8 @@ bool AstGraphBuilder::CreateGraph() { ...@@ -60,7 +60,8 @@ bool AstGraphBuilder::CreateGraph() {
SourcePosition(info()->shared_info()->start_position())); SourcePosition(info()->shared_info()->start_position()));
// Set up the basic structure of the graph. // Set up the basic structure of the graph.
graph()->SetStart(graph()->NewNode(common()->Start())); graph()->SetStart(
graph()->NewNode(common()->Start(info()->num_parameters())));
// Initialize the top-level environment. // Initialize the top-level environment.
Environment env(this, scope, graph()->start()); Environment env(this, scope, graph()->start());
...@@ -177,13 +178,15 @@ AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder, ...@@ -177,13 +178,15 @@ AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder,
DCHECK_EQ(scope->num_parameters() + 1, parameters_count()); DCHECK_EQ(scope->num_parameters() + 1, parameters_count());
// Bind the receiver variable. // Bind the receiver variable.
Node* receiver = builder->graph()->NewNode(common()->Parameter(0)); Node* receiver = builder->graph()->NewNode(common()->Parameter(0),
builder->graph()->start());
values()->push_back(receiver); values()->push_back(receiver);
// Bind all parameter variables. The parameter indices are shifted by 1 // Bind all parameter variables. The parameter indices are shifted by 1
// (receiver is parameter index -1 but environment index 0). // (receiver is parameter index -1 but environment index 0).
for (int i = 0; i < scope->num_parameters(); ++i) { for (int i = 0; i < scope->num_parameters(); ++i) {
Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1)); Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1),
builder->graph()->start());
values()->push_back(parameter); values()->push_back(parameter);
} }
...@@ -1618,7 +1621,7 @@ Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) { ...@@ -1618,7 +1621,7 @@ Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) {
if (!variable->IsContextSlot()) continue; if (!variable->IsContextSlot()) continue;
// Temporary parameter node. The parameter indices are shifted by 1 // Temporary parameter node. The parameter indices are shifted by 1
// (receiver is parameter index -1 but environment index 0). // (receiver is parameter index -1 but environment index 0).
Node* parameter = NewNode(common()->Parameter(i + 1)); Node* parameter = NewNode(common()->Parameter(i + 1), graph()->start());
// Context variable (at bottom of the context chain). // Context variable (at bottom of the context chain).
DCHECK_EQ(0, info()->scope()->ContextChainLength(variable->scope())); DCHECK_EQ(0, info()->scope()->ContextChainLength(variable->scope()));
Operator* op = javascript()->StoreContext(0, variable->index()); Operator* op = javascript()->StoreContext(0, variable->index());
......
...@@ -65,7 +65,12 @@ class CommonOperatorBuilder { ...@@ -65,7 +65,12 @@ class CommonOperatorBuilder {
return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \
inputs, 0, controls, #name); inputs, 0, controls, #name);
Operator* Start() { CONTROL_OP(Start, 0, 0); } Operator* Start(int num_formal_parameters) {
// Outputs are formal parameters, plus context, receiver, and JSFunction.
int outputs = num_formal_parameters + 3;
return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0,
outputs, 0, "Start");
}
Operator* Dead() { CONTROL_OP(Dead, 0, 0); } Operator* Dead() { CONTROL_OP(Dead, 0, 0); }
Operator* End() { CONTROL_OP(End, 0, 1); } Operator* End() { CONTROL_OP(End, 0, 1); }
Operator* Branch() { CONTROL_OP(Branch, 1, 1); } Operator* Branch() { CONTROL_OP(Branch, 1, 1); }
...@@ -95,7 +100,7 @@ class CommonOperatorBuilder { ...@@ -95,7 +100,7 @@ class CommonOperatorBuilder {
} }
Operator* Parameter(int index) { Operator* Parameter(int index) {
return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 0, return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1,
1, "Parameter", index); 1, "Parameter", index);
} }
Operator* Int32Constant(int32_t value) { Operator* Int32Constant(int32_t value) {
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
// Opcodes for common operators. // Opcodes for common operators.
#define LEAF_OP_LIST(V) \ #define LEAF_OP_LIST(V) \
V(Parameter) \
V(Int32Constant) \ V(Int32Constant) \
V(Int64Constant) \ V(Int64Constant) \
V(Float64Constant) \ V(Float64Constant) \
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
V(EffectPhi) \ V(EffectPhi) \
V(FrameState) \ V(FrameState) \
V(Call) \ V(Call) \
V(Parameter) \
V(Projection) V(Projection)
#define COMMON_OP_LIST(V) \ #define COMMON_OP_LIST(V) \
......
...@@ -21,10 +21,12 @@ RawMachineAssembler::RawMachineAssembler( ...@@ -21,10 +21,12 @@ RawMachineAssembler::RawMachineAssembler(
parameters_(NULL), parameters_(NULL),
exit_label_(schedule()->exit()), exit_label_(schedule()->exit()),
current_block_(schedule()->entry()) { current_block_(schedule()->entry()) {
Node* s = graph->NewNode(common_.Start(parameter_count()));
graph->SetStart(s);
if (parameter_count() == 0) return; if (parameter_count() == 0) return;
parameters_ = zone()->NewArray<Node*>(parameter_count()); parameters_ = zone()->NewArray<Node*>(parameter_count());
for (int i = 0; i < parameter_count(); ++i) { for (int i = 0; i < parameter_count(); ++i) {
parameters_[i] = NewNode(common()->Parameter(i)); parameters_[i] = NewNode(common()->Parameter(i), graph->start());
} }
} }
......
...@@ -28,10 +28,12 @@ StructuredMachineAssembler::StructuredMachineAssembler( ...@@ -28,10 +28,12 @@ StructuredMachineAssembler::StructuredMachineAssembler(
current_environment_(new (zone()) current_environment_(new (zone())
Environment(zone(), schedule()->entry(), false)), Environment(zone(), schedule()->entry(), false)),
number_of_variables_(0) { number_of_variables_(0) {
Node* s = graph->NewNode(common_.Start(parameter_count()));
graph->SetStart(s);
if (parameter_count() == 0) return; if (parameter_count() == 0) return;
parameters_ = zone()->NewArray<Node*>(parameter_count()); parameters_ = zone()->NewArray<Node*>(parameter_count());
for (int i = 0; i < parameter_count(); ++i) { for (int i = 0; i < parameter_count(); ++i) {
parameters_[i] = NewNode(common()->Parameter(i)); parameters_[i] = NewNode(common()->Parameter(i), graph->start());
} }
} }
......
...@@ -102,7 +102,8 @@ GenericGraphVisit::Control Verifier::Visitor::Pre(Node* node) { ...@@ -102,7 +102,8 @@ GenericGraphVisit::Control Verifier::Visitor::Pre(Node* node) {
Node::Uses uses = node->uses(); Node::Uses uses = node->uses();
for (Node::Uses::iterator it = uses.begin(); it != uses.end(); ++it) { for (Node::Uses::iterator it = uses.begin(); it != uses.end(); ++it) {
CHECK(!NodeProperties::IsValueEdge(it.edge()) || CHECK(!NodeProperties::IsValueEdge(it.edge()) ||
(*it)->opcode() == IrOpcode::kProjection); (*it)->opcode() == IrOpcode::kProjection ||
(*it)->opcode() == IrOpcode::kParameter);
} }
} }
...@@ -148,10 +149,18 @@ GenericGraphVisit::Control Verifier::Visitor::Pre(Node* node) { ...@@ -148,10 +149,18 @@ GenericGraphVisit::Control Verifier::Visitor::Pre(Node* node) {
case IrOpcode::kThrow: case IrOpcode::kThrow:
// TODO(rossberg): what are the constraints on these? // TODO(rossberg): what are the constraints on these?
break; break;
case IrOpcode::kParameter: case IrOpcode::kParameter: {
// Parameters have no inputs. // Parameters have the start node as inputs.
CHECK_EQ(0, input_count); CHECK_EQ(1, input_count);
CHECK_EQ(IrOpcode::kStart,
NodeProperties::GetValueInput(node, 0)->opcode());
// Parameter has an input that produces enough values.
int index = static_cast<Operator1<int>*>(node->op())->parameter();
Node* input = NodeProperties::GetValueInput(node, 0);
// Currently, parameter indices start at -1 instead of 0.
CHECK_GT(NodeProperties::GetValueOutputCount(input), index + 1);
break; break;
}
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
case IrOpcode::kInt64Constant: case IrOpcode::kInt64Constant:
case IrOpcode::kFloat64Constant: case IrOpcode::kFloat64Constant:
......
...@@ -22,9 +22,9 @@ void MachineCallHelper::InitParameters(GraphBuilder* builder, ...@@ -22,9 +22,9 @@ void MachineCallHelper::InitParameters(GraphBuilder* builder,
DCHECK_EQ(NULL, parameters_); DCHECK_EQ(NULL, parameters_);
graph_ = builder->graph(); graph_ = builder->graph();
if (parameter_count() == 0) return; if (parameter_count() == 0) return;
parameters_ = builder->graph()->zone()->NewArray<Node*>(parameter_count()); parameters_ = graph_->zone()->NewArray<Node*>(parameter_count());
for (int i = 0; i < parameter_count(); ++i) { for (int i = 0; i < parameter_count(); ++i) {
parameters_[i] = builder->NewNode(common->Parameter(i)); parameters_[i] = builder->NewNode(common->Parameter(i), graph_->start());
} }
} }
......
...@@ -47,10 +47,12 @@ class MachineCallHelper : public CallHelper { ...@@ -47,10 +47,12 @@ class MachineCallHelper : public CallHelper {
MachineRepresentation* parameters); MachineRepresentation* parameters);
void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common); void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common);
private: protected:
int parameter_count() const { int parameter_count() const {
return call_descriptor_builder_->parameter_count(); return call_descriptor_builder_->parameter_count();
} }
private:
MachineCallDescriptorBuilder* call_descriptor_builder_; MachineCallDescriptorBuilder* call_descriptor_builder_;
Node** parameters_; Node** parameters_;
// TODO(dcarney): shouldn't need graph stored. // TODO(dcarney): shouldn't need graph stored.
...@@ -97,7 +99,7 @@ class GraphBuilderTester ...@@ -97,7 +99,7 @@ class GraphBuilderTester
p0, p1, p2, p3, p4)), p0, p1, p2, p3, p4)),
SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_, SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_,
&main_simplified_) { &main_simplified_) {
Begin(); Begin(parameter_count());
InitParameters(this, &main_common_); InitParameters(this, &main_common_);
} }
virtual ~GraphBuilderTester() {} virtual ~GraphBuilderTester() {}
......
...@@ -23,8 +23,9 @@ class GraphTester : public HandleAndZoneScope, public Graph { ...@@ -23,8 +23,9 @@ class GraphTester : public HandleAndZoneScope, public Graph {
class GraphWithStartNodeTester : public GraphTester { class GraphWithStartNodeTester : public GraphTester {
public: public:
GraphWithStartNodeTester() explicit GraphWithStartNodeTester(int num_parameters = 0)
: builder_(main_zone()), start_node_(NewNode(builder_.Start())) { : builder_(main_zone()),
start_node_(NewNode(builder_.Start(num_parameters))) {
SetStart(start_node_); SetStart(start_node_);
} }
......
...@@ -16,9 +16,9 @@ SimplifiedGraphBuilder::SimplifiedGraphBuilder( ...@@ -16,9 +16,9 @@ SimplifiedGraphBuilder::SimplifiedGraphBuilder(
simplified_(simplified) {} simplified_(simplified) {}
void SimplifiedGraphBuilder::Begin() { void SimplifiedGraphBuilder::Begin(int num_parameters) {
DCHECK(graph()->start() == NULL); DCHECK(graph()->start() == NULL);
Node* start = graph()->NewNode(common()->Start()); Node* start = graph()->NewNode(common()->Start(num_parameters));
graph()->SetStart(start); graph()->SetStart(start);
set_environment(new (zone()) Environment(this, start)); set_environment(new (zone()) Environment(this, start));
} }
......
...@@ -53,7 +53,7 @@ class SimplifiedGraphBuilder ...@@ -53,7 +53,7 @@ class SimplifiedGraphBuilder
} }
// Initialize graph and builder. // Initialize graph and builder.
void Begin(); void Begin(int num_parameters);
void Return(Node* value); void Return(Node* value);
......
...@@ -50,7 +50,7 @@ class ContextSpecializationTester ...@@ -50,7 +50,7 @@ class ContextSpecializationTester
TEST(ReduceJSLoadContext) { TEST(ReduceJSLoadContext) {
ContextSpecializationTester t; ContextSpecializationTester t;
Node* start = t.NewNode(t.common()->Start()); Node* start = t.NewNode(t.common()->Start(0));
t.graph()->SetStart(start); t.graph()->SetStart(start);
// Make a context and initialize it a bit for this test. // Make a context and initialize it a bit for this test.
...@@ -64,7 +64,7 @@ TEST(ReduceJSLoadContext) { ...@@ -64,7 +64,7 @@ TEST(ReduceJSLoadContext) {
native->set(slot, *expected); native->set(slot, *expected);
Node* const_context = t.jsgraph()->Constant(native); Node* const_context = t.jsgraph()->Constant(native);
Node* param_context = t.NewNode(t.common()->Parameter(0)); Node* param_context = t.NewNode(t.common()->Parameter(0), start);
JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
{ {
...@@ -145,7 +145,7 @@ static void CheckEffectInput(Node* effect, Node* use) { ...@@ -145,7 +145,7 @@ static void CheckEffectInput(Node* effect, Node* use) {
TEST(SpecializeToContext) { TEST(SpecializeToContext) {
ContextSpecializationTester t; ContextSpecializationTester t;
Node* start = t.NewNode(t.common()->Start()); Node* start = t.NewNode(t.common()->Start(0));
t.graph()->SetStart(start); t.graph()->SetStart(start);
// Make a context and initialize it a bit for this test. // Make a context and initialize it a bit for this test.
...@@ -156,13 +156,13 @@ TEST(SpecializeToContext) { ...@@ -156,13 +156,13 @@ TEST(SpecializeToContext) {
t.info()->SetContext(native); t.info()->SetContext(native);
Node* const_context = t.jsgraph()->Constant(native); Node* const_context = t.jsgraph()->Constant(native);
Node* param_context = t.NewNode(t.common()->Parameter(0)); Node* param_context = t.NewNode(t.common()->Parameter(0), start);
JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
{ {
// Check that SpecializeToContext() replaces values and forwards effects // Check that SpecializeToContext() replaces values and forwards effects
// correctly, and folds values from constant and non-constant contexts // correctly, and folds values from constant and non-constant contexts
Node* effect_in = t.NewNode(t.common()->Start()); Node* effect_in = t.NewNode(t.common()->Start(0));
Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
const_context, const_context, effect_in, start); const_context, const_context, effect_in, start);
......
...@@ -16,7 +16,7 @@ using namespace v8::internal::compiler; ...@@ -16,7 +16,7 @@ using namespace v8::internal::compiler;
class JSTypedLoweringTester : public HandleAndZoneScope { class JSTypedLoweringTester : public HandleAndZoneScope {
public: public:
JSTypedLoweringTester() explicit JSTypedLoweringTester(int num_parameters = 0)
: isolate(main_isolate()), : isolate(main_isolate()),
binop(NULL), binop(NULL),
unop(NULL), unop(NULL),
...@@ -29,6 +29,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -29,6 +29,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
source_positions(&graph), source_positions(&graph),
context_node(NULL) { context_node(NULL) {
typer.DecorateGraph(&graph); typer.DecorateGraph(&graph);
Node* s = graph.NewNode(common.Start(num_parameters));
graph.SetStart(s);
} }
Isolate* isolate; Isolate* isolate;
...@@ -44,7 +46,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -44,7 +46,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
Node* context_node; Node* context_node;
Node* Parameter(Type* t, int32_t index = 0) { Node* Parameter(Type* t, int32_t index = 0) {
Node* n = graph.NewNode(common.Parameter(index)); Node* n = graph.NewNode(common.Parameter(index), graph.start());
NodeProperties::SetBounds(n, Bounds(Type::None(), t)); NodeProperties::SetBounds(n, Bounds(Type::None(), t));
return n; return n;
} }
...@@ -57,18 +59,11 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -57,18 +59,11 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
return node; return node;
} }
Node* start() { Node* start() { return graph.start(); }
Node* s = graph.start();
if (s == NULL) {
s = graph.NewNode(common.Start());
graph.SetStart(s);
}
return s;
}
Node* context() { Node* context() {
if (context_node == NULL) { if (context_node == NULL) {
context_node = graph.NewNode(common.Parameter(-1)); context_node = graph.NewNode(common.Parameter(-1), graph.start());
} }
return context_node; return context_node;
} }
......
...@@ -30,14 +30,17 @@ Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, ...@@ -30,14 +30,17 @@ Operator* NewConstantOperator<double>(CommonOperatorBuilder* common,
class ReducerTester : public HandleAndZoneScope { class ReducerTester : public HandleAndZoneScope {
public: public:
ReducerTester() explicit ReducerTester(int num_parameters = 0)
: isolate(main_isolate()), : isolate(main_isolate()),
binop(NULL), binop(NULL),
unop(NULL), unop(NULL),
machine(main_zone()), machine(main_zone()),
common(main_zone()), common(main_zone()),
graph(main_zone()), graph(main_zone()),
maxuint32(Constant<int32_t>(kMaxUInt32)) {} maxuint32(Constant<int32_t>(kMaxUInt32)) {
Node* s = graph.NewNode(common.Start(num_parameters));
graph.SetStart(s);
}
Isolate* isolate; Isolate* isolate;
Operator* binop; Operator* binop;
...@@ -168,7 +171,7 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -168,7 +171,7 @@ class ReducerTester : public HandleAndZoneScope {
} }
Node* Parameter(int32_t index = 0) { Node* Parameter(int32_t index = 0) {
return graph.NewNode(common.Parameter(index)); return graph.NewNode(common.Parameter(index), graph.start());
} }
}; };
......
...@@ -14,12 +14,14 @@ using namespace v8::internal::compiler; ...@@ -14,12 +14,14 @@ using namespace v8::internal::compiler;
class PhiReducerTester : HandleAndZoneScope { class PhiReducerTester : HandleAndZoneScope {
public: public:
PhiReducerTester() explicit PhiReducerTester(int num_parameters = 0)
: isolate(main_isolate()), : isolate(main_isolate()),
common(main_zone()), common(main_zone()),
graph(main_zone()), graph(main_zone()),
self(graph.NewNode(common.Start())), self(graph.NewNode(common.Start(num_parameters))),
dead(graph.NewNode(common.Dead())) {} dead(graph.NewNode(common.Dead())) {
graph.SetStart(self);
}
Isolate* isolate; Isolate* isolate;
CommonOperatorBuilder common; CommonOperatorBuilder common;
...@@ -47,7 +49,7 @@ class PhiReducerTester : HandleAndZoneScope { ...@@ -47,7 +49,7 @@ class PhiReducerTester : HandleAndZoneScope {
} }
Node* Parameter(int32_t index = 0) { Node* Parameter(int32_t index = 0) {
return graph.NewNode(common.Parameter(index)); return graph.NewNode(common.Parameter(index), graph.start());
} }
Node* Phi(Node* a) { Node* Phi(Node* a) {
......
...@@ -22,11 +22,13 @@ namespace compiler { ...@@ -22,11 +22,13 @@ namespace compiler {
class RepresentationChangerTester : public HandleAndZoneScope, class RepresentationChangerTester : public HandleAndZoneScope,
public GraphAndBuilders { public GraphAndBuilders {
public: public:
RepresentationChangerTester() explicit RepresentationChangerTester(int num_parameters = 0)
: GraphAndBuilders(main_zone()), : GraphAndBuilders(main_zone()),
typer_(main_zone()), typer_(main_zone()),
jsgraph_(main_graph_, &main_common_, &typer_), jsgraph_(main_graph_, &main_common_, &typer_),
changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) { changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) {
Node* s = graph()->NewNode(common()->Start(num_parameters));
graph()->SetStart(s);
} }
Typer typer_; Typer typer_;
...@@ -60,7 +62,7 @@ class RepresentationChangerTester : public HandleAndZoneScope, ...@@ -60,7 +62,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
} }
Node* Parameter(int index = 0) { Node* Parameter(int index = 0) {
return graph()->NewNode(common()->Parameter(index)); return graph()->NewNode(common()->Parameter(index), graph()->start());
} }
void CheckTypeError(RepTypeUnion from, RepTypeUnion to) { void CheckTypeError(RepTypeUnion from, RepTypeUnion to) {
......
...@@ -147,10 +147,10 @@ TEST(BuildMulNodeGraph) { ...@@ -147,10 +147,10 @@ TEST(BuildMulNodeGraph) {
CommonOperatorBuilder common(scope.main_zone()); CommonOperatorBuilder common(scope.main_zone());
MachineOperatorBuilder machine(scope.main_zone(), kMachineWord32); MachineOperatorBuilder machine(scope.main_zone(), kMachineWord32);
Node* start = graph.NewNode(common.Start()); Node* start = graph.NewNode(common.Start(0));
graph.SetStart(start); graph.SetStart(start);
Node* param0 = graph.NewNode(common.Parameter(0)); Node* param0 = graph.NewNode(common.Parameter(0), graph.start());
Node* param1 = graph.NewNode(common.Parameter(1)); Node* param1 = graph.NewNode(common.Parameter(1), graph.start());
Node* mul = graph.NewNode(machine.Int32Mul(), param0, param1); Node* mul = graph.NewNode(machine.Int32Mul(), param0, param1);
Node* ret = graph.NewNode(common.Return(), mul, start); Node* ret = graph.NewNode(common.Return(), mul, start);
......
...@@ -605,7 +605,7 @@ TEST(BuildScheduleEmpty) { ...@@ -605,7 +605,7 @@ TEST(BuildScheduleEmpty) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder builder(scope.main_zone()); CommonOperatorBuilder builder(scope.main_zone());
graph.SetStart(graph.NewNode(builder.Start())); graph.SetStart(graph.NewNode(builder.Start(0)));
graph.SetEnd(graph.NewNode(builder.End(), graph.start())); graph.SetEnd(graph.NewNode(builder.End(), graph.start()));
Scheduler scheduler(scope.main_zone()); Scheduler scheduler(scope.main_zone());
...@@ -617,9 +617,9 @@ TEST(BuildScheduleOneParameter) { ...@@ -617,9 +617,9 @@ TEST(BuildScheduleOneParameter) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder builder(scope.main_zone()); CommonOperatorBuilder builder(scope.main_zone());
graph.SetStart(graph.NewNode(builder.Start())); graph.SetStart(graph.NewNode(builder.Start(0)));
Node* p1 = graph.NewNode(builder.Parameter(0)); Node* p1 = graph.NewNode(builder.Parameter(0), graph.start());
Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start()); Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start());
graph.SetEnd(graph.NewNode(builder.End(), ret)); graph.SetEnd(graph.NewNode(builder.End(), ret));
...@@ -664,13 +664,13 @@ TEST(BuildScheduleIfSplit) { ...@@ -664,13 +664,13 @@ TEST(BuildScheduleIfSplit) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder builder(scope.main_zone()); CommonOperatorBuilder builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
graph.SetStart(graph.NewNode(builder.Start())); graph.SetStart(graph.NewNode(builder.Start(3)));
Node* p1 = graph.NewNode(builder.Parameter(0)); Node* p1 = graph.NewNode(builder.Parameter(0), graph.start());
Node* p2 = graph.NewNode(builder.Parameter(1)); Node* p2 = graph.NewNode(builder.Parameter(1), graph.start());
Node* p3 = graph.NewNode(builder.Parameter(2)); Node* p3 = graph.NewNode(builder.Parameter(2), graph.start());
Node* p4 = graph.NewNode(builder.Parameter(3)); Node* p4 = graph.NewNode(builder.Parameter(3), graph.start());
Node* p5 = graph.NewNode(builder.Parameter(4)); Node* p5 = graph.NewNode(builder.Parameter(4), graph.start());
Node* cmp = graph.NewNode(js_builder.LessThanOrEqual(), p1, p2, p3, Node* cmp = graph.NewNode(js_builder.LessThanOrEqual(), p1, p2, p3,
graph.start(), graph.start()); graph.start(), graph.start());
Node* branch = graph.NewNode(builder.Branch(), cmp, graph.start()); Node* branch = graph.NewNode(builder.Branch(), cmp, graph.start());
...@@ -715,6 +715,9 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -715,6 +715,9 @@ TEST(BuildScheduleIfSplitWithEffects) {
// return c * c - a; // return c * c - a;
// } // }
// } // }
op = common_builder.Start(0);
Node* n0 = graph.NewNode(op);
USE(n0);
Node* nil = graph.NewNode(common_builder.Dead()); Node* nil = graph.NewNode(common_builder.Dead());
op = common_builder.End(); op = common_builder.End();
Node* n23 = graph.NewNode(op, nil); Node* n23 = graph.NewNode(op, nil);
...@@ -738,11 +741,11 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -738,11 +741,11 @@ TEST(BuildScheduleIfSplitWithEffects) {
Node* n11 = graph.NewNode(op, nil, nil, nil, nil, nil); Node* n11 = graph.NewNode(op, nil, nil, nil, nil, nil);
USE(n11); USE(n11);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n2 = graph.NewNode(op); Node* n2 = graph.NewNode(op, n0);
USE(n2); USE(n2);
n11->ReplaceInput(0, n2); n11->ReplaceInput(0, n2);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n3 = graph.NewNode(op); Node* n3 = graph.NewNode(op, n0);
USE(n3); USE(n3);
n11->ReplaceInput(1, n3); n11->ReplaceInput(1, n3);
op = common_builder.HeapConstant(unique_constant); op = common_builder.HeapConstant(unique_constant);
...@@ -755,9 +758,6 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -755,9 +758,6 @@ TEST(BuildScheduleIfSplitWithEffects) {
n8->ReplaceInput(0, n2); n8->ReplaceInput(0, n2);
n8->ReplaceInput(1, n3); n8->ReplaceInput(1, n3);
n8->ReplaceInput(2, n7); n8->ReplaceInput(2, n7);
op = common_builder.Start();
Node* n0 = graph.NewNode(op);
USE(n0);
n8->ReplaceInput(3, n0); n8->ReplaceInput(3, n0);
n8->ReplaceInput(4, n0); n8->ReplaceInput(4, n0);
n11->ReplaceInput(3, n8); n11->ReplaceInput(3, n8);
...@@ -776,7 +776,7 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -776,7 +776,7 @@ TEST(BuildScheduleIfSplitWithEffects) {
Node* n12 = graph.NewNode(op, nil, nil, nil, nil, nil); Node* n12 = graph.NewNode(op, nil, nil, nil, nil, nil);
USE(n12); USE(n12);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n4 = graph.NewNode(op); Node* n4 = graph.NewNode(op, n0);
USE(n4); USE(n4);
n12->ReplaceInput(0, n4); n12->ReplaceInput(0, n4);
n12->ReplaceInput(1, n4); n12->ReplaceInput(1, n4);
...@@ -794,7 +794,7 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -794,7 +794,7 @@ TEST(BuildScheduleIfSplitWithEffects) {
n14->ReplaceInput(4, n10); n14->ReplaceInput(4, n10);
n15->ReplaceInput(0, n14); n15->ReplaceInput(0, n14);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n5 = graph.NewNode(op); Node* n5 = graph.NewNode(op, n0);
USE(n5); USE(n5);
n15->ReplaceInput(1, n5); n15->ReplaceInput(1, n5);
n15->ReplaceInput(2, n7); n15->ReplaceInput(2, n7);
...@@ -867,6 +867,9 @@ TEST(BuildScheduleSimpleLoop) { ...@@ -867,6 +867,9 @@ TEST(BuildScheduleSimpleLoop) {
// } // }
// return a; // return a;
// } // }
op = common_builder.Start(0);
Node* n0 = graph.NewNode(op);
USE(n0);
Node* nil = graph.NewNode(common_builder.Dead()); Node* nil = graph.NewNode(common_builder.Dead());
op = common_builder.End(); op = common_builder.End();
Node* n20 = graph.NewNode(op, nil); Node* n20 = graph.NewNode(op, nil);
...@@ -878,7 +881,7 @@ TEST(BuildScheduleSimpleLoop) { ...@@ -878,7 +881,7 @@ TEST(BuildScheduleSimpleLoop) {
Node* n8 = graph.NewNode(op, nil, nil, nil); Node* n8 = graph.NewNode(op, nil, nil, nil);
USE(n8); USE(n8);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n2 = graph.NewNode(op); Node* n2 = graph.NewNode(op, n0);
USE(n2); USE(n2);
n8->ReplaceInput(0, n2); n8->ReplaceInput(0, n2);
op = js_builder.Add(); op = js_builder.Add();
...@@ -900,16 +903,13 @@ TEST(BuildScheduleSimpleLoop) { ...@@ -900,16 +903,13 @@ TEST(BuildScheduleSimpleLoop) {
Node* n9 = graph.NewNode(op, nil, nil, nil); Node* n9 = graph.NewNode(op, nil, nil, nil);
USE(n9); USE(n9);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n3 = graph.NewNode(op); Node* n3 = graph.NewNode(op, n0);
USE(n3); USE(n3);
n9->ReplaceInput(0, n3); n9->ReplaceInput(0, n3);
n9->ReplaceInput(1, n9); n9->ReplaceInput(1, n9);
op = common_builder.Loop(2); op = common_builder.Loop(2);
Node* n6 = graph.NewNode(op, nil, nil); Node* n6 = graph.NewNode(op, nil, nil);
USE(n6); USE(n6);
op = common_builder.Start();
Node* n0 = graph.NewNode(op);
USE(n0);
n6->ReplaceInput(0, n0); n6->ReplaceInput(0, n0);
op = common_builder.IfTrue(); op = common_builder.IfTrue();
Node* n14 = graph.NewNode(op, nil); Node* n14 = graph.NewNode(op, nil);
...@@ -993,6 +993,9 @@ TEST(BuildScheduleComplexLoops) { ...@@ -993,6 +993,9 @@ TEST(BuildScheduleComplexLoops) {
// } // }
// return a; // return a;
// } // }
op = common_builder.Start(0);
Node* n0 = graph.NewNode(op);
USE(n0);
Node* nil = graph.NewNode(common_builder.Dead()); Node* nil = graph.NewNode(common_builder.Dead());
op = common_builder.End(); op = common_builder.End();
Node* n46 = graph.NewNode(op, nil); Node* n46 = graph.NewNode(op, nil);
...@@ -1007,7 +1010,7 @@ TEST(BuildScheduleComplexLoops) { ...@@ -1007,7 +1010,7 @@ TEST(BuildScheduleComplexLoops) {
Node* n9 = graph.NewNode(op, nil, nil, nil); Node* n9 = graph.NewNode(op, nil, nil, nil);
USE(n9); USE(n9);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n2 = graph.NewNode(op); Node* n2 = graph.NewNode(op, n0);
USE(n2); USE(n2);
n9->ReplaceInput(0, n2); n9->ReplaceInput(0, n2);
op = common_builder.Phi(2); op = common_builder.Phi(2);
...@@ -1032,7 +1035,7 @@ TEST(BuildScheduleComplexLoops) { ...@@ -1032,7 +1035,7 @@ TEST(BuildScheduleComplexLoops) {
Node* n10 = graph.NewNode(op, nil, nil, nil); Node* n10 = graph.NewNode(op, nil, nil, nil);
USE(n10); USE(n10);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n3 = graph.NewNode(op); Node* n3 = graph.NewNode(op, n0);
USE(n3); USE(n3);
n10->ReplaceInput(0, n3); n10->ReplaceInput(0, n3);
op = common_builder.Phi(2); op = common_builder.Phi(2);
...@@ -1053,9 +1056,6 @@ TEST(BuildScheduleComplexLoops) { ...@@ -1053,9 +1056,6 @@ TEST(BuildScheduleComplexLoops) {
op = common_builder.Loop(2); op = common_builder.Loop(2);
Node* n7 = graph.NewNode(op, nil, nil); Node* n7 = graph.NewNode(op, nil, nil);
USE(n7); USE(n7);
op = common_builder.Start();
Node* n0 = graph.NewNode(op);
USE(n0);
n7->ReplaceInput(0, n0); n7->ReplaceInput(0, n0);
op = common_builder.IfFalse(); op = common_builder.IfFalse();
Node* n30 = graph.NewNode(op, nil); Node* n30 = graph.NewNode(op, nil);
...@@ -1073,7 +1073,7 @@ TEST(BuildScheduleComplexLoops) { ...@@ -1073,7 +1073,7 @@ TEST(BuildScheduleComplexLoops) {
Node* n11 = graph.NewNode(op, nil, nil, nil); Node* n11 = graph.NewNode(op, nil, nil, nil);
USE(n11); USE(n11);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n4 = graph.NewNode(op); Node* n4 = graph.NewNode(op, n0);
USE(n4); USE(n4);
n11->ReplaceInput(0, n4); n11->ReplaceInput(0, n4);
n11->ReplaceInput(1, n25); n11->ReplaceInput(1, n25);
...@@ -1250,6 +1250,9 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1250,6 +1250,9 @@ TEST(BuildScheduleBreakAndContinue) {
// } // }
// return a + d; // return a + d;
// } // }
op = common_builder.Start(0);
Node* n0 = graph.NewNode(op);
USE(n0);
Node* nil = graph.NewNode(common_builder.Dead()); Node* nil = graph.NewNode(common_builder.Dead());
op = common_builder.End(); op = common_builder.End();
Node* n58 = graph.NewNode(op, nil); Node* n58 = graph.NewNode(op, nil);
...@@ -1264,7 +1267,7 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1264,7 +1267,7 @@ TEST(BuildScheduleBreakAndContinue) {
Node* n10 = graph.NewNode(op, nil, nil, nil); Node* n10 = graph.NewNode(op, nil, nil, nil);
USE(n10); USE(n10);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n2 = graph.NewNode(op); Node* n2 = graph.NewNode(op, n0);
USE(n2); USE(n2);
n10->ReplaceInput(0, n2); n10->ReplaceInput(0, n2);
op = common_builder.Phi(2); op = common_builder.Phi(2);
...@@ -1289,7 +1292,7 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1289,7 +1292,7 @@ TEST(BuildScheduleBreakAndContinue) {
Node* n11 = graph.NewNode(op, nil, nil, nil); Node* n11 = graph.NewNode(op, nil, nil, nil);
USE(n11); USE(n11);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n3 = graph.NewNode(op); Node* n3 = graph.NewNode(op, n0);
USE(n3); USE(n3);
n11->ReplaceInput(0, n3); n11->ReplaceInput(0, n3);
op = common_builder.Phi(2); op = common_builder.Phi(2);
...@@ -1310,9 +1313,6 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1310,9 +1313,6 @@ TEST(BuildScheduleBreakAndContinue) {
op = common_builder.Loop(2); op = common_builder.Loop(2);
Node* n8 = graph.NewNode(op, nil, nil); Node* n8 = graph.NewNode(op, nil, nil);
USE(n8); USE(n8);
op = common_builder.Start();
Node* n0 = graph.NewNode(op);
USE(n0);
n8->ReplaceInput(0, n0); n8->ReplaceInput(0, n0);
op = common_builder.Merge(2); op = common_builder.Merge(2);
Node* n53 = graph.NewNode(op, nil, nil); Node* n53 = graph.NewNode(op, nil, nil);
...@@ -1345,7 +1345,7 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1345,7 +1345,7 @@ TEST(BuildScheduleBreakAndContinue) {
Node* n12 = graph.NewNode(op, nil, nil, nil); Node* n12 = graph.NewNode(op, nil, nil, nil);
USE(n12); USE(n12);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n4 = graph.NewNode(op); Node* n4 = graph.NewNode(op, n0);
USE(n4); USE(n4);
n12->ReplaceInput(0, n4); n12->ReplaceInput(0, n4);
op = common_builder.Phi(2); op = common_builder.Phi(2);
...@@ -1580,6 +1580,9 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1580,6 +1580,9 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
// } // }
// return a; // return a;
// } // }
op = common_builder.Start(0);
Node* n0 = graph.NewNode(op);
USE(n0);
Node* nil = graph.NewNode(common_builder.Dead()); Node* nil = graph.NewNode(common_builder.Dead());
op = common_builder.End(); op = common_builder.End();
Node* n22 = graph.NewNode(op, nil); Node* n22 = graph.NewNode(op, nil);
...@@ -1591,7 +1594,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1591,7 +1594,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
Node* n9 = graph.NewNode(op, nil, nil, nil); Node* n9 = graph.NewNode(op, nil, nil, nil);
USE(n9); USE(n9);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n2 = graph.NewNode(op); Node* n2 = graph.NewNode(op, n0);
USE(n2); USE(n2);
n9->ReplaceInput(0, n2); n9->ReplaceInput(0, n2);
op = js_builder.Add(); op = js_builder.Add();
...@@ -1605,16 +1608,13 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1605,16 +1608,13 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
Node* n10 = graph.NewNode(op, nil, nil, nil); Node* n10 = graph.NewNode(op, nil, nil, nil);
USE(n10); USE(n10);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n3 = graph.NewNode(op); Node* n3 = graph.NewNode(op, n0);
USE(n3); USE(n3);
n10->ReplaceInput(0, n3); n10->ReplaceInput(0, n3);
n10->ReplaceInput(1, n10); n10->ReplaceInput(1, n10);
op = common_builder.Loop(2); op = common_builder.Loop(2);
Node* n7 = graph.NewNode(op, nil, nil); Node* n7 = graph.NewNode(op, nil, nil);
USE(n7); USE(n7);
op = common_builder.Start();
Node* n0 = graph.NewNode(op);
USE(n0);
n7->ReplaceInput(0, n0); n7->ReplaceInput(0, n0);
op = common_builder.IfTrue(); op = common_builder.IfTrue();
Node* n17 = graph.NewNode(op, nil); Node* n17 = graph.NewNode(op, nil);
...@@ -1656,7 +1656,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1656,7 +1656,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
Node* n11 = graph.NewNode(op, nil, nil, nil); Node* n11 = graph.NewNode(op, nil, nil, nil);
USE(n11); USE(n11);
op = common_builder.Parameter(0); op = common_builder.Parameter(0);
Node* n4 = graph.NewNode(op); Node* n4 = graph.NewNode(op, n0);
USE(n4); USE(n4);
n11->ReplaceInput(0, n4); n11->ReplaceInput(0, n4);
n11->ReplaceInput(1, n11); n11->ReplaceInput(1, n11);
......
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