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

Side by Side Diff: src/bootstrapper.cc

Issue 261963003: Always set the class name on installed functions if the target is the JSGlobal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 global_proxy->set_native_context(*factory->null_value()); 344 global_proxy->set_native_context(*factory->null_value());
345 SetObjectPrototype(global_proxy, factory->null_value()); 345 SetObjectPrototype(global_proxy, factory->null_value());
346 } 346 }
347 347
348 348
349 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, 349 static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
350 const char* name, 350 const char* name,
351 InstanceType type, 351 InstanceType type,
352 int instance_size, 352 int instance_size,
353 MaybeHandle<JSObject> maybe_prototype, 353 MaybeHandle<JSObject> maybe_prototype,
354 Builtins::Name call, 354 Builtins::Name call) {
355 bool set_instance_class_name) {
356 Isolate* isolate = target->GetIsolate(); 355 Isolate* isolate = target->GetIsolate();
357 Factory* factory = isolate->factory(); 356 Factory* factory = isolate->factory();
358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); 357 Handle<String> internalized_name = factory->InternalizeUtf8String(name);
359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); 358 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
360 Handle<JSObject> prototype; 359 Handle<JSObject> prototype;
361 Handle<JSFunction> function = maybe_prototype.ToHandle(&prototype) 360 Handle<JSFunction> function = maybe_prototype.ToHandle(&prototype)
362 ? factory->NewFunction(prototype, internalized_name, type, 361 ? factory->NewFunction(prototype, internalized_name, type,
363 instance_size, call_code) 362 instance_size, call_code)
364 : factory->NewFunction(internalized_name, call_code); 363 : factory->NewFunction(internalized_name, call_code);
365 PropertyAttributes attributes; 364 PropertyAttributes attributes;
366 if (target->IsJSBuiltinsObject()) { 365 if (target->IsJSBuiltinsObject()) {
367 attributes = 366 attributes =
368 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 367 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
369 } else { 368 } else {
370 attributes = DONT_ENUM; 369 attributes = DONT_ENUM;
371 } 370 }
372 JSObject::SetLocalPropertyIgnoreAttributes( 371 JSObject::SetLocalPropertyIgnoreAttributes(
373 target, internalized_name, function, attributes).Check(); 372 target, internalized_name, function, attributes).Check();
374 if (set_instance_class_name) { 373 if (target->IsJSGlobalObject()) {
375 function->shared()->set_instance_class_name(*internalized_name); 374 function->shared()->set_instance_class_name(*internalized_name);
376 } 375 }
377 function->shared()->set_native(true); 376 function->shared()->set_native(true);
378 return function; 377 return function;
379 } 378 }
380 379
381 380
382 void Genesis::SetFunctionInstanceDescriptor( 381 void Genesis::SetFunctionInstanceDescriptor(
383 Handle<Map> map, PrototypePropertyMode prototypeMode) { 382 Handle<Map> map, PrototypePropertyMode prototypeMode) {
384 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 383 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 826
828 Isolate* isolate = inner_global->GetIsolate(); 827 Isolate* isolate = inner_global->GetIsolate();
829 Factory* factory = isolate->factory(); 828 Factory* factory = isolate->factory();
830 Heap* heap = isolate->heap(); 829 Heap* heap = isolate->heap();
831 830
832 Handle<String> object_name = factory->Object_string(); 831 Handle<String> object_name = factory->Object_string();
833 JSObject::SetLocalPropertyIgnoreAttributes( 832 JSObject::SetLocalPropertyIgnoreAttributes(
834 inner_global, object_name, 833 inner_global, object_name,
835 isolate->object_function(), DONT_ENUM).Check(); 834 isolate->object_function(), DONT_ENUM).Check();
836 835
837 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 836 Handle<JSObject> global(native_context()->global_object());
838 837
839 // Install global Function object 838 // Install global Function object
840 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 839 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
841 empty_function, Builtins::kIllegal, true); 840 empty_function, Builtins::kIllegal);
842 841
843 { // --- A r r a y --- 842 { // --- A r r a y ---
844 Handle<JSFunction> array_function = 843 Handle<JSFunction> array_function =
845 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 844 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
846 isolate->initial_object_prototype(), 845 isolate->initial_object_prototype(),
847 Builtins::kArrayCode, true); 846 Builtins::kArrayCode);
848 array_function->shared()->DontAdaptArguments(); 847 array_function->shared()->DontAdaptArguments();
849 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); 848 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode));
850 849
851 // This seems a bit hackish, but we need to make sure Array.length 850 // This seems a bit hackish, but we need to make sure Array.length
852 // is 1. 851 // is 1.
853 array_function->shared()->set_length(1); 852 array_function->shared()->set_length(1);
854 853
855 Handle<Map> initial_map(array_function->initial_map()); 854 Handle<Map> initial_map(array_function->initial_map());
856 855
857 // This assert protects an optimization in 856 // This assert protects an optimization in
(...skipping 23 matching lines...) Expand all
881 CacheInitialJSArrayMaps(native_context(), initial_map); 880 CacheInitialJSArrayMaps(native_context(), initial_map);
882 ArrayConstructorStub array_constructor_stub(isolate); 881 ArrayConstructorStub array_constructor_stub(isolate);
883 Handle<Code> code = array_constructor_stub.GetCode(); 882 Handle<Code> code = array_constructor_stub.GetCode();
884 array_function->shared()->set_construct_stub(*code); 883 array_function->shared()->set_construct_stub(*code);
885 } 884 }
886 885
887 { // --- N u m b e r --- 886 { // --- N u m b e r ---
888 Handle<JSFunction> number_fun = 887 Handle<JSFunction> number_fun =
889 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, 888 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
890 isolate->initial_object_prototype(), 889 isolate->initial_object_prototype(),
891 Builtins::kIllegal, true); 890 Builtins::kIllegal);
892 native_context()->set_number_function(*number_fun); 891 native_context()->set_number_function(*number_fun);
893 } 892 }
894 893
895 { // --- B o o l e a n --- 894 { // --- B o o l e a n ---
896 Handle<JSFunction> boolean_fun = 895 Handle<JSFunction> boolean_fun =
897 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, 896 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
898 isolate->initial_object_prototype(), 897 isolate->initial_object_prototype(),
899 Builtins::kIllegal, true); 898 Builtins::kIllegal);
900 native_context()->set_boolean_function(*boolean_fun); 899 native_context()->set_boolean_function(*boolean_fun);
901 } 900 }
902 901
903 { // --- S t r i n g --- 902 { // --- S t r i n g ---
904 Handle<JSFunction> string_fun = 903 Handle<JSFunction> string_fun =
905 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, 904 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
906 isolate->initial_object_prototype(), 905 isolate->initial_object_prototype(),
907 Builtins::kIllegal, true); 906 Builtins::kIllegal);
908 string_fun->shared()->set_construct_stub( 907 string_fun->shared()->set_construct_stub(
909 isolate->builtins()->builtin(Builtins::kStringConstructCode)); 908 isolate->builtins()->builtin(Builtins::kStringConstructCode));
910 native_context()->set_string_function(*string_fun); 909 native_context()->set_string_function(*string_fun);
911 910
912 Handle<Map> string_map = 911 Handle<Map> string_map =
913 Handle<Map>(native_context()->string_function()->initial_map()); 912 Handle<Map>(native_context()->string_function()->initial_map());
914 Map::EnsureDescriptorSlack(string_map, 1); 913 Map::EnsureDescriptorSlack(string_map, 1);
915 914
916 PropertyAttributes attribs = static_cast<PropertyAttributes>( 915 PropertyAttributes attribs = static_cast<PropertyAttributes>(
917 DONT_ENUM | DONT_DELETE | READ_ONLY); 916 DONT_ENUM | DONT_DELETE | READ_ONLY);
918 Handle<AccessorInfo> string_length( 917 Handle<AccessorInfo> string_length(
919 Accessors::StringLengthInfo(isolate, attribs)); 918 Accessors::StringLengthInfo(isolate, attribs));
920 919
921 { // Add length. 920 { // Add length.
922 CallbacksDescriptor d(factory->length_string(), string_length, attribs); 921 CallbacksDescriptor d(factory->length_string(), string_length, attribs);
923 string_map->AppendDescriptor(&d); 922 string_map->AppendDescriptor(&d);
924 } 923 }
925 } 924 }
926 925
927 { // --- D a t e --- 926 { // --- D a t e ---
928 // Builtin functions for Date.prototype. 927 // Builtin functions for Date.prototype.
929 Handle<JSFunction> date_fun = 928 Handle<JSFunction> date_fun =
930 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, 929 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize,
931 isolate->initial_object_prototype(), 930 isolate->initial_object_prototype(),
932 Builtins::kIllegal, true); 931 Builtins::kIllegal);
933 932
934 native_context()->set_date_function(*date_fun); 933 native_context()->set_date_function(*date_fun);
935 } 934 }
936 935
937 936
938 { // -- R e g E x p 937 { // -- R e g E x p
939 // Builtin functions for RegExp.prototype. 938 // Builtin functions for RegExp.prototype.
940 Handle<JSFunction> regexp_fun = 939 Handle<JSFunction> regexp_fun =
941 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, 940 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
942 isolate->initial_object_prototype(), 941 isolate->initial_object_prototype(),
943 Builtins::kIllegal, true); 942 Builtins::kIllegal);
944 native_context()->set_regexp_function(*regexp_fun); 943 native_context()->set_regexp_function(*regexp_fun);
945 944
946 ASSERT(regexp_fun->has_initial_map()); 945 ASSERT(regexp_fun->has_initial_map());
947 Handle<Map> initial_map(regexp_fun->initial_map()); 946 Handle<Map> initial_map(regexp_fun->initial_map());
948 947
949 ASSERT_EQ(0, initial_map->inobject_properties()); 948 ASSERT_EQ(0, initial_map->inobject_properties());
950 949
951 PropertyAttributes final = 950 PropertyAttributes final =
952 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 951 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
953 Map::EnsureDescriptorSlack(initial_map, 5); 952 Map::EnsureDescriptorSlack(initial_map, 5);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 global, name, json_object, DONT_ENUM).Check(); 1034 global, name, json_object, DONT_ENUM).Check();
1036 native_context()->set_json_object(*json_object); 1035 native_context()->set_json_object(*json_object);
1037 } 1036 }
1038 1037
1039 { // -- A r r a y B u f f e r 1038 { // -- A r r a y B u f f e r
1040 Handle<JSFunction> array_buffer_fun = 1039 Handle<JSFunction> array_buffer_fun =
1041 InstallFunction( 1040 InstallFunction(
1042 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, 1041 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
1043 JSArrayBuffer::kSizeWithInternalFields, 1042 JSArrayBuffer::kSizeWithInternalFields,
1044 isolate->initial_object_prototype(), 1043 isolate->initial_object_prototype(),
1045 Builtins::kIllegal, true); 1044 Builtins::kIllegal);
1046 native_context()->set_array_buffer_fun(*array_buffer_fun); 1045 native_context()->set_array_buffer_fun(*array_buffer_fun);
1047 } 1046 }
1048 1047
1049 { // -- T y p e d A r r a y s 1048 { // -- T y p e d A r r a y s
1050 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ 1049 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1051 { \ 1050 { \
1052 Handle<JSFunction> fun; \ 1051 Handle<JSFunction> fun; \
1053 Handle<Map> external_map; \ 1052 Handle<Map> external_map; \
1054 InstallTypedArray(#Type "Array", \ 1053 InstallTypedArray(#Type "Array", \
1055 TYPE##_ELEMENTS, \ 1054 TYPE##_ELEMENTS, \
1056 &fun, \ 1055 &fun, \
1057 &external_map); \ 1056 &external_map); \
1058 native_context()->set_##type##_array_fun(*fun); \ 1057 native_context()->set_##type##_array_fun(*fun); \
1059 native_context()->set_##type##_array_external_map(*external_map); \ 1058 native_context()->set_##type##_array_external_map(*external_map); \
1060 } 1059 }
1061 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) 1060 TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
1062 #undef INSTALL_TYPED_ARRAY 1061 #undef INSTALL_TYPED_ARRAY
1063 1062
1064 Handle<JSFunction> data_view_fun = 1063 Handle<JSFunction> data_view_fun =
1065 InstallFunction( 1064 InstallFunction(
1066 global, "DataView", JS_DATA_VIEW_TYPE, 1065 global, "DataView", JS_DATA_VIEW_TYPE,
1067 JSDataView::kSizeWithInternalFields, 1066 JSDataView::kSizeWithInternalFields,
1068 isolate->initial_object_prototype(), 1067 isolate->initial_object_prototype(),
1069 Builtins::kIllegal, true); 1068 Builtins::kIllegal);
1070 native_context()->set_data_view_fun(*data_view_fun); 1069 native_context()->set_data_view_fun(*data_view_fun);
1071 } 1070 }
1072 1071
1073 // -- W e a k M a p 1072 // -- W e a k M a p
1074 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, 1073 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
1075 isolate->initial_object_prototype(), 1074 isolate->initial_object_prototype(), Builtins::kIllegal);
1076 Builtins::kIllegal, true);
1077 // -- W e a k S e t 1075 // -- W e a k S e t
1078 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, 1076 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
1079 isolate->initial_object_prototype(), 1077 isolate->initial_object_prototype(), Builtins::kIllegal);
1080 Builtins::kIllegal, true);
1081 1078
1082 { // --- arguments_boilerplate_ 1079 { // --- arguments_boilerplate_
1083 // Make sure we can recognize argument objects at runtime. 1080 // Make sure we can recognize argument objects at runtime.
1084 // This is done by introducing an anonymous function with 1081 // This is done by introducing an anonymous function with
1085 // class_name equals 'Arguments'. 1082 // class_name equals 'Arguments'.
1086 Handle<String> arguments_string = factory->InternalizeOneByteString( 1083 Handle<String> arguments_string = factory->InternalizeOneByteString(
1087 STATIC_ASCII_VECTOR("Arguments")); 1084 STATIC_ASCII_VECTOR("Arguments"));
1088 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); 1085 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
1089 1086
1090 Handle<JSFunction> function = factory->NewFunction(arguments_string, code); 1087 Handle<JSFunction> function = factory->NewFunction(arguments_string, code);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 native_context()->set_embedder_data(*embedder_data); 1261 native_context()->set_embedder_data(*embedder_data);
1265 } 1262 }
1266 1263
1267 1264
1268 void Genesis::InstallTypedArray( 1265 void Genesis::InstallTypedArray(
1269 const char* name, 1266 const char* name,
1270 ElementsKind elements_kind, 1267 ElementsKind elements_kind,
1271 Handle<JSFunction>* fun, 1268 Handle<JSFunction>* fun,
1272 Handle<Map>* external_map) { 1269 Handle<Map>* external_map) {
1273 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 1270 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1274 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, 1271 Handle<JSFunction> result = InstallFunction(
1275 JSTypedArray::kSize, isolate()->initial_object_prototype(), 1272 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
1276 Builtins::kIllegal, true); 1273 isolate()->initial_object_prototype(), Builtins::kIllegal);
1277 1274
1278 Handle<Map> initial_map = isolate()->factory()->NewMap( 1275 Handle<Map> initial_map = isolate()->factory()->NewMap(
1279 JS_TYPED_ARRAY_TYPE, 1276 JS_TYPED_ARRAY_TYPE,
1280 JSTypedArray::kSizeWithInternalFields, 1277 JSTypedArray::kSizeWithInternalFields,
1281 elements_kind); 1278 elements_kind);
1282 result->set_initial_map(*initial_map); 1279 result->set_initial_map(*initial_map);
1283 initial_map->set_constructor(*result); 1280 initial_map->set_constructor(*result);
1284 *fun = result; 1281 *fun = result;
1285 1282
1286 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); 1283 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind);
1287 *external_map = Map::AsElementsKind(initial_map, external_kind); 1284 *external_map = Map::AsElementsKind(initial_map, external_kind);
1288 } 1285 }
1289 1286
1290 1287
1291 void Genesis::InitializeExperimentalGlobal() { 1288 void Genesis::InitializeExperimentalGlobal() {
1292 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 1289 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1293 1290
1294 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no 1291 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no
1295 // longer need to live behind flags, so functions get added to the snapshot. 1292 // longer need to live behind flags, so functions get added to the snapshot.
1296 1293
1297 if (FLAG_harmony_symbols) { 1294 if (FLAG_harmony_symbols) {
1298 // --- S y m b o l --- 1295 // --- S y m b o l ---
1299 Handle<JSFunction> symbol_fun = 1296 Handle<JSFunction> symbol_fun = InstallFunction(
1300 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1297 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
1301 isolate()->initial_object_prototype(), 1298 isolate()->initial_object_prototype(), Builtins::kIllegal);
1302 Builtins::kIllegal, true);
1303 native_context()->set_symbol_function(*symbol_fun); 1299 native_context()->set_symbol_function(*symbol_fun);
1304 } 1300 }
1305 1301
1306 if (FLAG_harmony_collections) { 1302 if (FLAG_harmony_collections) {
1307 // -- M a p 1303 // -- M a p
1308 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, 1304 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize,
1309 isolate()->initial_object_prototype(), 1305 isolate()->initial_object_prototype(), Builtins::kIllegal);
1310 Builtins::kIllegal, true);
1311 // -- S e t 1306 // -- S e t
1312 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, 1307 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize,
1313 isolate()->initial_object_prototype(), 1308 isolate()->initial_object_prototype(), Builtins::kIllegal);
1314 Builtins::kIllegal, true);
1315 { // -- S e t I t e r a t o r 1309 { // -- S e t I t e r a t o r
1316 Handle<Map> map = isolate()->factory()->NewMap( 1310 Handle<Map> map = isolate()->factory()->NewMap(
1317 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); 1311 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize);
1318 native_context()->set_set_iterator_map(*map); 1312 native_context()->set_set_iterator_map(*map);
1319 } 1313 }
1320 { // -- M a p I t e r a t o r 1314 { // -- M a p I t e r a t o r
1321 Handle<Map> map = isolate()->factory()->NewMap( 1315 Handle<Map> map = isolate()->factory()->NewMap(
1322 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); 1316 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize);
1323 native_context()->set_map_iterator_map(*map); 1317 native_context()->set_map_iterator_map(*map);
1324 } 1318 }
1325 } 1319 }
1326 1320
1327 if (FLAG_harmony_generators) { 1321 if (FLAG_harmony_generators) {
1328 // Create generator meta-objects and install them on the builtins object. 1322 // Create generator meta-objects and install them on the builtins object.
1329 Handle<JSObject> builtins(native_context()->builtins()); 1323 Handle<JSObject> builtins(native_context()->builtins());
1330 Handle<JSObject> generator_object_prototype = 1324 Handle<JSObject> generator_object_prototype =
1331 factory()->NewJSObject(isolate()->object_function(), TENURED); 1325 factory()->NewJSObject(isolate()->object_function(), TENURED);
1332 Handle<JSFunction> generator_function_prototype = 1326 Handle<JSFunction> generator_function_prototype = InstallFunction(
1333 InstallFunction(builtins, "GeneratorFunctionPrototype", 1327 builtins, "GeneratorFunctionPrototype", JS_FUNCTION_TYPE,
1334 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, 1328 JSFunction::kHeaderSize, generator_object_prototype,
1335 generator_object_prototype, Builtins::kIllegal, false); 1329 Builtins::kIllegal);
1336 InstallFunction(builtins, "GeneratorFunction", 1330 InstallFunction(builtins, "GeneratorFunction",
1337 JS_FUNCTION_TYPE, JSFunction::kSize, 1331 JS_FUNCTION_TYPE, JSFunction::kSize,
1338 generator_function_prototype, Builtins::kIllegal, false); 1332 generator_function_prototype, Builtins::kIllegal);
1339 1333
1340 // Create maps for generator functions and their prototypes. Store those 1334 // Create maps for generator functions and their prototypes. Store those
1341 // maps in the native context. 1335 // maps in the native context.
1342 Handle<Map> function_map(native_context()->sloppy_function_map()); 1336 Handle<Map> function_map(native_context()->sloppy_function_map());
1343 Handle<Map> generator_function_map = Map::Copy(function_map); 1337 Handle<Map> generator_function_map = Map::Copy(function_map);
1344 generator_function_map->set_prototype(*generator_function_prototype); 1338 generator_function_map->set_prototype(*generator_function_prototype);
1345 native_context()->set_sloppy_generator_function_map( 1339 native_context()->set_sloppy_generator_function_map(
1346 *generator_function_map); 1340 *generator_function_map);
1347 1341
1348 Handle<Map> strict_mode_function_map( 1342 Handle<Map> strict_mode_function_map(
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 Handle<JSFunction> Genesis::InstallInternalArray( 1561 Handle<JSFunction> Genesis::InstallInternalArray(
1568 Handle<JSBuiltinsObject> builtins, 1562 Handle<JSBuiltinsObject> builtins,
1569 const char* name, 1563 const char* name,
1570 ElementsKind elements_kind) { 1564 ElementsKind elements_kind) {
1571 // --- I n t e r n a l A r r a y --- 1565 // --- I n t e r n a l A r r a y ---
1572 // An array constructor on the builtins object that works like 1566 // An array constructor on the builtins object that works like
1573 // the public Array constructor, except that its prototype 1567 // the public Array constructor, except that its prototype
1574 // doesn't inherit from Object.prototype. 1568 // doesn't inherit from Object.prototype.
1575 // To be used only for internal work by builtins. Instances 1569 // To be used only for internal work by builtins. Instances
1576 // must not be leaked to user code. 1570 // must not be leaked to user code.
1571 Handle<JSObject> prototype =
1572 factory()->NewJSObject(isolate()->object_function(), TENURED);
1577 Handle<JSFunction> array_function = InstallFunction( 1573 Handle<JSFunction> array_function = InstallFunction(
1578 builtins, name, JS_ARRAY_TYPE, JSArray::kSize, 1574 builtins, name, JS_ARRAY_TYPE, JSArray::kSize,
1579 isolate()->initial_object_prototype(), Builtins::kInternalArrayCode, 1575 prototype, Builtins::kInternalArrayCode);
1580 true);
1581 Handle<JSObject> prototype =
1582 factory()->NewJSObject(isolate()->object_function(), TENURED);
1583 Accessors::FunctionSetPrototype(array_function, prototype);
1584 1576
1585 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); 1577 InternalArrayConstructorStub internal_array_constructor_stub(isolate());
1586 Handle<Code> code = internal_array_constructor_stub.GetCode(); 1578 Handle<Code> code = internal_array_constructor_stub.GetCode();
1587 array_function->shared()->set_construct_stub(*code); 1579 array_function->shared()->set_construct_stub(*code);
1588 array_function->shared()->DontAdaptArguments(); 1580 array_function->shared()->DontAdaptArguments();
1589 1581
1590 Handle<Map> original_map(array_function->initial_map()); 1582 Handle<Map> original_map(array_function->initial_map());
1591 Handle<Map> initial_map = Map::Copy(original_map); 1583 Handle<Map> initial_map = Map::Copy(original_map);
1592 initial_map->set_elements_kind(elements_kind); 1584 initial_map->set_elements_kind(elements_kind);
1593 array_function->set_initial_map(*initial_map); 1585 array_function->set_initial_map(*initial_map);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 Handle<Context> context = 1658 Handle<Context> context =
1667 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); 1659 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1668 context->set_global_object(*builtins); // override builtins global object 1660 context->set_global_object(*builtins); // override builtins global object
1669 1661
1670 native_context()->set_runtime_context(*context); 1662 native_context()->set_runtime_context(*context);
1671 1663
1672 { // -- S c r i p t 1664 { // -- S c r i p t
1673 // Builtin functions for Script. 1665 // Builtin functions for Script.
1674 Handle<JSFunction> script_fun = InstallFunction( 1666 Handle<JSFunction> script_fun = InstallFunction(
1675 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, 1667 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
1676 isolate()->initial_object_prototype(), Builtins::kIllegal, false); 1668 isolate()->initial_object_prototype(), Builtins::kIllegal);
1677 Handle<JSObject> prototype = 1669 Handle<JSObject> prototype =
1678 factory()->NewJSObject(isolate()->object_function(), TENURED); 1670 factory()->NewJSObject(isolate()->object_function(), TENURED);
1679 Accessors::FunctionSetPrototype(script_fun, prototype); 1671 Accessors::FunctionSetPrototype(script_fun, prototype);
1680 native_context()->set_script_function(*script_fun); 1672 native_context()->set_script_function(*script_fun);
1681 1673
1682 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 1674 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1683 Map::EnsureDescriptorSlack(script_map, 13); 1675 Map::EnsureDescriptorSlack(script_map, 13);
1684 1676
1685 PropertyAttributes attribs = 1677 PropertyAttributes attribs =
1686 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1678 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 Handle<Script> script = factory()->NewScript(factory()->empty_string()); 1783 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1792 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1784 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1793 heap()->public_set_empty_script(*script); 1785 heap()->public_set_empty_script(*script);
1794 } 1786 }
1795 { 1787 {
1796 // Builtin function for OpaqueReference -- a JSValue-based object, 1788 // Builtin function for OpaqueReference -- a JSValue-based object,
1797 // that keeps its field isolated from JavaScript code. It may store 1789 // that keeps its field isolated from JavaScript code. It may store
1798 // objects, that JavaScript code may not access. 1790 // objects, that JavaScript code may not access.
1799 Handle<JSFunction> opaque_reference_fun = InstallFunction( 1791 Handle<JSFunction> opaque_reference_fun = InstallFunction(
1800 builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize, 1792 builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize,
1801 isolate()->initial_object_prototype(), Builtins::kIllegal, false); 1793 isolate()->initial_object_prototype(), Builtins::kIllegal);
1802 Handle<JSObject> prototype = 1794 Handle<JSObject> prototype =
1803 factory()->NewJSObject(isolate()->object_function(), TENURED); 1795 factory()->NewJSObject(isolate()->object_function(), TENURED);
1804 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); 1796 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype);
1805 native_context()->set_opaque_reference_function(*opaque_reference_fun); 1797 native_context()->set_opaque_reference_function(*opaque_reference_fun);
1806 } 1798 }
1807 1799
1808 // InternalArrays should not use Smi-Only array optimizations. There are too 1800 // InternalArrays should not use Smi-Only array optimizations. There are too
1809 // many places in the C++ runtime code (e.g. RegEx) that assume that 1801 // many places in the C++ runtime code (e.g. RegEx) that assume that
1810 // elements in InternalArrays can be set to non-Smi values without going 1802 // elements in InternalArrays can be set to non-Smi values without going
1811 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT 1803 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 { Handle<String> key = factory()->function_class_string(); 1842 { Handle<String> key = factory()->function_class_string();
1851 Handle<JSFunction> function = 1843 Handle<JSFunction> function =
1852 Handle<JSFunction>::cast(Object::GetProperty( 1844 Handle<JSFunction>::cast(Object::GetProperty(
1853 isolate()->global_object(), key).ToHandleChecked()); 1845 isolate()->global_object(), key).ToHandleChecked());
1854 Handle<JSObject> proto = 1846 Handle<JSObject> proto =
1855 Handle<JSObject>(JSObject::cast(function->instance_prototype())); 1847 Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1856 1848
1857 // Install the call and the apply functions. 1849 // Install the call and the apply functions.
1858 Handle<JSFunction> call = 1850 Handle<JSFunction> call =
1859 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1851 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1860 MaybeHandle<JSObject>(), 1852 MaybeHandle<JSObject>(), Builtins::kFunctionCall);
1861 Builtins::kFunctionCall, false);
1862 Handle<JSFunction> apply = 1853 Handle<JSFunction> apply =
1863 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, 1854 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1864 MaybeHandle<JSObject>(), 1855 MaybeHandle<JSObject>(), Builtins::kFunctionApply);
1865 Builtins::kFunctionApply, false);
1866 1856
1867 // Make sure that Function.prototype.call appears to be compiled. 1857 // Make sure that Function.prototype.call appears to be compiled.
1868 // The code will never be called, but inline caching for call will 1858 // The code will never be called, but inline caching for call will
1869 // only work if it appears to be compiled. 1859 // only work if it appears to be compiled.
1870 call->shared()->DontAdaptArguments(); 1860 call->shared()->DontAdaptArguments();
1871 ASSERT(call->is_compiled()); 1861 ASSERT(call->is_compiled());
1872 1862
1873 // Set the expected parameters for apply to 2; required by builtin. 1863 // Set the expected parameters for apply to 2; required by builtin.
1874 apply->shared()->set_formal_parameter_count(2); 1864 apply->shared()->set_formal_parameter_count(2);
1875 1865
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 return from + sizeof(NestingCounterType); 2649 return from + sizeof(NestingCounterType);
2660 } 2650 }
2661 2651
2662 2652
2663 // Called when the top-level V8 mutex is destroyed. 2653 // Called when the top-level V8 mutex is destroyed.
2664 void Bootstrapper::FreeThreadResources() { 2654 void Bootstrapper::FreeThreadResources() {
2665 ASSERT(!IsActive()); 2655 ASSERT(!IsActive());
2666 } 2656 }
2667 2657
2668 } } // namespace v8::internal 2658 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698