Commit 870ce53a authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Fix value output count for the Start node.

The value output count for Start is currently off by 1 for code stubs,
because the CommonOperatorBuilder hardcodes the receiver parameter.

R=mstarzinger@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29490}
parent e595f33f
......@@ -502,9 +502,10 @@ bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
Scope* scope = info()->scope();
DCHECK(graph() != NULL);
// Set up the basic structure of the graph.
int parameter_count = info()->num_parameters();
graph()->SetStart(graph()->NewNode(common()->Start(parameter_count)));
// Set up the basic structure of the graph. Outputs for {Start} are the formal
// parameters (including the receiver) plus context and closure.
int actual_parameter_count = info()->num_parameters_including_this() + 2;
graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count)));
// Initialize the top-level environment.
Environment env(this, scope, graph()->start());
......
......@@ -441,9 +441,7 @@ const Operator* CommonOperatorBuilder::IfValue(int32_t index) {
}
const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) {
// Outputs are formal parameters, plus context, receiver, and JSFunction.
const int value_output_count = num_formal_parameters + 3;
const Operator* CommonOperatorBuilder::Start(int value_output_count) {
return new (zone()) Operator( // --
IrOpcode::kStart, Operator::kFoldable, // opcode
"Start", // name
......
......@@ -124,7 +124,7 @@ class CommonOperatorBuilder final : public ZoneObject {
const Operator* Return();
const Operator* Terminate();
const Operator* Start(int num_formal_parameters);
const Operator* Start(int value_output_count);
const Operator* Loop(int control_input_count);
const Operator* Merge(int control_input_count);
const Operator* Parameter(int index, const char* debug_name = nullptr);
......
......@@ -318,13 +318,13 @@ void Verifier::Visitor::Check(Node* node) {
case IrOpcode::kParameter: {
// Parameters have the start node as inputs.
CHECK_EQ(1, input_count);
CHECK_EQ(IrOpcode::kStart,
NodeProperties::GetValueInput(node, 0)->opcode());
// Parameter has an input that produces enough values.
int index = OpParameter<int>(node);
Node* input = NodeProperties::GetValueInput(node, 0);
int const index = ParameterIndexOf(node->op());
Node* const start = NodeProperties::GetValueInput(node, 0);
CHECK_EQ(IrOpcode::kStart, start->opcode());
// Currently, parameter indices start at -1 instead of 0.
CHECK_GT(input->op()->ValueOutputCount(), index + 1);
CHECK_LE(-1, index);
CHECK_LT(index + 1, start->op()->ValueOutputCount());
// Type can be anything.
CheckUpperIs(node, Type::Any());
break;
......
......@@ -23,7 +23,7 @@ SimplifiedGraphBuilder::SimplifiedGraphBuilder(
void SimplifiedGraphBuilder::Begin(int num_parameters) {
DCHECK(graph()->start() == NULL);
Node* start = graph()->NewNode(common()->Start(num_parameters));
Node* start = graph()->NewNode(common()->Start(num_parameters + 3));
graph()->SetStart(start);
effect_ = start;
}
......
......@@ -40,7 +40,7 @@ TEST(RunMathFloorStub) {
JSGraph js(isolate, &graph, &common, &javascript, &machine);
// FunctionTester (ab)uses a 2-argument function
Node* start = graph.NewNode(common.Start(2));
Node* start = graph.NewNode(common.Start(4));
// Parameter 0 is the number to round
Node* numberParam = graph.NewNode(common.Parameter(1), start);
Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
......@@ -76,7 +76,7 @@ TEST(RunStringLengthTFStub) {
Graph graph(zone);
CommonOperatorBuilder common(zone);
// FunctionTester (ab)uses a 4-argument function
Node* start = graph.NewNode(common.Start(4));
Node* start = graph.NewNode(common.Start(6));
// Parameter 0 is the receiver
Node* receiverParam = graph.NewNode(common.Parameter(1), start);
Node* nameParam = graph.NewNode(common.Parameter(2), start);
......@@ -122,7 +122,7 @@ TEST(RunStringAddTFStub) {
Graph graph(zone);
CommonOperatorBuilder common(zone);
// FunctionTester (ab)uses a 2-argument function
Node* start = graph.NewNode(common.Start(2));
Node* start = graph.NewNode(common.Start(4));
// Parameter 0 is the receiver
Node* leftParam = graph.NewNode(common.Parameter(1), start);
Node* rightParam = graph.NewNode(common.Parameter(2), start);
......
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