Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 816913003: Implement ES6 rest parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo in ARM port Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2472 2477
2473 // Assign the object to the arguments variable. 2478 // Assign the object to the arguments variable.
2474 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 2479 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
2475 // This should never lazy deopt, so it is fine to send invalid bailout id. 2480 // This should never lazy deopt, so it is fine to send invalid bailout id.
2476 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None()); 2481 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None());
2477 2482
2478 return object; 2483 return object;
2479 } 2484 }
2480 2485
2481 2486
2487 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
2488 if (rest == NULL) return NULL;
2489
2490 DCHECK(index >= 0);
2491 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 1);
2492 Node* object = NewNode(op, jsgraph()->SmiConstant(index));
2493
2494 // Assign the object to the rest array
2495 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
2496 // This should never lazy deopt, so it is fine to send invalid bailout id.
2497 BuildVariableAssignment(rest, object, Token::ASSIGN, BailoutId::None());
2498
2499 return object;
2500 }
2501
2502
2482 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, 2503 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole,
2483 Node* not_hole) { 2504 Node* not_hole) {
2484 IfBuilder hole_check(this); 2505 IfBuilder hole_check(this);
2485 Node* the_hole = jsgraph()->TheHoleConstant(); 2506 Node* the_hole = jsgraph()->TheHoleConstant();
2486 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); 2507 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
2487 hole_check.If(check); 2508 hole_check.If(check);
2488 hole_check.Then(); 2509 hole_check.Then();
2489 environment()->Push(for_hole); 2510 environment()->Push(for_hole);
2490 hole_check.Else(); 2511 hole_check.Else();
2491 environment()->Push(not_hole); 2512 environment()->Push(not_hole);
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
3142 Node* dead_node = graph()->NewNode(common()->Dead()); 3163 Node* dead_node = graph()->NewNode(common()->Dead());
3143 dead_control_.set(dead_node); 3164 dead_control_.set(dead_node);
3144 return dead_node; 3165 return dead_node;
3145 } 3166 }
3146 return dead_control_.get(); 3167 return dead_control_.get();
3147 } 3168 }
3148 3169
3149 } // namespace compiler 3170 } // namespace compiler
3150 } // namespace internal 3171 } // namespace internal
3151 } // namespace v8 3172 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698