OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 { // --- arguments_boilerplate_ | 1072 { // --- arguments_boilerplate_ |
1074 // Make sure we can recognize argument objects at runtime. | 1073 // Make sure we can recognize argument objects at runtime. |
1075 // This is done by introducing an anonymous function with | 1074 // This is done by introducing an anonymous function with |
1076 // class_name equals 'Arguments'. | 1075 // class_name equals 'Arguments'. |
1077 Handle<String> arguments_string = factory->InternalizeOneByteString( | 1076 Handle<String> arguments_string = factory->InternalizeOneByteString( |
1078 STATIC_ASCII_VECTOR("Arguments")); | 1077 STATIC_ASCII_VECTOR("Arguments")); |
1079 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1078 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1255 native_context()->set_embedder_data(*embedder_data); | 1254 native_context()->set_embedder_data(*embedder_data); |
1256 } | 1255 } |
1257 | 1256 |
1258 | 1257 |
1259 void Genesis::InstallTypedArray( | 1258 void Genesis::InstallTypedArray( |
1260 const char* name, | 1259 const char* name, |
1261 ElementsKind elements_kind, | 1260 ElementsKind elements_kind, |
1262 Handle<JSFunction>* fun, | 1261 Handle<JSFunction>* fun, |
1263 Handle<Map>* external_map) { | 1262 Handle<Map>* external_map) { |
1264 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1263 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
1265 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1264 Handle<JSFunction> result = InstallFunction( |
1266 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1265 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, |
1267 Builtins::kIllegal, true); | 1266 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1268 | 1267 |
1269 Handle<Map> initial_map = isolate()->factory()->NewMap( | 1268 Handle<Map> initial_map = isolate()->factory()->NewMap( |
1270 JS_TYPED_ARRAY_TYPE, | 1269 JS_TYPED_ARRAY_TYPE, |
1271 JSTypedArray::kSizeWithInternalFields, | 1270 JSTypedArray::kSizeWithInternalFields, |
1272 elements_kind); | 1271 elements_kind); |
1273 result->set_initial_map(*initial_map); | 1272 result->set_initial_map(*initial_map); |
1274 initial_map->set_constructor(*result); | 1273 initial_map->set_constructor(*result); |
1275 *fun = result; | 1274 *fun = result; |
1276 | 1275 |
1277 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1276 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
1278 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1277 *external_map = Map::AsElementsKind(initial_map, external_kind); |
1279 } | 1278 } |
1280 | 1279 |
1281 | 1280 |
1282 void Genesis::InitializeExperimentalGlobal() { | 1281 void Genesis::InitializeExperimentalGlobal() { |
1283 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1282 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
1284 | 1283 |
1285 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no | 1284 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no |
1286 // longer need to live behind flags, so functions get added to the snapshot. | 1285 // longer need to live behind flags, so functions get added to the snapshot. |
1287 | 1286 |
1288 if (FLAG_harmony_symbols) { | 1287 if (FLAG_harmony_symbols) { |
1289 // --- S y m b o l --- | 1288 // --- S y m b o l --- |
1290 Handle<JSFunction> symbol_fun = | 1289 Handle<JSFunction> symbol_fun = InstallFunction( |
1291 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1290 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
1292 isolate()->initial_object_prototype(), | 1291 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1293 Builtins::kIllegal, true); | |
1294 native_context()->set_symbol_function(*symbol_fun); | 1292 native_context()->set_symbol_function(*symbol_fun); |
1295 } | 1293 } |
1296 | 1294 |
1297 if (FLAG_harmony_collections) { | 1295 if (FLAG_harmony_collections) { |
1298 // -- M a p | 1296 // -- M a p |
1299 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, | 1297 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, |
1300 isolate()->initial_object_prototype(), | 1298 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1301 Builtins::kIllegal, true); | |
1302 // -- S e t | 1299 // -- S e t |
1303 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, | 1300 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, |
1304 isolate()->initial_object_prototype(), | 1301 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1305 Builtins::kIllegal, true); | |
1306 { // -- S e t I t e r a t o r | 1302 { // -- S e t I t e r a t o r |
1307 Handle<Map> map = isolate()->factory()->NewMap( | 1303 Handle<Map> map = isolate()->factory()->NewMap( |
1308 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); | 1304 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); |
1309 native_context()->set_set_iterator_map(*map); | 1305 native_context()->set_set_iterator_map(*map); |
1310 } | 1306 } |
1311 { // -- M a p I t e r a t o r | 1307 { // -- M a p I t e r a t o r |
1312 Handle<Map> map = isolate()->factory()->NewMap( | 1308 Handle<Map> map = isolate()->factory()->NewMap( |
1313 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); | 1309 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); |
1314 native_context()->set_map_iterator_map(*map); | 1310 native_context()->set_map_iterator_map(*map); |
1315 } | 1311 } |
1316 } | 1312 } |
1317 | 1313 |
1318 if (FLAG_harmony_weak_collections) { | 1314 if (FLAG_harmony_weak_collections) { |
1319 // -- W e a k M a p | 1315 // -- W e a k M a p |
1320 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1316 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
1321 isolate()->initial_object_prototype(), | 1317 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1322 Builtins::kIllegal, true); | |
1323 // -- W e a k S e t | 1318 // -- W e a k S e t |
1324 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, | 1319 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, |
1325 isolate()->initial_object_prototype(), | 1320 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1326 Builtins::kIllegal, true); | |
1327 } | 1321 } |
1328 | 1322 |
1329 if (FLAG_harmony_generators) { | 1323 if (FLAG_harmony_generators) { |
1330 // Create generator meta-objects and install them on the builtins object. | 1324 // Create generator meta-objects and install them on the builtins object. |
1331 Handle<JSObject> builtins(native_context()->builtins()); | 1325 Handle<JSObject> builtins(native_context()->builtins()); |
1332 Handle<JSObject> generator_object_prototype = | 1326 Handle<JSObject> generator_object_prototype = |
1333 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1327 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1334 Handle<JSFunction> generator_function_prototype = | 1328 Handle<JSFunction> generator_function_prototype = InstallFunction( |
1335 InstallFunction(builtins, "GeneratorFunctionPrototype", | 1329 builtins, "GeneratorFunctionPrototype", JS_FUNCTION_TYPE, |
1336 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, | 1330 JSFunction::kHeaderSize, generator_object_prototype, |
1337 generator_object_prototype, Builtins::kIllegal, false); | 1331 Builtins::kIllegal); |
1338 InstallFunction(builtins, "GeneratorFunction", | 1332 InstallFunction(builtins, "GeneratorFunction", |
1339 JS_FUNCTION_TYPE, JSFunction::kSize, | 1333 JS_FUNCTION_TYPE, JSFunction::kSize, |
1340 generator_function_prototype, Builtins::kIllegal, false); | 1334 generator_function_prototype, Builtins::kIllegal); |
1341 | 1335 |
1342 // Create maps for generator functions and their prototypes. Store those | 1336 // Create maps for generator functions and their prototypes. Store those |
1343 // maps in the native context. | 1337 // maps in the native context. |
1344 Handle<Map> function_map(native_context()->sloppy_function_map()); | 1338 Handle<Map> function_map(native_context()->sloppy_function_map()); |
1345 Handle<Map> generator_function_map = Map::Copy(function_map); | 1339 Handle<Map> generator_function_map = Map::Copy(function_map); |
1346 generator_function_map->set_prototype(*generator_function_prototype); | 1340 generator_function_map->set_prototype(*generator_function_prototype); |
1347 native_context()->set_sloppy_generator_function_map( | 1341 native_context()->set_sloppy_generator_function_map( |
1348 *generator_function_map); | 1342 *generator_function_map); |
1349 | 1343 |
1350 Handle<Map> strict_mode_function_map( | 1344 Handle<Map> strict_mode_function_map( |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 const char* name, | 1564 const char* name, |
1571 ElementsKind elements_kind) { | 1565 ElementsKind elements_kind) { |
1572 // --- I n t e r n a l A r r a y --- | 1566 // --- I n t e r n a l A r r a y --- |
1573 // An array constructor on the builtins object that works like | 1567 // An array constructor on the builtins object that works like |
1574 // the public Array constructor, except that its prototype | 1568 // the public Array constructor, except that its prototype |
1575 // doesn't inherit from Object.prototype. | 1569 // doesn't inherit from Object.prototype. |
1576 // To be used only for internal work by builtins. Instances | 1570 // To be used only for internal work by builtins. Instances |
1577 // must not be leaked to user code. | 1571 // must not be leaked to user code. |
1578 Handle<JSFunction> array_function = InstallFunction( | 1572 Handle<JSFunction> array_function = InstallFunction( |
1579 builtins, name, JS_ARRAY_TYPE, JSArray::kSize, | 1573 builtins, name, JS_ARRAY_TYPE, JSArray::kSize, |
1580 isolate()->initial_object_prototype(), Builtins::kInternalArrayCode, | 1574 isolate()->initial_object_prototype(), Builtins::kInternalArrayCode); |
Igor Sheludko
2014/05/07 18:45:05
Here we skip instance_class_name initialization fo
| |
1581 true); | |
1582 Handle<JSObject> prototype = | 1575 Handle<JSObject> prototype = |
1583 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1576 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1584 Accessors::FunctionSetPrototype(array_function, prototype); | 1577 Accessors::FunctionSetPrototype(array_function, prototype); |
Igor Sheludko
2014/05/07 18:45:05
Can we pass the prototype to the InstallFunction()
| |
1585 | 1578 |
1586 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); | 1579 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); |
1587 Handle<Code> code = internal_array_constructor_stub.GetCode(); | 1580 Handle<Code> code = internal_array_constructor_stub.GetCode(); |
1588 array_function->shared()->set_construct_stub(*code); | 1581 array_function->shared()->set_construct_stub(*code); |
1589 array_function->shared()->DontAdaptArguments(); | 1582 array_function->shared()->DontAdaptArguments(); |
1590 | 1583 |
1591 Handle<Map> original_map(array_function->initial_map()); | 1584 Handle<Map> original_map(array_function->initial_map()); |
1592 Handle<Map> initial_map = Map::Copy(original_map); | 1585 Handle<Map> initial_map = Map::Copy(original_map); |
1593 initial_map->set_elements_kind(elements_kind); | 1586 initial_map->set_elements_kind(elements_kind); |
1594 array_function->set_initial_map(*initial_map); | 1587 array_function->set_initial_map(*initial_map); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1667 Handle<Context> context = | 1660 Handle<Context> context = |
1668 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1661 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
1669 context->set_global_object(*builtins); // override builtins global object | 1662 context->set_global_object(*builtins); // override builtins global object |
1670 | 1663 |
1671 native_context()->set_runtime_context(*context); | 1664 native_context()->set_runtime_context(*context); |
1672 | 1665 |
1673 { // -- S c r i p t | 1666 { // -- S c r i p t |
1674 // Builtin functions for Script. | 1667 // Builtin functions for Script. |
1675 Handle<JSFunction> script_fun = InstallFunction( | 1668 Handle<JSFunction> script_fun = InstallFunction( |
1676 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 1669 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
1677 isolate()->initial_object_prototype(), Builtins::kIllegal, false); | 1670 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1678 Handle<JSObject> prototype = | 1671 Handle<JSObject> prototype = |
1679 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1672 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1680 Accessors::FunctionSetPrototype(script_fun, prototype); | 1673 Accessors::FunctionSetPrototype(script_fun, prototype); |
1681 native_context()->set_script_function(*script_fun); | 1674 native_context()->set_script_function(*script_fun); |
1682 | 1675 |
1683 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1676 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
1684 Map::EnsureDescriptorSlack(script_map, 13); | 1677 Map::EnsureDescriptorSlack(script_map, 13); |
1685 | 1678 |
1686 PropertyAttributes attribs = | 1679 PropertyAttributes attribs = |
1687 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1680 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 Handle<Script> script = factory()->NewScript(factory()->empty_string()); | 1785 Handle<Script> script = factory()->NewScript(factory()->empty_string()); |
1793 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1786 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
1794 heap()->public_set_empty_script(*script); | 1787 heap()->public_set_empty_script(*script); |
1795 } | 1788 } |
1796 { | 1789 { |
1797 // Builtin function for OpaqueReference -- a JSValue-based object, | 1790 // Builtin function for OpaqueReference -- a JSValue-based object, |
1798 // that keeps its field isolated from JavaScript code. It may store | 1791 // that keeps its field isolated from JavaScript code. It may store |
1799 // objects, that JavaScript code may not access. | 1792 // objects, that JavaScript code may not access. |
1800 Handle<JSFunction> opaque_reference_fun = InstallFunction( | 1793 Handle<JSFunction> opaque_reference_fun = InstallFunction( |
1801 builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize, | 1794 builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize, |
1802 isolate()->initial_object_prototype(), Builtins::kIllegal, false); | 1795 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1803 Handle<JSObject> prototype = | 1796 Handle<JSObject> prototype = |
1804 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1797 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1805 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); | 1798 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); |
1806 native_context()->set_opaque_reference_function(*opaque_reference_fun); | 1799 native_context()->set_opaque_reference_function(*opaque_reference_fun); |
1807 } | 1800 } |
1808 | 1801 |
1809 // InternalArrays should not use Smi-Only array optimizations. There are too | 1802 // InternalArrays should not use Smi-Only array optimizations. There are too |
1810 // many places in the C++ runtime code (e.g. RegEx) that assume that | 1803 // many places in the C++ runtime code (e.g. RegEx) that assume that |
1811 // elements in InternalArrays can be set to non-Smi values without going | 1804 // elements in InternalArrays can be set to non-Smi values without going |
1812 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT | 1805 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1851 { Handle<String> key = factory()->function_class_string(); | 1844 { Handle<String> key = factory()->function_class_string(); |
1852 Handle<JSFunction> function = | 1845 Handle<JSFunction> function = |
1853 Handle<JSFunction>::cast(Object::GetProperty( | 1846 Handle<JSFunction>::cast(Object::GetProperty( |
1854 isolate()->global_object(), key).ToHandleChecked()); | 1847 isolate()->global_object(), key).ToHandleChecked()); |
1855 Handle<JSObject> proto = | 1848 Handle<JSObject> proto = |
1856 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 1849 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
1857 | 1850 |
1858 // Install the call and the apply functions. | 1851 // Install the call and the apply functions. |
1859 Handle<JSFunction> call = | 1852 Handle<JSFunction> call = |
1860 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1853 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1861 MaybeHandle<JSObject>(), | 1854 MaybeHandle<JSObject>(), Builtins::kFunctionCall); |
1862 Builtins::kFunctionCall, false); | |
1863 Handle<JSFunction> apply = | 1855 Handle<JSFunction> apply = |
1864 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1856 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1865 MaybeHandle<JSObject>(), | 1857 MaybeHandle<JSObject>(), Builtins::kFunctionApply); |
1866 Builtins::kFunctionApply, false); | |
1867 | 1858 |
1868 // Make sure that Function.prototype.call appears to be compiled. | 1859 // Make sure that Function.prototype.call appears to be compiled. |
1869 // The code will never be called, but inline caching for call will | 1860 // The code will never be called, but inline caching for call will |
1870 // only work if it appears to be compiled. | 1861 // only work if it appears to be compiled. |
1871 call->shared()->DontAdaptArguments(); | 1862 call->shared()->DontAdaptArguments(); |
1872 ASSERT(call->is_compiled()); | 1863 ASSERT(call->is_compiled()); |
1873 | 1864 |
1874 // Set the expected parameters for apply to 2; required by builtin. | 1865 // Set the expected parameters for apply to 2; required by builtin. |
1875 apply->shared()->set_formal_parameter_count(2); | 1866 apply->shared()->set_formal_parameter_count(2); |
1876 | 1867 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2662 return from + sizeof(NestingCounterType); | 2653 return from + sizeof(NestingCounterType); |
2663 } | 2654 } |
2664 | 2655 |
2665 | 2656 |
2666 // Called when the top-level V8 mutex is destroyed. | 2657 // Called when the top-level V8 mutex is destroyed. |
2667 void Bootstrapper::FreeThreadResources() { | 2658 void Bootstrapper::FreeThreadResources() { |
2668 ASSERT(!IsActive()); | 2659 ASSERT(!IsActive()); |
2669 } | 2660 } |
2670 | 2661 |
2671 } } // namespace v8::internal | 2662 } } // namespace v8::internal |
OLD | NEW |