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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 return jsgraph()->SmiConstant(0); | 465 return jsgraph()->SmiConstant(0); |
466 } else { | 466 } else { |
467 DCHECK(closure_scope->is_function_scope()); | 467 DCHECK(closure_scope->is_function_scope()); |
468 return GetFunctionClosure(); | 468 return GetFunctionClosure(); |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 Node* AstGraphBuilder::GetFunctionClosure() { | 473 Node* AstGraphBuilder::GetFunctionClosure() { |
474 if (!function_closure_.is_set()) { | 474 if (!function_closure_.is_set()) { |
475 const Operator* op = common()->Parameter( | 475 int index = Linkage::kJSCallClosureParamIndex; |
476 Linkage::kJSFunctionCallClosureParamIndex, "%closure"); | 476 const Operator* op = common()->Parameter(index, "%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 + 2) is special for the outer context of the function | 486 int params = info()->num_parameters_including_this(); |
487 const Operator* op = common()->Parameter( | 487 int index = Linkage::GetJSCallContextParamIndex(params); |
488 info()->num_parameters_including_this() + 1, "%context"); | 488 const Operator* op = common()->Parameter(index, "%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 number of arguments, context and | 501 // parameters (including the receiver) plus new target, number of arguments, |
502 // closure. | 502 // context and closure. |
503 int actual_parameter_count = info()->num_parameters_including_this() + 3; | 503 int actual_parameter_count = info()->num_parameters_including_this() + 4; |
504 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 504 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
505 | 505 |
506 // Initialize the top-level environment. | 506 // Initialize the top-level environment. |
507 Environment env(this, scope, graph()->start()); | 507 Environment env(this, scope, graph()->start()); |
508 set_environment(&env); | 508 set_environment(&env); |
509 | 509 |
510 if (info()->is_osr()) { | 510 if (info()->is_osr()) { |
511 // 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. |
512 // It will be replaced with {Dead} after typing and optimizations. | 512 // It will be replaced with {Dead} after typing and optimizations. |
513 NewNode(common()->OsrNormalEntry()); | 513 NewNode(common()->OsrNormalEntry()); |
(...skipping 3787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4301 // Phi does not exist yet, introduce one. | 4301 // Phi does not exist yet, introduce one. |
4302 value = NewPhi(inputs, value, control); | 4302 value = NewPhi(inputs, value, control); |
4303 value->ReplaceInput(inputs - 1, other); | 4303 value->ReplaceInput(inputs - 1, other); |
4304 } | 4304 } |
4305 return value; | 4305 return value; |
4306 } | 4306 } |
4307 | 4307 |
4308 } // namespace compiler | 4308 } // namespace compiler |
4309 } // namespace internal | 4309 } // namespace internal |
4310 } // namespace v8 | 4310 } // namespace v8 |
OLD | NEW |