Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 4ef0506a12388cf0f534058b33b98e21f3689169..28074fd197577841d1fa378f1db253309f67c592 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -583,11 +583,10 @@ void BytecodeGenerator::MakeBytecodeBody() { |
// Build the arguments object if it is used. |
VisitArgumentsObject(scope()->arguments()); |
- // TODO(mythria): Build rest arguments array if it is used. |
+ // Build rest arguments array if it is used. |
int rest_index; |
- if (scope()->rest_parameter(&rest_index)) { |
- UNIMPLEMENTED(); |
- } |
+ Variable* rest_parameter = scope()->rest_parameter(&rest_index); |
+ VisitRestArgumentsArray(rest_parameter, rest_index); |
// Build assignment to {.this_function} variable if it is used. |
VisitThisFunctionVariable(scope()->this_function_var()); |
@@ -2423,6 +2422,15 @@ void BytecodeGenerator::VisitArgumentsObject(Variable* variable) { |
VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid()); |
} |
+void BytecodeGenerator::VisitRestArgumentsArray(Variable* rest, int index) { |
+ if (rest == nullptr) return; |
+ |
+ // Allocate and initialize a new arguments object and assign to the {rest} |
+ // variable. |
+ builder()->CreateRestArguments(index); |
+ DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); |
+ VisitVariableAssignment(rest, FeedbackVectorSlot::Invalid()); |
+} |
void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) { |
if (variable == nullptr) return; |