Index: src/runtime/runtime-array.cc |
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc |
index a9cbc208b34e442cc25d4f40dedf46acfba62ded..20cd65974c0fcaa67e38c823b246b36e073bf970 100644 |
--- a/src/runtime/runtime-array.cc |
+++ b/src/runtime/runtime-array.cc |
@@ -646,5 +646,33 @@ RUNTIME_FUNCTION(Runtime_SpreadIterablePrepare) { |
return *spread; |
} |
+RUNTIME_FUNCTION(Runtime_SpreadIterableFixed) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(1, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, spread, 0); |
+ |
+ // The caller should check if proper iteration is necessary. |
+ Handle<JSFunction> spread_iterable_function = isolate->spread_iterable(); |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, spread, |
+ Execution::Call(isolate, spread_iterable_function, |
+ isolate->factory()->undefined_value(), 1, &spread)); |
+ |
+ // Create a new FixedArray and put the result of the spread into it. |
+ Handle<JSArray> spread_array = Handle<JSArray>::cast(spread); |
+ uint32_t spread_length; |
+ CHECK(spread_array->length()->ToArrayIndex(&spread_length)); |
+ |
+ Handle<FixedArray> result = isolate->factory()->NewFixedArray(spread_length); |
+ ElementsAccessor* accessor = spread_array->GetElementsAccessor(); |
+ for (uint32_t i = 0; i < spread_length; i++) { |
+ DCHECK(accessor->HasElement(spread_array, i)); |
+ Handle<Object> element = accessor->Get(spread_array, i); |
+ result->set(i, *element); |
+ } |
+ |
+ return *result; |
+} |
+ |
} // namespace internal |
} // namespace v8 |