Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: src/bootstrapper.cc

Issue 2407423002: [modules] Implement @@iterator on namespace objects. (Closed)
Patch Set: Rename kSize to kHeadersize again. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/ast-types.cc ('k') | src/builtins/builtins.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 global, "Set", JS_SET_TYPE, JSSet::kSize, 2154 global, "Set", JS_SET_TYPE, JSSet::kSize,
2155 isolate->initial_object_prototype(), Builtins::kIllegal); 2155 isolate->initial_object_prototype(), Builtins::kIllegal);
2156 InstallWithIntrinsicDefaultProto(isolate, js_set_fun, 2156 InstallWithIntrinsicDefaultProto(isolate, js_set_fun,
2157 Context::JS_SET_FUN_INDEX); 2157 Context::JS_SET_FUN_INDEX);
2158 } 2158 }
2159 2159
2160 { // -- J S M o d u l e N a m e s p a c e 2160 { // -- J S M o d u l e N a m e s p a c e
2161 Handle<Map> map = 2161 Handle<Map> map =
2162 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize); 2162 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize);
2163 Map::SetPrototype(map, isolate->factory()->null_value()); 2163 Map::SetPrototype(map, isolate->factory()->null_value());
2164 Map::EnsureDescriptorSlack(map, 2);
2164 native_context()->set_js_module_namespace_map(*map); 2165 native_context()->set_js_module_namespace_map(*map);
2165 2166
2166 // Install @@toStringTag. 2167 { // Install @@toStringTag.
2167 PropertyAttributes attribs = 2168 PropertyAttributes attribs =
2168 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); 2169 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
2169 DataConstantDescriptor d(factory->to_string_tag_symbol(), 2170 DataConstantDescriptor d(factory->to_string_tag_symbol(),
2170 factory->NewStringFromAsciiChecked("Module"), 2171 factory->NewStringFromAsciiChecked("Module"),
2171 attribs); 2172 attribs);
2172 Map::EnsureDescriptorSlack(map, 1); 2173 map->AppendDescriptor(&d);
2173 map->AppendDescriptor(&d); 2174 }
2174 2175
2175 // TODO(neis): Implement and install @@iterator. 2176 { // Install @@iterator.
2177 Handle<JSFunction> iterator = SimpleCreateFunction(
2178 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"),
2179 Builtins::kModuleNamespaceIterator, 0, true);
2180 iterator->shared()->set_native(true);
2181 // TODO(neis): Is this really supposed to be writable?
2182 DataConstantDescriptor d(factory->iterator_symbol(), iterator, DONT_ENUM);
2183 map->AppendDescriptor(&d);
2184 }
2176 } 2185 }
2177 2186
2178 { // -- I t e r a t o r R e s u l t 2187 { // -- I t e r a t o r R e s u l t
2179 Handle<Map> map = 2188 Handle<Map> map =
2180 factory->NewMap(JS_OBJECT_TYPE, JSIteratorResult::kSize); 2189 factory->NewMap(JS_OBJECT_TYPE, JSIteratorResult::kSize);
2181 Map::SetPrototype(map, isolate->initial_object_prototype()); 2190 Map::SetPrototype(map, isolate->initial_object_prototype());
2182 Map::EnsureDescriptorSlack(map, 2); 2191 Map::EnsureDescriptorSlack(map, 2);
2183 2192
2184 { // value 2193 { // value
2185 DataDescriptor d(factory->value_string(), JSIteratorResult::kValueIndex, 2194 DataDescriptor d(factory->value_string(), JSIteratorResult::kValueIndex,
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 generator_function_prototype, factory->constructor_string(), 2784 generator_function_prototype, factory->constructor_string(),
2776 generator_function_function, 2785 generator_function_function,
2777 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 2786 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2778 2787
2779 native_context->sloppy_generator_function_map()->SetConstructor( 2788 native_context->sloppy_generator_function_map()->SetConstructor(
2780 *generator_function_function); 2789 *generator_function_function);
2781 native_context->strict_generator_function_map()->SetConstructor( 2790 native_context->strict_generator_function_map()->SetConstructor(
2782 *generator_function_function); 2791 *generator_function_function);
2783 } 2792 }
2784 2793
2794 { // -- F i x e d A r r a y I t e r a t o r
2795 int size = JSFixedArrayIterator::kHeaderSize +
2796 JSFixedArrayIterator::kInObjectPropertyCount * kPointerSize;
2797 Handle<Map> map = factory->NewMap(JS_FIXED_ARRAY_ITERATOR_TYPE, size);
2798 Map::SetPrototype(map, iterator_prototype);
2799 Map::EnsureDescriptorSlack(map,
2800 JSFixedArrayIterator::kInObjectPropertyCount);
2801 map->SetInObjectProperties(JSFixedArrayIterator::kInObjectPropertyCount);
2802 map->SetConstructor(native_context->object_function());
2803
2804 { // next
2805 DataDescriptor d(factory->next_string(), JSFixedArrayIterator::kNextIndex,
2806 DONT_ENUM, Representation::Tagged());
2807 map->AppendDescriptor(&d);
2808 }
2809
2810 native_context->set_fixed_array_iterator_map(*map);
2811 }
2812
2785 { // -- S e t I t e r a t o r 2813 { // -- S e t I t e r a t o r
2786 Handle<JSObject> set_iterator_prototype = 2814 Handle<JSObject> set_iterator_prototype =
2787 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 2815 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
2788 JSObject::ForceSetPrototype(set_iterator_prototype, iterator_prototype); 2816 JSObject::ForceSetPrototype(set_iterator_prototype, iterator_prototype);
2789 Handle<JSFunction> set_iterator_function = InstallFunction( 2817 Handle<JSFunction> set_iterator_function = InstallFunction(
2790 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 2818 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
2791 set_iterator_prototype, Builtins::kIllegal); 2819 set_iterator_prototype, Builtins::kIllegal);
2792 native_context->set_set_iterator_map(set_iterator_function->initial_map()); 2820 native_context->set_set_iterator_map(set_iterator_function->initial_map());
2793 } 2821 }
2794 2822
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
4405 } 4433 }
4406 4434
4407 4435
4408 // Called when the top-level V8 mutex is destroyed. 4436 // Called when the top-level V8 mutex is destroyed.
4409 void Bootstrapper::FreeThreadResources() { 4437 void Bootstrapper::FreeThreadResources() {
4410 DCHECK(!IsActive()); 4438 DCHECK(!IsActive());
4411 } 4439 }
4412 4440
4413 } // namespace internal 4441 } // namespace internal
4414 } // namespace v8 4442 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-types.cc ('k') | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698