| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 Linkage::kJSFunctionCallClosureParamIndex, "%closure"); | 476 Linkage::kJSFunctionCallClosureParamIndex, "%closure"); |
| 477 Node* node = NewNode(op, graph()->start()); | 477 Node* node = NewNode(op, graph()->start()); |
| 478 function_closure_.set(node); | 478 function_closure_.set(node); |
| 479 } | 479 } |
| 480 return function_closure_.get(); | 480 return function_closure_.get(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 | 483 |
| 484 Node* AstGraphBuilder::GetFunctionContext() { | 484 Node* AstGraphBuilder::GetFunctionContext() { |
| 485 if (!function_context_.is_set()) { | 485 if (!function_context_.is_set()) { |
| 486 // Parameter (arity + 1) is special for the outer context of the function | 486 // Parameter (arity + 2) is special for the outer context of the function |
| 487 const Operator* op = common()->Parameter( | 487 const Operator* op = common()->Parameter( |
| 488 info()->num_parameters_including_this(), "%context"); | 488 info()->num_parameters_including_this() + 1, "%context"); |
| 489 Node* node = NewNode(op, graph()->start()); | 489 Node* node = NewNode(op, graph()->start()); |
| 490 function_context_.set(node); | 490 function_context_.set(node); |
| 491 } | 491 } |
| 492 return function_context_.get(); | 492 return function_context_.get(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 | 495 |
| 496 bool AstGraphBuilder::CreateGraph(bool stack_check) { | 496 bool AstGraphBuilder::CreateGraph(bool stack_check) { |
| 497 Scope* scope = info()->scope(); | 497 Scope* scope = info()->scope(); |
| 498 DCHECK(graph() != NULL); | 498 DCHECK(graph() != NULL); |
| 499 | 499 |
| 500 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 500 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
| 501 // parameters (including the receiver) plus context and closure. | 501 // parameters (including the receiver) plus number of arguments, context and |
| 502 int actual_parameter_count = info()->num_parameters_including_this() + 2; | 502 // closure. |
| 503 int actual_parameter_count = info()->num_parameters_including_this() + 3; |
| 503 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 504 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
| 504 | 505 |
| 505 // Initialize the top-level environment. | 506 // Initialize the top-level environment. |
| 506 Environment env(this, scope, graph()->start()); | 507 Environment env(this, scope, graph()->start()); |
| 507 set_environment(&env); | 508 set_environment(&env); |
| 508 | 509 |
| 509 if (info()->is_osr()) { | 510 if (info()->is_osr()) { |
| 510 // Use OSR normal entry as the start of the top-level environment. | 511 // Use OSR normal entry as the start of the top-level environment. |
| 511 // It will be replaced with {Dead} after typing and optimizations. | 512 // It will be replaced with {Dead} after typing and optimizations. |
| 512 NewNode(common()->OsrNormalEntry()); | 513 NewNode(common()->OsrNormalEntry()); |
| (...skipping 3848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4361 // Phi does not exist yet, introduce one. | 4362 // Phi does not exist yet, introduce one. |
| 4362 value = NewPhi(inputs, value, control); | 4363 value = NewPhi(inputs, value, control); |
| 4363 value->ReplaceInput(inputs - 1, other); | 4364 value->ReplaceInput(inputs - 1, other); |
| 4364 } | 4365 } |
| 4365 return value; | 4366 return value; |
| 4366 } | 4367 } |
| 4367 | 4368 |
| 4368 } // namespace compiler | 4369 } // namespace compiler |
| 4369 } // namespace internal | 4370 } // namespace internal |
| 4370 } // namespace v8 | 4371 } // namespace v8 |
| OLD | NEW |