| Index: src/bootstrapper.cc
|
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
|
| index 5c77aa4e95a8d2d22a112838e376cc1ee45039ba..e8cdeb21894526d37ad363b7ac1f0d271e4b410a 100644
|
| --- a/src/bootstrapper.cc
|
| +++ b/src/bootstrapper.cc
|
| @@ -1303,6 +1303,94 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
| native_context()->set_is_arraylike(*is_arraylike);
|
| }
|
|
|
| + { // --- A r r a y I t e r a t o r ---
|
| + Handle<JSObject> iterator_prototype(
|
| + native_context()->initial_iterator_prototype());
|
| +
|
| + Handle<JSObject> array_iterator_prototype =
|
| + factory->NewJSObject(isolate->object_function(), TENURED);
|
| + JSObject::ForceSetPrototype(array_iterator_prototype, iterator_prototype);
|
| +
|
| + JSObject::AddProperty(
|
| + array_iterator_prototype, factory->to_string_tag_symbol(),
|
| + factory->ArrayIterator_string(),
|
| + static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
|
| +
|
| + Handle<JSFunction> next = InstallFunction(
|
| + array_iterator_prototype, "next", JS_OBJECT_TYPE, JSObject::kHeaderSize,
|
| + MaybeHandle<JSObject>(), Builtins::kArrayIteratorPrototypeNext);
|
| +
|
| + // Set the expected parameters for %ArrayIteratorPrototype%.next to 0 (not
|
| + // including the receiver), as required by the builtin.
|
| + next->shared()->set_internal_formal_parameter_count(0);
|
| +
|
| + // Set the length for the function to satisfy ECMA-262.
|
| + next->shared()->set_length(0);
|
| +
|
| + Handle<JSFunction> array_iterator_function = CreateFunction(
|
| + isolate, factory->ArrayIterator_string(),
|
| + JS_FAST_ARRAY_VALUE_ITERATOR_TYPE, JSArrayIterator::kSize,
|
| + array_iterator_prototype, Builtins::kIllegal);
|
| + array_iterator_function->shared()->set_instance_class_name(
|
| + isolate->heap()->ArrayIterator_string());
|
| +
|
| + Handle<Map> initial_map(array_iterator_function->initial_map(), isolate);
|
| +
|
| +#define ARRAY_ITERATOR_LIST(V, TypedArray, Array) \
|
| + V(TypedArray, TYPED_ARRAY, KEY, typed_array, key) \
|
| + V(Array, GENERIC_ARRAY, KEY, array, key) \
|
| + V(TypedArray, UINT8_ARRAY, KEY_VALUE, uint8_array, key_value) \
|
| + V(TypedArray, INT8_ARRAY, KEY_VALUE, int8_array, key_value) \
|
| + V(TypedArray, UINT16_ARRAY, KEY_VALUE, uint16_array, key_value) \
|
| + V(TypedArray, INT16_ARRAY, KEY_VALUE, int16_array, key_value) \
|
| + V(TypedArray, UINT32_ARRAY, KEY_VALUE, uint32_array, key_value) \
|
| + V(TypedArray, INT32_ARRAY, KEY_VALUE, int32_array, key_value) \
|
| + V(TypedArray, FLOAT32_ARRAY, KEY_VALUE, float32_array, key_value) \
|
| + V(TypedArray, FLOAT64_ARRAY, KEY_VALUE, float64_array, key_value) \
|
| + V(TypedArray, UINT8_CLAMPED_ARRAY, KEY_VALUE, uint8_clamped_array, \
|
| + key_value) \
|
| + V(Array, FAST_SMI_ARRAY, KEY_VALUE, fast_smi_array, key_value) \
|
| + V(Array, FAST_HOLEY_SMI_ARRAY, KEY_VALUE, fast_holey_smi_array, key_value) \
|
| + V(Array, FAST_ARRAY, KEY_VALUE, fast_array, key_value) \
|
| + V(Array, FAST_HOLEY_ARRAY, KEY_VALUE, fast_holey_array, key_value) \
|
| + V(Array, FAST_DOUBLE_ARRAY, KEY_VALUE, fast_double_array, key_value) \
|
| + V(Array, FAST_HOLEY_DOUBLE_ARRAY, KEY_VALUE, fast_holey_double_array, \
|
| + key_value) \
|
| + V(Array, GENERIC_ARRAY, KEY_VALUE, array, key_value) \
|
| + V(TypedArray, UINT8_ARRAY, VALUE, uint8_array, value) \
|
| + V(TypedArray, INT8_ARRAY, VALUE, int8_array, value) \
|
| + V(TypedArray, UINT16_ARRAY, VALUE, uint16_array, value) \
|
| + V(TypedArray, INT16_ARRAY, VALUE, int16_array, value) \
|
| + V(TypedArray, UINT32_ARRAY, VALUE, uint32_array, value) \
|
| + V(TypedArray, INT32_ARRAY, VALUE, int32_array, value) \
|
| + V(TypedArray, FLOAT32_ARRAY, VALUE, float32_array, value) \
|
| + V(TypedArray, FLOAT64_ARRAY, VALUE, float64_array, value) \
|
| + V(TypedArray, UINT8_CLAMPED_ARRAY, VALUE, uint8_clamped_array, value) \
|
| + V(Array, FAST_SMI_ARRAY, VALUE, fast_smi_array, value) \
|
| + V(Array, FAST_HOLEY_SMI_ARRAY, VALUE, fast_holey_smi_array, value) \
|
| + V(Array, FAST_ARRAY, VALUE, fast_array, value) \
|
| + V(Array, FAST_HOLEY_ARRAY, VALUE, fast_holey_array, value) \
|
| + V(Array, FAST_DOUBLE_ARRAY, VALUE, fast_double_array, value) \
|
| + V(Array, FAST_HOLEY_DOUBLE_ARRAY, VALUE, fast_holey_double_array, value) \
|
| + V(Array, GENERIC_ARRAY, VALUE, array, value)
|
| +
|
| +#define CREATE_ARRAY_ITERATOR_MAP(Class, PREFIX, SUFFIX, prefix, suffix) \
|
| + do { \
|
| + const InstanceType type = JS_##PREFIX##_##SUFFIX##_ITERATOR_TYPE; \
|
| + Handle<Map> map = \
|
| + Map::Copy(initial_map, "JS_" #PREFIX "_" #SUFFIX "_ITERATOR_TYPE"); \
|
| + map->set_instance_size(Class::kSize); \
|
| + map->set_instance_type(type); \
|
| + native_context()->set_##prefix##_##suffix##_iterator_map(*map); \
|
| + } while (0);
|
| +
|
| + ARRAY_ITERATOR_LIST(CREATE_ARRAY_ITERATOR_MAP, JSTypedArrayIterator,
|
| + JSArrayIterator)
|
| +
|
| +#undef CREATE_ARRAY_ITERATOR_MAP
|
| +#undef ARRAY_ITERATOR_LIST
|
| + }
|
| +
|
| { // --- N u m b e r ---
|
| Handle<JSFunction> number_fun = InstallFunction(
|
| global, "Number", JS_VALUE_TYPE, JSValue::kSize,
|
| @@ -2077,6 +2165,18 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
| SimpleInstallGetter(prototype, factory->length_string(),
|
| Builtins::kTypedArrayPrototypeLength, true,
|
| kTypedArrayLength);
|
| +
|
| + // Install "keys", "values" and "entries" methods on the {prototype}.
|
| + SimpleInstallFunction(prototype, factory->entries_string(),
|
| + Builtins::kTypedArrayPrototypeEntries, 0, true);
|
| + SimpleInstallFunction(prototype, factory->keys_string(),
|
| + Builtins::kTypedArrayPrototypeKeys, 0, true);
|
| + Handle<JSFunction> iterator =
|
| + SimpleInstallFunction(prototype, factory->values_string(),
|
| + Builtins::kTypedArrayPrototypeValues, 0, true);
|
| + JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator,
|
| + DONT_ENUM);
|
| + native_context()->set_array_values_iterator(*iterator);
|
| }
|
|
|
| { // -- T y p e d A r r a y s
|
| @@ -2811,6 +2911,14 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
|
| *generator_function_function);
|
| }
|
|
|
| + { // -- A r r a y I t e r a t o r
|
| + Handle<Object> array_values(native_context->array_values_iterator(),
|
| + isolate);
|
| + JSObject::AddProperty(container,
|
| + factory->NewStringFromAsciiChecked("ArrayValues"),
|
| + array_values, DONT_ENUM);
|
| + }
|
| +
|
| { // -- F i x e d A r r a y I t e r a t o r
|
| int size = JSFixedArrayIterator::kHeaderSize +
|
| JSFixedArrayIterator::kInObjectPropertyCount * kPointerSize;
|
|
|