Chromium Code Reviews| Index: src/bootstrapper.cc |
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
| index 14fe8b0a5b67b9c058cf437de1d44c6931c3d555..6acd1e71206f3f9b3b9b103b7003b0eb1bddd909 100644 |
| --- a/src/bootstrapper.cc |
| +++ b/src/bootstrapper.cc |
| @@ -660,6 +660,16 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { |
| // Create iterator-related meta-objects. |
| Handle<JSObject> iterator_prototype = |
| factory()->NewJSObject(isolate()->object_function(), TENURED); |
| + |
| + Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction( |
|
caitp
2016/09/15 19:02:39
The full %IteratorPrototype% is now set up here, s
|
| + isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"), |
| + Builtins::kIteratorPrototypeIterator, 0, false); |
| + iterator_prototype_iterator->shared()->set_native(true); |
| + |
| + JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(), |
| + iterator_prototype_iterator, DONT_ENUM); |
| + native_context()->set_initial_iterator_prototype(*iterator_prototype); |
| + |
| Handle<JSObject> generator_object_prototype = |
| factory()->NewJSObject(isolate()->object_function(), TENURED); |
| native_context()->set_initial_generator_prototype( |
| @@ -1406,6 +1416,38 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, |
| Builtins::kStringPrototypeTrimRight, 0, false); |
| SimpleInstallFunction(prototype, "valueOf", |
| Builtins::kStringPrototypeValueOf, 0, true); |
| + |
| + Handle<JSFunction> iterator = SimpleCreateFunction( |
| + isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"), |
| + Builtins::kStringPrototypeIterator, 0, true); |
| + iterator->shared()->set_native(true); |
| + JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator, |
| + static_cast<PropertyAttributes>(DONT_ENUM)); |
| + } |
| + |
| + { // --- S t r i n g I t e r a t o r --- |
| + Handle<JSObject> iterator_prototype( |
| + native_context()->initial_iterator_prototype()); |
| + |
| + Handle<JSObject> string_iterator_prototype = |
| + factory->NewJSObject(isolate->object_function(), TENURED); |
| + JSObject::ForceSetPrototype(string_iterator_prototype, iterator_prototype); |
|
caitp
2016/09/15 19:02:39
TODO: use JSObject::SetPrototype()
caitp
2016/09/15 19:14:57
JSObject::SetPrototype actually doesn't seem like
Benedikt Meurer
2016/09/16 03:16:37
Acknowledged.
|
| + |
| + JSObject::AddProperty( |
| + string_iterator_prototype, factory->to_string_tag_symbol(), |
| + factory->NewStringFromAsciiChecked("String Iterator"), |
| + static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| + |
| + InstallFunction(string_iterator_prototype, "next", JS_OBJECT_TYPE, |
| + JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
| + Builtins::kStringIteratorPrototypeNext); |
| + |
| + Handle<JSFunction> string_iterator_function = CreateFunction( |
| + isolate, factory->NewStringFromAsciiChecked("StringIterator"), |
|
caitp
2016/09/15 19:02:39
I assume this string is actually used for somethin
|
| + JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize, |
| + string_iterator_prototype, Builtins::kIllegal); |
| + native_context()->set_string_iterator_map( |
| + string_iterator_function->initial_map()); |
| } |
| { |
| @@ -2466,17 +2508,12 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, |
| native_context->set_object_to_string(*to_string); |
| } |
| - Handle<JSObject> iterator_prototype; |
| - |
| - { |
| - PrototypeIterator iter(native_context->generator_object_prototype_map()); |
| - iter.Advance(); // Advance to the prototype of generator_object_prototype. |
| - iterator_prototype = Handle<JSObject>(iter.GetCurrent<JSObject>()); |
| + Handle<JSObject> iterator_prototype( |
|
caitp
2016/09/15 19:02:39
This stuff is still used by collections iterators
|
| + native_context->initial_iterator_prototype()); |
| - JSObject::AddProperty(container, |
| - factory->InternalizeUtf8String("IteratorPrototype"), |
| - iterator_prototype, NONE); |
| - } |
| + JSObject::AddProperty(container, |
| + factory->InternalizeUtf8String("IteratorPrototype"), |
| + iterator_prototype, NONE); |
| { |
| PrototypeIterator iter(native_context->sloppy_generator_function_map()); |