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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 50e202939aa4cce386678a5e287d6d3a9ded9488..277f0d5c8598a6a1822a9eaa17a92875c12e2069 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -449,6 +449,11 @@ bool AstGraphBuilder::CreateGraph() {
// Build the arguments object if it is used.
BuildArgumentsObject(scope->arguments());
+ // Build rest arguments array if it is used.
+ int rest_index;
+ Variable* rest_parameter = scope->rest_parameter(&rest_index);
+ BuildRestArgumentsArray(rest_parameter, rest_index);
+
// Emit tracing call if requested to do so.
if (FLAG_trace) {
NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0));
@@ -2479,6 +2484,22 @@ Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) {
}
+Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
+ if (rest == NULL) return NULL;
+
+ DCHECK(index >= 0);
+ const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 1);
+ Node* object = NewNode(op, jsgraph()->SmiConstant(index));
+
+ // Assign the object to the rest array
+ DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
+ // This should never lazy deopt, so it is fine to send invalid bailout id.
+ BuildVariableAssignment(rest, object, Token::ASSIGN, BailoutId::None());
+
+ return object;
+}
+
+
Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole,
Node* not_hole) {
IfBuilder hole_check(this);
« 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