Index: src/runtime/runtime-array.cc |
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc |
index ad374d22b29b874adfb6b4c4c852cedce14739ff..41dc016bf6dd5d46f0ca008ece61014b6c376174 100644 |
--- a/src/runtime/runtime-array.cc |
+++ b/src/runtime/runtime-array.cc |
@@ -648,5 +648,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 |