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

Side by Side Diff: src/bootstrapper.cc

Issue 2608333002: [cleanup] remove sloppy generator/async function maps (Closed)
Patch Set: [cleanup] remove sloppy generator/async function maps Created 3 years, 11 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 | « no previous file | src/builtins/builtins-constructor.cc » ('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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 SimpleCreateFunction(isolate(), factory()->next_string(), 747 SimpleCreateFunction(isolate(), factory()->next_string(),
748 Builtins::kGeneratorPrototypeNext, 1, true); 748 Builtins::kGeneratorPrototypeNext, 1, true);
749 native_context()->set_generator_next_internal(*generator_next_internal); 749 native_context()->set_generator_next_internal(*generator_next_internal);
750 750
751 // Create maps for generator functions and their prototypes. Store those 751 // Create maps for generator functions and their prototypes. Store those
752 // maps in the native context. The "prototype" property descriptor is 752 // maps in the native context. The "prototype" property descriptor is
753 // writable, non-enumerable, and non-configurable (as per ES6 draft 753 // writable, non-enumerable, and non-configurable (as per ES6 draft
754 // 04-14-15, section 25.2.4.3). 754 // 04-14-15, section 25.2.4.3).
755 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); 755 Handle<Map> strict_function_map(strict_function_map_writable_prototype_);
756 // Generator functions do not have "caller" or "arguments" accessors. 756 // Generator functions do not have "caller" or "arguments" accessors.
757 Handle<Map> sloppy_generator_function_map = 757 Handle<Map> generator_function_map =
758 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); 758 Map::Copy(strict_function_map, "GeneratorFunction");
759 sloppy_generator_function_map->set_is_constructor(false); 759 generator_function_map->set_is_constructor(false);
760 Map::SetPrototype(sloppy_generator_function_map, 760 Map::SetPrototype(generator_function_map, generator_function_prototype);
761 generator_function_prototype); 761 native_context()->set_generator_function_map(*generator_function_map);
762 native_context()->set_sloppy_generator_function_map(
763 *sloppy_generator_function_map);
764
765 Handle<Map> strict_generator_function_map =
766 Map::Copy(strict_function_map, "StrictGeneratorFunction");
767 strict_generator_function_map->set_is_constructor(false);
768 Map::SetPrototype(strict_generator_function_map,
769 generator_function_prototype);
770 native_context()->set_strict_generator_function_map(
771 *strict_generator_function_map);
772 762
773 Handle<JSFunction> object_function(native_context()->object_function()); 763 Handle<JSFunction> object_function(native_context()->object_function());
774 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); 764 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
775 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); 765 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype);
776 native_context()->set_generator_object_prototype_map( 766 native_context()->set_generator_object_prototype_map(
777 *generator_object_prototype_map); 767 *generator_object_prototype_map);
778 } 768 }
779 769
780 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { 770 void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) {
781 // %AsyncFunctionPrototype% intrinsic 771 // %AsyncFunctionPrototype% intrinsic
782 Handle<JSObject> async_function_prototype = 772 Handle<JSObject> async_function_prototype =
783 factory()->NewJSObject(isolate()->object_function(), TENURED); 773 factory()->NewJSObject(isolate()->object_function(), TENURED);
784 JSObject::ForceSetPrototype(async_function_prototype, empty); 774 JSObject::ForceSetPrototype(async_function_prototype, empty);
785 775
786 JSObject::AddProperty(async_function_prototype, 776 JSObject::AddProperty(async_function_prototype,
787 factory()->to_string_tag_symbol(), 777 factory()->to_string_tag_symbol(),
788 factory()->NewStringFromAsciiChecked("AsyncFunction"), 778 factory()->NewStringFromAsciiChecked("AsyncFunction"),
789 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 779 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
790 780
791 Handle<Map> strict_function_map( 781 Handle<Map> strict_function_map(
792 native_context()->strict_function_without_prototype_map()); 782 native_context()->strict_function_without_prototype_map());
793 Handle<Map> sloppy_async_function_map = 783 Handle<Map> async_function_map =
794 Map::Copy(strict_function_map, "SloppyAsyncFunction");
795 sloppy_async_function_map->set_is_constructor(false);
796 Map::SetPrototype(sloppy_async_function_map, async_function_prototype);
797 native_context()->set_sloppy_async_function_map(*sloppy_async_function_map);
798
799 Handle<Map> strict_async_function_map =
800 Map::Copy(strict_function_map, "StrictAsyncFunction"); 784 Map::Copy(strict_function_map, "StrictAsyncFunction");
adamk 2017/01/03 20:55:41 No need for the "Strict" prefix here either.
caitp 2017/01/03 21:12:04 Done
801 strict_async_function_map->set_is_constructor(false); 785 async_function_map->set_is_constructor(false);
802 Map::SetPrototype(strict_async_function_map, async_function_prototype); 786 Map::SetPrototype(async_function_map, async_function_prototype);
803 native_context()->set_strict_async_function_map(*strict_async_function_map); 787 native_context()->set_async_function_map(*async_function_map);
804 } 788 }
805 789
806 void Genesis::CreateJSProxyMaps() { 790 void Genesis::CreateJSProxyMaps() {
807 // Allocate the different maps for all Proxy types. 791 // Allocate the different maps for all Proxy types.
808 // Next to the default proxy, we need maps indicating callable and 792 // Next to the default proxy, we need maps indicating callable and
809 // constructable proxies. 793 // constructable proxies.
810 Handle<Map> proxy_function_map = 794 Handle<Map> proxy_function_map =
811 Map::Copy(isolate()->sloppy_function_without_prototype_map(), "Proxy"); 795 Map::Copy(isolate()->sloppy_function_without_prototype_map(), "Proxy");
812 proxy_function_map->set_is_constructor(true); 796 proxy_function_map->set_is_constructor(true);
813 native_context()->set_proxy_function_map(*proxy_function_map); 797 native_context()->set_proxy_function_map(*proxy_function_map);
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 } 3114 }
3131 3115
3132 Handle<JSObject> iterator_prototype( 3116 Handle<JSObject> iterator_prototype(
3133 native_context->initial_iterator_prototype()); 3117 native_context->initial_iterator_prototype());
3134 3118
3135 JSObject::AddProperty(container, 3119 JSObject::AddProperty(container,
3136 factory->InternalizeUtf8String("IteratorPrototype"), 3120 factory->InternalizeUtf8String("IteratorPrototype"),
3137 iterator_prototype, NONE); 3121 iterator_prototype, NONE);
3138 3122
3139 { 3123 {
3140 PrototypeIterator iter(native_context->sloppy_generator_function_map()); 3124 PrototypeIterator iter(native_context->generator_function_map());
3141 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>()); 3125 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>());
3142 3126
3143 JSObject::AddProperty( 3127 JSObject::AddProperty(
3144 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 3128 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
3145 generator_function_prototype, NONE); 3129 generator_function_prototype, NONE);
3146 3130
3147 static const bool kUseStrictFunctionMap = true; 3131 static const bool kUseStrictFunctionMap = true;
3148 Handle<JSFunction> generator_function_function = InstallFunction( 3132 Handle<JSFunction> generator_function_function = InstallFunction(
3149 container, "GeneratorFunction", JS_FUNCTION_TYPE, JSFunction::kSize, 3133 container, "GeneratorFunction", JS_FUNCTION_TYPE, JSFunction::kSize,
3150 generator_function_prototype, Builtins::kGeneratorFunctionConstructor, 3134 generator_function_prototype, Builtins::kGeneratorFunctionConstructor,
3151 kUseStrictFunctionMap); 3135 kUseStrictFunctionMap);
3152 generator_function_function->set_prototype_or_initial_map( 3136 generator_function_function->set_prototype_or_initial_map(
3153 native_context->sloppy_generator_function_map()); 3137 native_context->generator_function_map());
3154 generator_function_function->shared()->DontAdaptArguments(); 3138 generator_function_function->shared()->DontAdaptArguments();
3155 generator_function_function->shared()->SetConstructStub( 3139 generator_function_function->shared()->SetConstructStub(
3156 *isolate->builtins()->GeneratorFunctionConstructor()); 3140 *isolate->builtins()->GeneratorFunctionConstructor());
3157 generator_function_function->shared()->set_length(1); 3141 generator_function_function->shared()->set_length(1);
3158 InstallWithIntrinsicDefaultProto( 3142 InstallWithIntrinsicDefaultProto(
3159 isolate, generator_function_function, 3143 isolate, generator_function_function,
3160 Context::GENERATOR_FUNCTION_FUNCTION_INDEX); 3144 Context::GENERATOR_FUNCTION_FUNCTION_INDEX);
3161 3145
3162 JSObject::ForceSetPrototype(generator_function_function, 3146 JSObject::ForceSetPrototype(generator_function_function,
3163 isolate->function_function()); 3147 isolate->function_function());
3164 JSObject::AddProperty( 3148 JSObject::AddProperty(
3165 generator_function_prototype, factory->constructor_string(), 3149 generator_function_prototype, factory->constructor_string(),
3166 generator_function_function, 3150 generator_function_function,
3167 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 3151 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
3168 3152
3169 native_context->sloppy_generator_function_map()->SetConstructor( 3153 native_context->generator_function_map()->SetConstructor(
3170 *generator_function_function);
3171 native_context->strict_generator_function_map()->SetConstructor(
3172 *generator_function_function); 3154 *generator_function_function);
3173 } 3155 }
3174 3156
3175 { // -- S e t I t e r a t o r 3157 { // -- S e t I t e r a t o r
3176 Handle<JSObject> set_iterator_prototype = 3158 Handle<JSObject> set_iterator_prototype =
3177 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 3159 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
3178 JSObject::ForceSetPrototype(set_iterator_prototype, iterator_prototype); 3160 JSObject::ForceSetPrototype(set_iterator_prototype, iterator_prototype);
3179 Handle<JSFunction> set_iterator_function = InstallFunction( 3161 Handle<JSFunction> set_iterator_function = InstallFunction(
3180 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 3162 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
3181 set_iterator_prototype, Builtins::kIllegal); 3163 set_iterator_prototype, Builtins::kIllegal);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 Handle<AccessorInfo> script_source_mapping_url = 3297 Handle<AccessorInfo> script_source_mapping_url =
3316 Accessors::ScriptSourceMappingUrlInfo(isolate, attribs); 3298 Accessors::ScriptSourceMappingUrlInfo(isolate, attribs);
3317 { 3299 {
3318 Descriptor d = Descriptor::AccessorConstant( 3300 Descriptor d = Descriptor::AccessorConstant(
3319 Handle<Name>(Name::cast(script_source_mapping_url->name())), 3301 Handle<Name>(Name::cast(script_source_mapping_url->name())),
3320 script_source_mapping_url, attribs); 3302 script_source_mapping_url, attribs);
3321 script_map->AppendDescriptor(&d); 3303 script_map->AppendDescriptor(&d);
3322 } 3304 }
3323 3305
3324 { 3306 {
3325 PrototypeIterator iter(native_context->sloppy_async_function_map()); 3307 PrototypeIterator iter(native_context->async_function_map());
3326 Handle<JSObject> async_function_prototype(iter.GetCurrent<JSObject>()); 3308 Handle<JSObject> async_function_prototype(iter.GetCurrent<JSObject>());
3327 3309
3328 static const bool kUseStrictFunctionMap = true; 3310 static const bool kUseStrictFunctionMap = true;
3329 Handle<JSFunction> async_function_constructor = InstallFunction( 3311 Handle<JSFunction> async_function_constructor = InstallFunction(
3330 container, "AsyncFunction", JS_FUNCTION_TYPE, JSFunction::kSize, 3312 container, "AsyncFunction", JS_FUNCTION_TYPE, JSFunction::kSize,
3331 async_function_prototype, Builtins::kAsyncFunctionConstructor, 3313 async_function_prototype, Builtins::kAsyncFunctionConstructor,
3332 kUseStrictFunctionMap); 3314 kUseStrictFunctionMap);
3333 async_function_constructor->shared()->DontAdaptArguments(); 3315 async_function_constructor->shared()->DontAdaptArguments();
3334 async_function_constructor->shared()->SetConstructStub( 3316 async_function_constructor->shared()->SetConstructStub(
3335 *isolate->builtins()->AsyncFunctionConstructor()); 3317 *isolate->builtins()->AsyncFunctionConstructor());
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
4745 } 4727 }
4746 4728
4747 4729
4748 // Called when the top-level V8 mutex is destroyed. 4730 // Called when the top-level V8 mutex is destroyed.
4749 void Bootstrapper::FreeThreadResources() { 4731 void Bootstrapper::FreeThreadResources() {
4750 DCHECK(!IsActive()); 4732 DCHECK(!IsActive());
4751 } 4733 }
4752 4734
4753 } // namespace internal 4735 } // namespace internal
4754 } // namespace v8 4736 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins-constructor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698