| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // Build node to initialize local function context. | 442 // Build node to initialize local function context. |
| 443 Node* closure = GetFunctionClosure(); | 443 Node* closure = GetFunctionClosure(); |
| 444 Node* inner_context = BuildLocalFunctionContext(incoming_context, closure); | 444 Node* inner_context = BuildLocalFunctionContext(incoming_context, closure); |
| 445 | 445 |
| 446 // Push top-level function context for the function body. | 446 // Push top-level function context for the function body. |
| 447 ContextScope top_context(this, scope, inner_context); | 447 ContextScope top_context(this, scope, inner_context); |
| 448 | 448 |
| 449 // Build the arguments object if it is used. | 449 // Build the arguments object if it is used. |
| 450 BuildArgumentsObject(scope->arguments()); | 450 BuildArgumentsObject(scope->arguments()); |
| 451 | 451 |
| 452 // Build rest arguments array if it is used. |
| 453 int rest_index; |
| 454 Variable* rest_parameter = scope->rest_parameter(&rest_index); |
| 455 BuildRestArgumentsArray(rest_parameter, rest_index); |
| 456 |
| 452 // Emit tracing call if requested to do so. | 457 // Emit tracing call if requested to do so. |
| 453 if (FLAG_trace) { | 458 if (FLAG_trace) { |
| 454 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0)); | 459 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0)); |
| 455 } | 460 } |
| 456 | 461 |
| 457 // Visit implicit declaration of the function name. | 462 // Visit implicit declaration of the function name. |
| 458 if (scope->is_function_scope() && scope->function() != NULL) { | 463 if (scope->is_function_scope() && scope->function() != NULL) { |
| 459 VisitVariableDeclaration(scope->function()); | 464 VisitVariableDeclaration(scope->function()); |
| 460 } | 465 } |
| 461 | 466 |
| (...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2461 | 2466 |
| 2462 // Assign the object to the arguments variable. | 2467 // Assign the object to the arguments variable. |
| 2463 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 2468 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
| 2464 // This should never lazy deopt, so it is fine to send invalid bailout id. | 2469 // This should never lazy deopt, so it is fine to send invalid bailout id. |
| 2465 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None()); | 2470 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None()); |
| 2466 | 2471 |
| 2467 return object; | 2472 return object; |
| 2468 } | 2473 } |
| 2469 | 2474 |
| 2470 | 2475 |
| 2476 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { |
| 2477 if (rest == NULL) return NULL; |
| 2478 |
| 2479 DCHECK(index >= 0); |
| 2480 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 1); |
| 2481 Node* object = NewNode(op, jsgraph()->SmiConstant(index)); |
| 2482 |
| 2483 // Assign the object to the rest array |
| 2484 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); |
| 2485 // This should never lazy deopt, so it is fine to send invalid bailout id. |
| 2486 BuildVariableAssignment(rest, object, Token::ASSIGN, BailoutId::None()); |
| 2487 |
| 2488 return object; |
| 2489 } |
| 2490 |
| 2491 |
| 2471 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, | 2492 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, |
| 2472 Node* not_hole) { | 2493 Node* not_hole) { |
| 2473 IfBuilder hole_check(this); | 2494 IfBuilder hole_check(this); |
| 2474 Node* the_hole = jsgraph()->TheHoleConstant(); | 2495 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 2475 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); | 2496 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); |
| 2476 hole_check.If(check); | 2497 hole_check.If(check); |
| 2477 hole_check.Then(); | 2498 hole_check.Then(); |
| 2478 environment()->Push(for_hole); | 2499 environment()->Push(for_hole); |
| 2479 hole_check.Else(); | 2500 hole_check.Else(); |
| 2480 environment()->Push(not_hole); | 2501 environment()->Push(not_hole); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3131 Node* dead_node = graph()->NewNode(common()->Dead()); | 3152 Node* dead_node = graph()->NewNode(common()->Dead()); |
| 3132 dead_control_.set(dead_node); | 3153 dead_control_.set(dead_node); |
| 3133 return dead_node; | 3154 return dead_node; |
| 3134 } | 3155 } |
| 3135 return dead_control_.get(); | 3156 return dead_control_.get(); |
| 3136 } | 3157 } |
| 3137 | 3158 |
| 3138 } // namespace compiler | 3159 } // namespace compiler |
| 3139 } // namespace internal | 3160 } // namespace internal |
| 3140 } // namespace v8 | 3161 } // namespace v8 |
| OLD | NEW |