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

Side by Side Diff: src/bootstrapper.cc

Issue 1731063007: Remove the global Strength enum class completely. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_strong-remove-literals
Patch Set: Remove more cruft. Created 4 years, 9 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.cc ('k') | src/contexts.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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Creates some basic objects. Used for creating a context from scratch. 150 // Creates some basic objects. Used for creating a context from scratch.
151 void CreateRoots(); 151 void CreateRoots();
152 // Creates the empty function. Used for creating a context from scratch. 152 // Creates the empty function. Used for creating a context from scratch.
153 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate); 153 Handle<JSFunction> CreateEmptyFunction(Isolate* isolate);
154 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 154 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3
155 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); 155 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower();
156 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); 156 Handle<JSFunction> GetStrictArgumentsPoisonFunction();
157 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); 157 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name);
158 158
159 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); 159 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty);
160 void CreateStrongModeFunctionMaps(Handle<JSFunction> empty);
161 void CreateIteratorMaps(); 160 void CreateIteratorMaps();
162 161
163 // Make the "arguments" and "caller" properties throw a TypeError on access. 162 // Make the "arguments" and "caller" properties throw a TypeError on access.
164 void AddRestrictedFunctionProperties(Handle<Map> map); 163 void AddRestrictedFunctionProperties(Handle<Map> map);
165 164
166 // Creates the global objects using the global proxy and the template passed 165 // Creates the global objects using the global proxy and the template passed
167 // in through the API. We call this regardless of whether we are building a 166 // in through the API. We call this regardless of whether we are building a
168 // context from scratch or using a deserialized one from the partial snapshot 167 // context from scratch or using a deserialized one from the partial snapshot
169 // but in the latter case we don't use the objects it produces directly, as 168 // but in the latter case we don't use the objects it produces directly, as
170 // we have to used the deserialized ones that are linked together with the 169 // we have to used the deserialized ones that are linked together with the
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 276 }
278 277
279 Handle<Map> CreateSloppyFunctionMap(FunctionMode function_mode); 278 Handle<Map> CreateSloppyFunctionMap(FunctionMode function_mode);
280 279
281 void SetFunctionInstanceDescriptor(Handle<Map> map, 280 void SetFunctionInstanceDescriptor(Handle<Map> map,
282 FunctionMode function_mode); 281 FunctionMode function_mode);
283 void MakeFunctionInstancePrototypeWritable(); 282 void MakeFunctionInstancePrototypeWritable();
284 283
285 Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode, 284 Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode,
286 Handle<JSFunction> empty_function); 285 Handle<JSFunction> empty_function);
287 Handle<Map> CreateStrongFunctionMap(Handle<JSFunction> empty_function,
288 bool is_constructor);
289 286
290 287
291 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, 288 void SetStrictFunctionInstanceDescriptor(Handle<Map> map,
292 FunctionMode function_mode); 289 FunctionMode function_mode);
293 void SetStrongFunctionInstanceDescriptor(Handle<Map> map); 290 void SetStrongFunctionInstanceDescriptor(Handle<Map> map);
294 291
295 static bool CallUtilsFunction(Isolate* isolate, const char* name); 292 static bool CallUtilsFunction(Isolate* isolate, const char* name);
296 293
297 static bool CompileExtension(Isolate* isolate, v8::Extension* extension); 294 static bool CompileExtension(Isolate* isolate, v8::Extension* extension);
298 295
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 map->set_is_prototype_map(true); 537 map->set_is_prototype_map(true);
541 object_function_prototype->set_map(*map); 538 object_function_prototype->set_map(*map);
542 539
543 native_context()->set_initial_object_prototype(*object_function_prototype); 540 native_context()->set_initial_object_prototype(*object_function_prototype);
544 // For bootstrapping set the array prototype to be the same as the object 541 // For bootstrapping set the array prototype to be the same as the object
545 // prototype, otherwise the missing initial_array_prototype will cause 542 // prototype, otherwise the missing initial_array_prototype will cause
546 // assertions during startup. 543 // assertions during startup.
547 native_context()->set_initial_array_prototype(*object_function_prototype); 544 native_context()->set_initial_array_prototype(*object_function_prototype);
548 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) 545 Accessors::FunctionSetPrototype(object_fun, object_function_prototype)
549 .Assert(); 546 .Assert();
550
551 // Allocate initial strong object map.
552 Handle<Map> strong_object_map =
553 Map::Copy(Handle<Map>(object_fun->initial_map()), "EmptyStrongObject");
554 strong_object_map->set_is_strong();
555 native_context()->set_js_object_strong_map(*strong_object_map);
556 } 547 }
557 548
558 // Allocate the empty function as the prototype for function - ES6 19.2.3 549 // Allocate the empty function as the prototype for function - ES6 19.2.3
559 Handle<Code> code(isolate->builtins()->EmptyFunction()); 550 Handle<Code> code(isolate->builtins()->EmptyFunction());
560 Handle<JSFunction> empty_function = 551 Handle<JSFunction> empty_function =
561 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); 552 factory->NewFunctionWithoutPrototype(factory->empty_string(), code);
562 553
563 // Allocate the function map first and then patch the prototype later 554 // Allocate the function map first and then patch the prototype later
564 Handle<Map> empty_function_map = 555 Handle<Map> empty_function_map =
565 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 556 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 FunctionMode function_mode, Handle<JSFunction> empty_function) { 706 FunctionMode function_mode, Handle<JSFunction> empty_function) {
716 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 707 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
717 SetStrictFunctionInstanceDescriptor(map, function_mode); 708 SetStrictFunctionInstanceDescriptor(map, function_mode);
718 map->set_is_constructor(IsFunctionModeWithPrototype(function_mode)); 709 map->set_is_constructor(IsFunctionModeWithPrototype(function_mode));
719 map->set_is_callable(); 710 map->set_is_callable();
720 Map::SetPrototype(map, empty_function); 711 Map::SetPrototype(map, empty_function);
721 return map; 712 return map;
722 } 713 }
723 714
724 715
725 Handle<Map> Genesis::CreateStrongFunctionMap(
726 Handle<JSFunction> empty_function, bool is_constructor) {
727 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
728 SetStrongFunctionInstanceDescriptor(map);
729 map->set_is_constructor(is_constructor);
730 Map::SetPrototype(map, empty_function);
731 map->set_is_callable();
732 map->set_is_extensible(is_constructor);
733 map->set_is_strong();
734 return map;
735 }
736
737
738 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { 716 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
739 // Allocate map for the prototype-less strict mode instances. 717 // Allocate map for the prototype-less strict mode instances.
740 Handle<Map> strict_function_without_prototype_map = 718 Handle<Map> strict_function_without_prototype_map =
741 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); 719 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
742 native_context()->set_strict_function_without_prototype_map( 720 native_context()->set_strict_function_without_prototype_map(
743 *strict_function_without_prototype_map); 721 *strict_function_without_prototype_map);
744 722
745 // Allocate map for the strict mode functions. This map is temporary, used 723 // Allocate map for the strict mode functions. This map is temporary, used
746 // only for processing of builtins. 724 // only for processing of builtins.
747 // Later the map is replaced with writable prototype map, allocated below. 725 // Later the map is replaced with writable prototype map, allocated below.
748 Handle<Map> strict_function_map = 726 Handle<Map> strict_function_map =
749 CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty); 727 CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty);
750 native_context()->set_strict_function_map(*strict_function_map); 728 native_context()->set_strict_function_map(*strict_function_map);
751 729
752 // The final map for the strict mode functions. Writeable prototype. 730 // The final map for the strict mode functions. Writeable prototype.
753 // This map is installed in MakeFunctionInstancePrototypeWritable. 731 // This map is installed in MakeFunctionInstancePrototypeWritable.
754 strict_function_map_writable_prototype_ = 732 strict_function_map_writable_prototype_ =
755 CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty); 733 CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty);
756 } 734 }
757 735
758 736
759 void Genesis::CreateStrongModeFunctionMaps(Handle<JSFunction> empty) {
760 // Allocate map for strong mode instances, which never have prototypes.
761 Handle<Map> strong_function_map = CreateStrongFunctionMap(empty, false);
762 native_context()->set_strong_function_map(*strong_function_map);
763 // Constructors do, though.
764 Handle<Map> strong_constructor_map = CreateStrongFunctionMap(empty, true);
765 native_context()->set_strong_constructor_map(*strong_constructor_map);
766 }
767
768
769 void Genesis::CreateIteratorMaps() { 737 void Genesis::CreateIteratorMaps() {
770 // Create iterator-related meta-objects. 738 // Create iterator-related meta-objects.
771 Handle<JSObject> iterator_prototype = 739 Handle<JSObject> iterator_prototype =
772 factory()->NewJSObject(isolate()->object_function(), TENURED); 740 factory()->NewJSObject(isolate()->object_function(), TENURED);
773 Handle<JSObject> generator_object_prototype = 741 Handle<JSObject> generator_object_prototype =
774 factory()->NewJSObject(isolate()->object_function(), TENURED); 742 factory()->NewJSObject(isolate()->object_function(), TENURED);
775 Handle<JSObject> generator_function_prototype = 743 Handle<JSObject> generator_function_prototype =
776 factory()->NewJSObject(isolate()->object_function(), TENURED); 744 factory()->NewJSObject(isolate()->object_function(), TENURED);
777 SetObjectPrototype(generator_object_prototype, iterator_prototype); 745 SetObjectPrototype(generator_object_prototype, iterator_prototype);
778 746
(...skipping 17 matching lines...) Expand all
796 *sloppy_generator_function_map); 764 *sloppy_generator_function_map);
797 765
798 Handle<Map> strict_generator_function_map = 766 Handle<Map> strict_generator_function_map =
799 Map::Copy(strict_function_map, "StrictGeneratorFunction"); 767 Map::Copy(strict_function_map, "StrictGeneratorFunction");
800 strict_generator_function_map->set_is_constructor(false); 768 strict_generator_function_map->set_is_constructor(false);
801 Map::SetPrototype(strict_generator_function_map, 769 Map::SetPrototype(strict_generator_function_map,
802 generator_function_prototype); 770 generator_function_prototype);
803 native_context()->set_strict_generator_function_map( 771 native_context()->set_strict_generator_function_map(
804 *strict_generator_function_map); 772 *strict_generator_function_map);
805 773
806 Handle<Map> strong_function_map(native_context()->strong_function_map());
807 Handle<Map> strong_generator_function_map =
808 Map::Copy(strong_function_map, "StrongGeneratorFunction");
809 strong_generator_function_map->set_is_constructor(false);
810 Map::SetPrototype(strong_generator_function_map,
811 generator_function_prototype);
812 native_context()->set_strong_generator_function_map(
813 *strong_generator_function_map);
814
815 Handle<JSFunction> object_function(native_context()->object_function()); 774 Handle<JSFunction> object_function(native_context()->object_function());
816 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); 775 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
817 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); 776 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype);
818 native_context()->set_generator_object_prototype_map( 777 native_context()->set_generator_object_prototype_map(
819 *generator_object_prototype_map); 778 *generator_object_prototype_map);
820 } 779 }
821 780
822 781
823 static void ReplaceAccessors(Handle<Map> map, 782 static void ReplaceAccessors(Handle<Map> map,
824 Handle<String> name, 783 Handle<String> name,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1126
1168 // Install in the native context 1127 // Install in the native context
1169 native_context()->set_ordinary_has_instance(*has_instance); 1128 native_context()->set_ordinary_has_instance(*has_instance);
1170 1129
1171 // Install the "constructor" property on the %FunctionPrototype%. 1130 // Install the "constructor" property on the %FunctionPrototype%.
1172 JSObject::AddProperty(prototype, factory->constructor_string(), 1131 JSObject::AddProperty(prototype, factory->constructor_string(),
1173 function_fun, DONT_ENUM); 1132 function_fun, DONT_ENUM);
1174 1133
1175 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); 1134 sloppy_function_map_writable_prototype_->SetConstructor(*function_fun);
1176 strict_function_map_writable_prototype_->SetConstructor(*function_fun); 1135 strict_function_map_writable_prototype_->SetConstructor(*function_fun);
1177 native_context()->strong_function_map()->SetConstructor(*function_fun);
1178 } 1136 }
1179 1137
1180 { // --- A r r a y --- 1138 { // --- A r r a y ---
1181 Handle<JSFunction> array_function = 1139 Handle<JSFunction> array_function =
1182 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 1140 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
1183 isolate->initial_object_prototype(), 1141 isolate->initial_object_prototype(),
1184 Builtins::kArrayCode); 1142 Builtins::kArrayCode);
1185 array_function->shared()->DontAdaptArguments(); 1143 array_function->shared()->DontAdaptArguments();
1186 array_function->shared()->set_builtin_function_id(kArrayCode); 1144 array_function->shared()->set_builtin_function_id(kArrayCode);
1187 1145
(...skipping 22 matching lines...) Expand all
1210 1168
1211 InstallWithIntrinsicDefaultProto(isolate, array_function, 1169 InstallWithIntrinsicDefaultProto(isolate, array_function,
1212 Context::ARRAY_FUNCTION_INDEX); 1170 Context::ARRAY_FUNCTION_INDEX);
1213 1171
1214 // Cache the array maps, needed by ArrayConstructorStub 1172 // Cache the array maps, needed by ArrayConstructorStub
1215 CacheInitialJSArrayMaps(native_context(), initial_map); 1173 CacheInitialJSArrayMaps(native_context(), initial_map);
1216 ArrayConstructorStub array_constructor_stub(isolate); 1174 ArrayConstructorStub array_constructor_stub(isolate);
1217 Handle<Code> code = array_constructor_stub.GetCode(); 1175 Handle<Code> code = array_constructor_stub.GetCode();
1218 array_function->shared()->set_construct_stub(*code); 1176 array_function->shared()->set_construct_stub(*code);
1219 1177
1220 Handle<Map> initial_strong_map =
1221 Map::Copy(initial_map, "SetInstancePrototype");
1222 initial_strong_map->set_is_strong();
1223 CacheInitialJSArrayMaps(native_context(), initial_strong_map);
1224
1225 Handle<JSFunction> is_arraylike = SimpleInstallFunction( 1178 Handle<JSFunction> is_arraylike = SimpleInstallFunction(
1226 array_function, isolate->factory()->InternalizeUtf8String("isArray"), 1179 array_function, isolate->factory()->InternalizeUtf8String("isArray"),
1227 Builtins::kArrayIsArray, 1, true); 1180 Builtins::kArrayIsArray, 1, true);
1228 native_context()->set_is_arraylike(*is_arraylike); 1181 native_context()->set_is_arraylike(*is_arraylike);
1229 } 1182 }
1230 1183
1231 { // --- N u m b e r --- 1184 { // --- N u m b e r ---
1232 Handle<JSFunction> number_fun = InstallFunction( 1185 Handle<JSFunction> number_fun = InstallFunction(
1233 global, "Number", JS_VALUE_TYPE, JSValue::kSize, 1186 global, "Number", JS_VALUE_TYPE, JSValue::kSize,
1234 isolate->initial_object_prototype(), Builtins::kNumberConstructor); 1187 isolate->initial_object_prototype(), Builtins::kNumberConstructor);
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 *isolate->builtins()->GeneratorFunctionConstructor()); 2083 *isolate->builtins()->GeneratorFunctionConstructor());
2131 generator_function_function->shared()->set_length(1); 2084 generator_function_function->shared()->set_length(1);
2132 InstallWithIntrinsicDefaultProto( 2085 InstallWithIntrinsicDefaultProto(
2133 isolate, generator_function_function, 2086 isolate, generator_function_function,
2134 Context::GENERATOR_FUNCTION_FUNCTION_INDEX); 2087 Context::GENERATOR_FUNCTION_FUNCTION_INDEX);
2135 2088
2136 native_context->sloppy_generator_function_map()->SetConstructor( 2089 native_context->sloppy_generator_function_map()->SetConstructor(
2137 *generator_function_function); 2090 *generator_function_function);
2138 native_context->strict_generator_function_map()->SetConstructor( 2091 native_context->strict_generator_function_map()->SetConstructor(
2139 *generator_function_function); 2092 *generator_function_function);
2140 native_context->strong_generator_function_map()->SetConstructor(
2141 *generator_function_function);
2142 } 2093 }
2143 2094
2144 { // -- S e t I t e r a t o r 2095 { // -- S e t I t e r a t o r
2145 Handle<JSObject> set_iterator_prototype = 2096 Handle<JSObject> set_iterator_prototype =
2146 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 2097 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
2147 SetObjectPrototype(set_iterator_prototype, iterator_prototype); 2098 SetObjectPrototype(set_iterator_prototype, iterator_prototype);
2148 Handle<JSFunction> set_iterator_function = InstallFunction( 2099 Handle<JSFunction> set_iterator_function = InstallFunction(
2149 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 2100 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
2150 set_iterator_prototype, Builtins::kIllegal); 2101 set_iterator_prototype, Builtins::kIllegal);
2151 native_context->set_set_iterator_map(set_iterator_function->initial_map()); 2102 native_context->set_set_iterator_map(set_iterator_function->initial_map());
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 3547
3597 HookUpGlobalProxy(global_object, global_proxy); 3548 HookUpGlobalProxy(global_object, global_proxy);
3598 HookUpGlobalObject(global_object); 3549 HookUpGlobalObject(global_object);
3599 3550
3600 if (!ConfigureGlobalObjects(global_proxy_template)) return; 3551 if (!ConfigureGlobalObjects(global_proxy_template)) return;
3601 } else { 3552 } else {
3602 // We get here if there was no context snapshot. 3553 // We get here if there was no context snapshot.
3603 CreateRoots(); 3554 CreateRoots();
3604 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); 3555 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
3605 CreateStrictModeFunctionMaps(empty_function); 3556 CreateStrictModeFunctionMaps(empty_function);
3606 CreateStrongModeFunctionMaps(empty_function);
3607 CreateIteratorMaps(); 3557 CreateIteratorMaps();
3608 Handle<JSGlobalObject> global_object = 3558 Handle<JSGlobalObject> global_object =
3609 CreateNewGlobals(global_proxy_template, global_proxy); 3559 CreateNewGlobals(global_proxy_template, global_proxy);
3610 HookUpGlobalProxy(global_object, global_proxy); 3560 HookUpGlobalProxy(global_object, global_proxy);
3611 InitializeGlobal(global_object, empty_function, context_type); 3561 InitializeGlobal(global_object, empty_function, context_type);
3612 InitializeNormalizedMapCaches(); 3562 InitializeNormalizedMapCaches();
3613 3563
3614 if (!InstallNatives(context_type)) return; 3564 if (!InstallNatives(context_type)) return;
3615 3565
3616 MakeFunctionInstancePrototypeWritable(); 3566 MakeFunctionInstancePrototypeWritable();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3680 } 3630 }
3681 3631
3682 3632
3683 // Called when the top-level V8 mutex is destroyed. 3633 // Called when the top-level V8 mutex is destroyed.
3684 void Bootstrapper::FreeThreadResources() { 3634 void Bootstrapper::FreeThreadResources() {
3685 DCHECK(!IsActive()); 3635 DCHECK(!IsActive());
3686 } 3636 }
3687 3637
3688 } // namespace internal 3638 } // namespace internal
3689 } // namespace v8 3639 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698