| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); | 343 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); |
| 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 Handle<JSObject> prototype, | 353 MaybeHandle<JSObject> maybe_prototype, |
| 354 Builtins::Name call, | 354 Builtins::Name call, |
| 355 bool install_initial_map, | |
| 356 bool set_instance_class_name) { | 355 bool set_instance_class_name) { |
| 357 Isolate* isolate = target->GetIsolate(); | 356 Isolate* isolate = target->GetIsolate(); |
| 358 Factory* factory = isolate->factory(); | 357 Factory* factory = isolate->factory(); |
| 359 Handle<String> internalized_name = factory->InternalizeUtf8String(name); | 358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); |
| 360 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); |
| 361 Handle<JSFunction> function = prototype.is_null() | 360 Handle<JSFunction> function = factory->NewFunction( |
| 362 ? factory->NewFunction(internalized_name, call_code) | 361 maybe_prototype, internalized_name, type, instance_size, call_code, |
| 363 : factory->NewFunctionWithPrototype(internalized_name, | 362 !maybe_prototype.is_null()); |
| 364 type, | |
| 365 instance_size, | |
| 366 prototype, | |
| 367 call_code, | |
| 368 install_initial_map); | |
| 369 PropertyAttributes attributes; | 363 PropertyAttributes attributes; |
| 370 if (target->IsJSBuiltinsObject()) { | 364 if (target->IsJSBuiltinsObject()) { |
| 371 attributes = | 365 attributes = |
| 372 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 366 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 373 } else { | 367 } else { |
| 374 attributes = DONT_ENUM; | 368 attributes = DONT_ENUM; |
| 375 } | 369 } |
| 376 JSObject::SetLocalPropertyIgnoreAttributes( | 370 JSObject::SetLocalPropertyIgnoreAttributes( |
| 377 target, internalized_name, function, attributes).Check(); | 371 target, internalized_name, function, attributes).Check(); |
| 378 if (set_instance_class_name) { | 372 if (set_instance_class_name) { |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 | 832 |
| 839 Handle<String> object_name = factory->Object_string(); | 833 Handle<String> object_name = factory->Object_string(); |
| 840 JSObject::SetLocalPropertyIgnoreAttributes( | 834 JSObject::SetLocalPropertyIgnoreAttributes( |
| 841 inner_global, object_name, | 835 inner_global, object_name, |
| 842 isolate->object_function(), DONT_ENUM).Check(); | 836 isolate->object_function(), DONT_ENUM).Check(); |
| 843 | 837 |
| 844 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 838 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 845 | 839 |
| 846 // Install global Function object | 840 // Install global Function object |
| 847 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 841 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 848 empty_function, Builtins::kIllegal, true, true); | 842 empty_function, Builtins::kIllegal, true); |
| 849 | 843 |
| 850 { // --- A r r a y --- | 844 { // --- A r r a y --- |
| 851 Handle<JSFunction> array_function = | 845 Handle<JSFunction> array_function = |
| 852 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 846 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 853 isolate->initial_object_prototype(), | 847 isolate->initial_object_prototype(), |
| 854 Builtins::kArrayCode, true, true); | 848 Builtins::kArrayCode, true); |
| 855 array_function->shared()->DontAdaptArguments(); | 849 array_function->shared()->DontAdaptArguments(); |
| 856 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); | 850 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
| 857 | 851 |
| 858 // This seems a bit hackish, but we need to make sure Array.length | 852 // This seems a bit hackish, but we need to make sure Array.length |
| 859 // is 1. | 853 // is 1. |
| 860 array_function->shared()->set_length(1); | 854 array_function->shared()->set_length(1); |
| 861 | 855 |
| 862 Handle<Map> initial_map(array_function->initial_map()); | 856 Handle<Map> initial_map(array_function->initial_map()); |
| 863 | 857 |
| 864 // This assert protects an optimization in | 858 // This assert protects an optimization in |
| (...skipping 23 matching lines...) Expand all Loading... |
| 888 CacheInitialJSArrayMaps(native_context(), initial_map); | 882 CacheInitialJSArrayMaps(native_context(), initial_map); |
| 889 ArrayConstructorStub array_constructor_stub(isolate); | 883 ArrayConstructorStub array_constructor_stub(isolate); |
| 890 Handle<Code> code = array_constructor_stub.GetCode(); | 884 Handle<Code> code = array_constructor_stub.GetCode(); |
| 891 array_function->shared()->set_construct_stub(*code); | 885 array_function->shared()->set_construct_stub(*code); |
| 892 } | 886 } |
| 893 | 887 |
| 894 { // --- N u m b e r --- | 888 { // --- N u m b e r --- |
| 895 Handle<JSFunction> number_fun = | 889 Handle<JSFunction> number_fun = |
| 896 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 890 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
| 897 isolate->initial_object_prototype(), | 891 isolate->initial_object_prototype(), |
| 898 Builtins::kIllegal, true, true); | 892 Builtins::kIllegal, true); |
| 899 native_context()->set_number_function(*number_fun); | 893 native_context()->set_number_function(*number_fun); |
| 900 } | 894 } |
| 901 | 895 |
| 902 { // --- B o o l e a n --- | 896 { // --- B o o l e a n --- |
| 903 Handle<JSFunction> boolean_fun = | 897 Handle<JSFunction> boolean_fun = |
| 904 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, | 898 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, |
| 905 isolate->initial_object_prototype(), | 899 isolate->initial_object_prototype(), |
| 906 Builtins::kIllegal, true, true); | 900 Builtins::kIllegal, true); |
| 907 native_context()->set_boolean_function(*boolean_fun); | 901 native_context()->set_boolean_function(*boolean_fun); |
| 908 } | 902 } |
| 909 | 903 |
| 910 { // --- S t r i n g --- | 904 { // --- S t r i n g --- |
| 911 Handle<JSFunction> string_fun = | 905 Handle<JSFunction> string_fun = |
| 912 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, | 906 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, |
| 913 isolate->initial_object_prototype(), | 907 isolate->initial_object_prototype(), |
| 914 Builtins::kIllegal, true, true); | 908 Builtins::kIllegal, true); |
| 915 string_fun->shared()->set_construct_stub( | 909 string_fun->shared()->set_construct_stub( |
| 916 isolate->builtins()->builtin(Builtins::kStringConstructCode)); | 910 isolate->builtins()->builtin(Builtins::kStringConstructCode)); |
| 917 native_context()->set_string_function(*string_fun); | 911 native_context()->set_string_function(*string_fun); |
| 918 | 912 |
| 919 Handle<Map> string_map = | 913 Handle<Map> string_map = |
| 920 Handle<Map>(native_context()->string_function()->initial_map()); | 914 Handle<Map>(native_context()->string_function()->initial_map()); |
| 921 Map::EnsureDescriptorSlack(string_map, 1); | 915 Map::EnsureDescriptorSlack(string_map, 1); |
| 922 | 916 |
| 923 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 917 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 924 DONT_ENUM | DONT_DELETE | READ_ONLY); | 918 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 925 Handle<AccessorInfo> string_length( | 919 Handle<AccessorInfo> string_length( |
| 926 Accessors::StringLengthInfo(isolate, attribs)); | 920 Accessors::StringLengthInfo(isolate, attribs)); |
| 927 | 921 |
| 928 { // Add length. | 922 { // Add length. |
| 929 CallbacksDescriptor d(factory->length_string(), string_length, attribs); | 923 CallbacksDescriptor d(factory->length_string(), string_length, attribs); |
| 930 string_map->AppendDescriptor(&d); | 924 string_map->AppendDescriptor(&d); |
| 931 } | 925 } |
| 932 } | 926 } |
| 933 | 927 |
| 934 { // --- D a t e --- | 928 { // --- D a t e --- |
| 935 // Builtin functions for Date.prototype. | 929 // Builtin functions for Date.prototype. |
| 936 Handle<JSFunction> date_fun = | 930 Handle<JSFunction> date_fun = |
| 937 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, | 931 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, |
| 938 isolate->initial_object_prototype(), | 932 isolate->initial_object_prototype(), |
| 939 Builtins::kIllegal, true, true); | 933 Builtins::kIllegal, true); |
| 940 | 934 |
| 941 native_context()->set_date_function(*date_fun); | 935 native_context()->set_date_function(*date_fun); |
| 942 } | 936 } |
| 943 | 937 |
| 944 | 938 |
| 945 { // -- R e g E x p | 939 { // -- R e g E x p |
| 946 // Builtin functions for RegExp.prototype. | 940 // Builtin functions for RegExp.prototype. |
| 947 Handle<JSFunction> regexp_fun = | 941 Handle<JSFunction> regexp_fun = |
| 948 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 942 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
| 949 isolate->initial_object_prototype(), | 943 isolate->initial_object_prototype(), |
| 950 Builtins::kIllegal, true, true); | 944 Builtins::kIllegal, true); |
| 951 native_context()->set_regexp_function(*regexp_fun); | 945 native_context()->set_regexp_function(*regexp_fun); |
| 952 | 946 |
| 953 ASSERT(regexp_fun->has_initial_map()); | 947 ASSERT(regexp_fun->has_initial_map()); |
| 954 Handle<Map> initial_map(regexp_fun->initial_map()); | 948 Handle<Map> initial_map(regexp_fun->initial_map()); |
| 955 | 949 |
| 956 ASSERT_EQ(0, initial_map->inobject_properties()); | 950 ASSERT_EQ(0, initial_map->inobject_properties()); |
| 957 | 951 |
| 958 PropertyAttributes final = | 952 PropertyAttributes final = |
| 959 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 953 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 960 Map::EnsureDescriptorSlack(initial_map, 5); | 954 Map::EnsureDescriptorSlack(initial_map, 5); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 global, name, json_object, DONT_ENUM).Check(); | 1037 global, name, json_object, DONT_ENUM).Check(); |
| 1044 native_context()->set_json_object(*json_object); | 1038 native_context()->set_json_object(*json_object); |
| 1045 } | 1039 } |
| 1046 | 1040 |
| 1047 { // -- A r r a y B u f f e r | 1041 { // -- A r r a y B u f f e r |
| 1048 Handle<JSFunction> array_buffer_fun = | 1042 Handle<JSFunction> array_buffer_fun = |
| 1049 InstallFunction( | 1043 InstallFunction( |
| 1050 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1044 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
| 1051 JSArrayBuffer::kSizeWithInternalFields, | 1045 JSArrayBuffer::kSizeWithInternalFields, |
| 1052 isolate->initial_object_prototype(), | 1046 isolate->initial_object_prototype(), |
| 1053 Builtins::kIllegal, true, true); | 1047 Builtins::kIllegal, true); |
| 1054 native_context()->set_array_buffer_fun(*array_buffer_fun); | 1048 native_context()->set_array_buffer_fun(*array_buffer_fun); |
| 1055 } | 1049 } |
| 1056 | 1050 |
| 1057 { // -- T y p e d A r r a y s | 1051 { // -- T y p e d A r r a y s |
| 1058 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 1052 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 1059 { \ | 1053 { \ |
| 1060 Handle<JSFunction> fun; \ | 1054 Handle<JSFunction> fun; \ |
| 1061 Handle<Map> external_map; \ | 1055 Handle<Map> external_map; \ |
| 1062 InstallTypedArray(#Type "Array", \ | 1056 InstallTypedArray(#Type "Array", \ |
| 1063 TYPE##_ELEMENTS, \ | 1057 TYPE##_ELEMENTS, \ |
| 1064 &fun, \ | 1058 &fun, \ |
| 1065 &external_map); \ | 1059 &external_map); \ |
| 1066 native_context()->set_##type##_array_fun(*fun); \ | 1060 native_context()->set_##type##_array_fun(*fun); \ |
| 1067 native_context()->set_##type##_array_external_map(*external_map); \ | 1061 native_context()->set_##type##_array_external_map(*external_map); \ |
| 1068 } | 1062 } |
| 1069 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) | 1063 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) |
| 1070 #undef INSTALL_TYPED_ARRAY | 1064 #undef INSTALL_TYPED_ARRAY |
| 1071 | 1065 |
| 1072 Handle<JSFunction> data_view_fun = | 1066 Handle<JSFunction> data_view_fun = |
| 1073 InstallFunction( | 1067 InstallFunction( |
| 1074 global, "DataView", JS_DATA_VIEW_TYPE, | 1068 global, "DataView", JS_DATA_VIEW_TYPE, |
| 1075 JSDataView::kSizeWithInternalFields, | 1069 JSDataView::kSizeWithInternalFields, |
| 1076 isolate->initial_object_prototype(), | 1070 isolate->initial_object_prototype(), |
| 1077 Builtins::kIllegal, true, true); | 1071 Builtins::kIllegal, true); |
| 1078 native_context()->set_data_view_fun(*data_view_fun); | 1072 native_context()->set_data_view_fun(*data_view_fun); |
| 1079 } | 1073 } |
| 1080 | 1074 |
| 1081 { // --- arguments_boilerplate_ | 1075 { // --- arguments_boilerplate_ |
| 1082 // Make sure we can recognize argument objects at runtime. | 1076 // Make sure we can recognize argument objects at runtime. |
| 1083 // This is done by introducing an anonymous function with | 1077 // This is done by introducing an anonymous function with |
| 1084 // class_name equals 'Arguments'. | 1078 // class_name equals 'Arguments'. |
| 1085 Handle<String> arguments_string = factory->InternalizeOneByteString( | 1079 Handle<String> arguments_string = factory->InternalizeOneByteString( |
| 1086 STATIC_ASCII_VECTOR("Arguments")); | 1080 STATIC_ASCII_VECTOR("Arguments")); |
| 1087 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1081 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1088 Handle<JSObject> prototype( | |
| 1089 JSObject::cast(native_context()->object_function()->prototype())); | |
| 1090 | 1082 |
| 1091 Handle<JSFunction> function = | 1083 Handle<JSFunction> function = factory->NewFunction( |
| 1092 factory->NewFunctionWithPrototype(arguments_string, | 1084 MaybeHandle<Object>(), arguments_string, JS_OBJECT_TYPE, |
| 1093 JS_OBJECT_TYPE, | 1085 JSObject::kHeaderSize, code, false); |
| 1094 JSObject::kHeaderSize, | |
| 1095 prototype, | |
| 1096 code, | |
| 1097 false); | |
| 1098 ASSERT(!function->has_initial_map()); | 1086 ASSERT(!function->has_initial_map()); |
| 1099 function->shared()->set_instance_class_name(*arguments_string); | 1087 function->shared()->set_instance_class_name(*arguments_string); |
| 1100 function->shared()->set_expected_nof_properties(2); | 1088 function->shared()->set_expected_nof_properties(2); |
| 1089 function->set_prototype_or_initial_map( |
| 1090 native_context()->object_function()->prototype()); |
| 1101 Handle<JSObject> result = factory->NewJSObject(function); | 1091 Handle<JSObject> result = factory->NewJSObject(function); |
| 1102 | 1092 |
| 1103 native_context()->set_sloppy_arguments_boilerplate(*result); | 1093 native_context()->set_sloppy_arguments_boilerplate(*result); |
| 1104 // Note: length must be added as the first property and | 1094 // Note: length must be added as the first property and |
| 1105 // callee must be added as the second property. | 1095 // callee must be added as the second property. |
| 1106 JSObject::SetLocalPropertyIgnoreAttributes( | 1096 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1107 result, factory->length_string(), | 1097 result, factory->length_string(), |
| 1108 factory->undefined_value(), DONT_ENUM, | 1098 factory->undefined_value(), DONT_ENUM, |
| 1109 Object::FORCE_TAGGED, FORCE_FIELD).Check(); | 1099 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
| 1110 JSObject::SetLocalPropertyIgnoreAttributes( | 1100 JSObject::SetLocalPropertyIgnoreAttributes( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1266 |
| 1277 | 1267 |
| 1278 void Genesis::InstallTypedArray( | 1268 void Genesis::InstallTypedArray( |
| 1279 const char* name, | 1269 const char* name, |
| 1280 ElementsKind elements_kind, | 1270 ElementsKind elements_kind, |
| 1281 Handle<JSFunction>* fun, | 1271 Handle<JSFunction>* fun, |
| 1282 Handle<Map>* external_map) { | 1272 Handle<Map>* external_map) { |
| 1283 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1273 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1284 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1274 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, |
| 1285 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1275 JSTypedArray::kSize, isolate()->initial_object_prototype(), |
| 1286 Builtins::kIllegal, false, true); | 1276 Builtins::kIllegal, true); |
| 1287 | 1277 |
| 1288 Handle<Map> initial_map = isolate()->factory()->NewMap( | 1278 Handle<Map> initial_map = isolate()->factory()->NewMap( |
| 1289 JS_TYPED_ARRAY_TYPE, | 1279 JS_TYPED_ARRAY_TYPE, |
| 1290 JSTypedArray::kSizeWithInternalFields, | 1280 JSTypedArray::kSizeWithInternalFields, |
| 1291 elements_kind); | 1281 elements_kind); |
| 1292 result->set_initial_map(*initial_map); | 1282 result->set_initial_map(*initial_map); |
| 1293 initial_map->set_constructor(*result); | 1283 initial_map->set_constructor(*result); |
| 1294 *fun = result; | 1284 *fun = result; |
| 1295 | 1285 |
| 1296 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1286 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
| 1297 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1287 *external_map = Map::AsElementsKind(initial_map, external_kind); |
| 1298 } | 1288 } |
| 1299 | 1289 |
| 1300 | 1290 |
| 1301 void Genesis::InitializeExperimentalGlobal() { | 1291 void Genesis::InitializeExperimentalGlobal() { |
| 1302 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1292 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1303 | 1293 |
| 1304 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no | 1294 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no |
| 1305 // longer need to live behind flags, so functions get added to the snapshot. | 1295 // longer need to live behind flags, so functions get added to the snapshot. |
| 1306 | 1296 |
| 1307 if (FLAG_harmony_symbols) { | 1297 if (FLAG_harmony_symbols) { |
| 1308 // --- S y m b o l --- | 1298 // --- S y m b o l --- |
| 1309 Handle<JSFunction> symbol_fun = | 1299 Handle<JSFunction> symbol_fun = |
| 1310 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1300 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
| 1311 isolate()->initial_object_prototype(), | 1301 isolate()->initial_object_prototype(), |
| 1312 Builtins::kIllegal, true, true); | 1302 Builtins::kIllegal, true); |
| 1313 native_context()->set_symbol_function(*symbol_fun); | 1303 native_context()->set_symbol_function(*symbol_fun); |
| 1314 } | 1304 } |
| 1315 | 1305 |
| 1316 if (FLAG_harmony_collections) { | 1306 if (FLAG_harmony_collections) { |
| 1317 { // -- M a p | 1307 // -- M a p |
| 1318 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, | 1308 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, |
| 1319 isolate()->initial_object_prototype(), | 1309 isolate()->initial_object_prototype(), |
| 1320 Builtins::kIllegal, true, true); | 1310 Builtins::kIllegal, true); |
| 1321 } | 1311 // -- S e t |
| 1322 { // -- S e t | 1312 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, |
| 1323 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, | 1313 isolate()->initial_object_prototype(), |
| 1324 isolate()->initial_object_prototype(), | 1314 Builtins::kIllegal, true); |
| 1325 Builtins::kIllegal, true, true); | |
| 1326 } | |
| 1327 { // -- S e t I t e r a t o r | 1315 { // -- S e t I t e r a t o r |
| 1328 Handle<Map> map = isolate()->factory()->NewMap( | 1316 Handle<Map> map = isolate()->factory()->NewMap( |
| 1329 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); | 1317 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); |
| 1330 native_context()->set_set_iterator_map(*map); | 1318 native_context()->set_set_iterator_map(*map); |
| 1331 } | 1319 } |
| 1332 { // -- M a p I t e r a t o r | 1320 { // -- M a p I t e r a t o r |
| 1333 Handle<Map> map = isolate()->factory()->NewMap( | 1321 Handle<Map> map = isolate()->factory()->NewMap( |
| 1334 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); | 1322 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); |
| 1335 native_context()->set_map_iterator_map(*map); | 1323 native_context()->set_map_iterator_map(*map); |
| 1336 } | 1324 } |
| 1337 } | 1325 } |
| 1338 | 1326 |
| 1339 if (FLAG_harmony_weak_collections) { | 1327 if (FLAG_harmony_weak_collections) { |
| 1340 { // -- W e a k M a p | 1328 // -- W e a k M a p |
| 1341 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1329 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
| 1342 isolate()->initial_object_prototype(), | 1330 isolate()->initial_object_prototype(), |
| 1343 Builtins::kIllegal, true, true); | 1331 Builtins::kIllegal, true); |
| 1344 } | 1332 // -- W e a k S e t |
| 1345 { // -- W e a k S e t | 1333 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, |
| 1346 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, | 1334 isolate()->initial_object_prototype(), |
| 1347 isolate()->initial_object_prototype(), | 1335 Builtins::kIllegal, true); |
| 1348 Builtins::kIllegal, true, true); | |
| 1349 } | |
| 1350 } | 1336 } |
| 1351 | 1337 |
| 1352 if (FLAG_harmony_generators) { | 1338 if (FLAG_harmony_generators) { |
| 1353 // Create generator meta-objects and install them on the builtins object. | 1339 // Create generator meta-objects and install them on the builtins object. |
| 1354 Handle<JSObject> builtins(native_context()->builtins()); | 1340 Handle<JSObject> builtins(native_context()->builtins()); |
| 1355 Handle<JSObject> generator_object_prototype = | 1341 Handle<JSObject> generator_object_prototype = |
| 1356 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1342 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1357 Handle<JSFunction> generator_function_prototype = | 1343 Handle<JSFunction> generator_function_prototype = |
| 1358 InstallFunction(builtins, "GeneratorFunctionPrototype", | 1344 InstallFunction(builtins, "GeneratorFunctionPrototype", |
| 1359 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, | 1345 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, |
| 1360 generator_object_prototype, Builtins::kIllegal, | 1346 generator_object_prototype, Builtins::kIllegal, false); |
| 1361 false, false); | |
| 1362 InstallFunction(builtins, "GeneratorFunction", | 1347 InstallFunction(builtins, "GeneratorFunction", |
| 1363 JS_FUNCTION_TYPE, JSFunction::kSize, | 1348 JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1364 generator_function_prototype, Builtins::kIllegal, | 1349 generator_function_prototype, Builtins::kIllegal, false); |
| 1365 false, false); | |
| 1366 | 1350 |
| 1367 // Create maps for generator functions and their prototypes. Store those | 1351 // Create maps for generator functions and their prototypes. Store those |
| 1368 // maps in the native context. | 1352 // maps in the native context. |
| 1369 Handle<Map> function_map(native_context()->sloppy_function_map()); | 1353 Handle<Map> function_map(native_context()->sloppy_function_map()); |
| 1370 Handle<Map> generator_function_map = Map::Copy(function_map); | 1354 Handle<Map> generator_function_map = Map::Copy(function_map); |
| 1371 generator_function_map->set_prototype(*generator_function_prototype); | 1355 generator_function_map->set_prototype(*generator_function_prototype); |
| 1372 native_context()->set_sloppy_generator_function_map( | 1356 native_context()->set_sloppy_generator_function_map( |
| 1373 *generator_function_map); | 1357 *generator_function_map); |
| 1374 | 1358 |
| 1375 Handle<Map> strict_mode_function_map( | 1359 Handle<Map> strict_mode_function_map( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 Handle<JSFunction> Genesis::InstallInternalArray( | 1577 Handle<JSFunction> Genesis::InstallInternalArray( |
| 1594 Handle<JSBuiltinsObject> builtins, | 1578 Handle<JSBuiltinsObject> builtins, |
| 1595 const char* name, | 1579 const char* name, |
| 1596 ElementsKind elements_kind) { | 1580 ElementsKind elements_kind) { |
| 1597 // --- I n t e r n a l A r r a y --- | 1581 // --- I n t e r n a l A r r a y --- |
| 1598 // An array constructor on the builtins object that works like | 1582 // An array constructor on the builtins object that works like |
| 1599 // the public Array constructor, except that its prototype | 1583 // the public Array constructor, except that its prototype |
| 1600 // doesn't inherit from Object.prototype. | 1584 // doesn't inherit from Object.prototype. |
| 1601 // To be used only for internal work by builtins. Instances | 1585 // To be used only for internal work by builtins. Instances |
| 1602 // must not be leaked to user code. | 1586 // must not be leaked to user code. |
| 1603 Handle<JSFunction> array_function = | 1587 Handle<JSFunction> array_function = InstallFunction( |
| 1604 InstallFunction(builtins, | 1588 builtins, name, JS_ARRAY_TYPE, JSArray::kSize, |
| 1605 name, | 1589 isolate()->initial_object_prototype(), Builtins::kInternalArrayCode, |
| 1606 JS_ARRAY_TYPE, | 1590 true); |
| 1607 JSArray::kSize, | |
| 1608 isolate()->initial_object_prototype(), | |
| 1609 Builtins::kInternalArrayCode, | |
| 1610 true, true); | |
| 1611 Handle<JSObject> prototype = | 1591 Handle<JSObject> prototype = |
| 1612 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1592 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1613 Accessors::FunctionSetPrototype(array_function, prototype); | 1593 Accessors::FunctionSetPrototype(array_function, prototype); |
| 1614 | 1594 |
| 1615 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); | 1595 InternalArrayConstructorStub internal_array_constructor_stub(isolate()); |
| 1616 Handle<Code> code = internal_array_constructor_stub.GetCode(); | 1596 Handle<Code> code = internal_array_constructor_stub.GetCode(); |
| 1617 array_function->shared()->set_construct_stub(*code); | 1597 array_function->shared()->set_construct_stub(*code); |
| 1618 array_function->shared()->DontAdaptArguments(); | 1598 array_function->shared()->DontAdaptArguments(); |
| 1619 | 1599 |
| 1620 Handle<Map> original_map(array_function->initial_map()); | 1600 Handle<Map> original_map(array_function->initial_map()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 | 1676 |
| 1697 // Allocate the builtins context. | 1677 // Allocate the builtins context. |
| 1698 Handle<Context> context = | 1678 Handle<Context> context = |
| 1699 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1679 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
| 1700 context->set_global_object(*builtins); // override builtins global object | 1680 context->set_global_object(*builtins); // override builtins global object |
| 1701 | 1681 |
| 1702 native_context()->set_runtime_context(*context); | 1682 native_context()->set_runtime_context(*context); |
| 1703 | 1683 |
| 1704 { // -- S c r i p t | 1684 { // -- S c r i p t |
| 1705 // Builtin functions for Script. | 1685 // Builtin functions for Script. |
| 1706 Handle<JSFunction> script_fun = | 1686 Handle<JSFunction> script_fun = InstallFunction( |
| 1707 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 1687 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
| 1708 isolate()->initial_object_prototype(), | 1688 isolate()->initial_object_prototype(), Builtins::kIllegal, false); |
| 1709 Builtins::kIllegal, false, false); | |
| 1710 Handle<JSObject> prototype = | 1689 Handle<JSObject> prototype = |
| 1711 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1690 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1712 Accessors::FunctionSetPrototype(script_fun, prototype); | 1691 Accessors::FunctionSetPrototype(script_fun, prototype); |
| 1713 native_context()->set_script_function(*script_fun); | 1692 native_context()->set_script_function(*script_fun); |
| 1714 | 1693 |
| 1715 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1694 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
| 1716 Map::EnsureDescriptorSlack(script_map, 13); | 1695 Map::EnsureDescriptorSlack(script_map, 13); |
| 1717 | 1696 |
| 1718 PropertyAttributes attribs = | 1697 PropertyAttributes attribs = |
| 1719 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1698 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 | 1801 |
| 1823 // Allocate the empty script. | 1802 // Allocate the empty script. |
| 1824 Handle<Script> script = factory()->NewScript(factory()->empty_string()); | 1803 Handle<Script> script = factory()->NewScript(factory()->empty_string()); |
| 1825 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1804 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 1826 heap()->public_set_empty_script(*script); | 1805 heap()->public_set_empty_script(*script); |
| 1827 } | 1806 } |
| 1828 { | 1807 { |
| 1829 // Builtin function for OpaqueReference -- a JSValue-based object, | 1808 // Builtin function for OpaqueReference -- a JSValue-based object, |
| 1830 // that keeps its field isolated from JavaScript code. It may store | 1809 // that keeps its field isolated from JavaScript code. It may store |
| 1831 // objects, that JavaScript code may not access. | 1810 // objects, that JavaScript code may not access. |
| 1832 Handle<JSFunction> opaque_reference_fun = | 1811 Handle<JSFunction> opaque_reference_fun = InstallFunction( |
| 1833 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, | 1812 builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize, |
| 1834 JSValue::kSize, | 1813 isolate()->initial_object_prototype(), Builtins::kIllegal, false); |
| 1835 isolate()->initial_object_prototype(), | |
| 1836 Builtins::kIllegal, false, false); | |
| 1837 Handle<JSObject> prototype = | 1814 Handle<JSObject> prototype = |
| 1838 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1815 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1839 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); | 1816 Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); |
| 1840 native_context()->set_opaque_reference_function(*opaque_reference_fun); | 1817 native_context()->set_opaque_reference_function(*opaque_reference_fun); |
| 1841 } | 1818 } |
| 1842 | 1819 |
| 1843 // InternalArrays should not use Smi-Only array optimizations. There are too | 1820 // InternalArrays should not use Smi-Only array optimizations. There are too |
| 1844 // many places in the C++ runtime code (e.g. RegEx) that assume that | 1821 // many places in the C++ runtime code (e.g. RegEx) that assume that |
| 1845 // elements in InternalArrays can be set to non-Smi values without going | 1822 // elements in InternalArrays can be set to non-Smi values without going |
| 1846 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT | 1823 // 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... |
| 1885 { Handle<String> key = factory()->function_class_string(); | 1862 { Handle<String> key = factory()->function_class_string(); |
| 1886 Handle<JSFunction> function = | 1863 Handle<JSFunction> function = |
| 1887 Handle<JSFunction>::cast(Object::GetProperty( | 1864 Handle<JSFunction>::cast(Object::GetProperty( |
| 1888 isolate()->global_object(), key).ToHandleChecked()); | 1865 isolate()->global_object(), key).ToHandleChecked()); |
| 1889 Handle<JSObject> proto = | 1866 Handle<JSObject> proto = |
| 1890 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 1867 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
| 1891 | 1868 |
| 1892 // Install the call and the apply functions. | 1869 // Install the call and the apply functions. |
| 1893 Handle<JSFunction> call = | 1870 Handle<JSFunction> call = |
| 1894 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1871 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1895 Handle<JSObject>::null(), | 1872 MaybeHandle<JSObject>(), |
| 1896 Builtins::kFunctionCall, | 1873 Builtins::kFunctionCall, false); |
| 1897 false, false); | |
| 1898 Handle<JSFunction> apply = | 1874 Handle<JSFunction> apply = |
| 1899 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1875 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1900 Handle<JSObject>::null(), | 1876 MaybeHandle<JSObject>(), |
| 1901 Builtins::kFunctionApply, | 1877 Builtins::kFunctionApply, false); |
| 1902 false, false); | |
| 1903 | 1878 |
| 1904 // Make sure that Function.prototype.call appears to be compiled. | 1879 // Make sure that Function.prototype.call appears to be compiled. |
| 1905 // The code will never be called, but inline caching for call will | 1880 // The code will never be called, but inline caching for call will |
| 1906 // only work if it appears to be compiled. | 1881 // only work if it appears to be compiled. |
| 1907 call->shared()->DontAdaptArguments(); | 1882 call->shared()->DontAdaptArguments(); |
| 1908 ASSERT(call->is_compiled()); | 1883 ASSERT(call->is_compiled()); |
| 1909 | 1884 |
| 1910 // Set the expected parameters for apply to 2; required by builtin. | 1885 // Set the expected parameters for apply to 2; required by builtin. |
| 1911 apply->shared()->set_formal_parameter_count(2); | 1886 apply->shared()->set_formal_parameter_count(2); |
| 1912 | 1887 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2698 return from + sizeof(NestingCounterType); | 2673 return from + sizeof(NestingCounterType); |
| 2699 } | 2674 } |
| 2700 | 2675 |
| 2701 | 2676 |
| 2702 // Called when the top-level V8 mutex is destroyed. | 2677 // Called when the top-level V8 mutex is destroyed. |
| 2703 void Bootstrapper::FreeThreadResources() { | 2678 void Bootstrapper::FreeThreadResources() { |
| 2704 ASSERT(!IsActive()); | 2679 ASSERT(!IsActive()); |
| 2705 } | 2680 } |
| 2706 | 2681 |
| 2707 } } // namespace v8::internal | 2682 } } // namespace v8::internal |
| OLD | NEW |