| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 void InitializeExperimentalGlobal(); | 194 void InitializeExperimentalGlobal(); |
| 195 // Installs the contents of the native .js files on the global objects. | 195 // Installs the contents of the native .js files on the global objects. |
| 196 // Used for creating a context from scratch. | 196 // Used for creating a context from scratch. |
| 197 void InstallNativeFunctions(); | 197 void InstallNativeFunctions(); |
| 198 void InstallExperimentalNativeFunctions(); | 198 void InstallExperimentalNativeFunctions(); |
| 199 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, | 199 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, |
| 200 const char* name, | 200 const char* name, |
| 201 ElementsKind elements_kind); | 201 ElementsKind elements_kind); |
| 202 bool InstallNatives(); | 202 bool InstallNatives(); |
| 203 | 203 |
| 204 Handle<JSFunction> InstallTypedArray(const char* name); | 204 Handle<JSFunction> InstallTypedArray(const char* name, |
| 205 ElementsKind elementsKind); |
| 205 bool InstallExperimentalNatives(); | 206 bool InstallExperimentalNatives(); |
| 206 void InstallBuiltinFunctionIds(); | 207 void InstallBuiltinFunctionIds(); |
| 207 void InstallJSFunctionResultCaches(); | 208 void InstallJSFunctionResultCaches(); |
| 208 void InitializeNormalizedMapCaches(); | 209 void InitializeNormalizedMapCaches(); |
| 209 | 210 |
| 210 enum ExtensionTraversalState { | 211 enum ExtensionTraversalState { |
| 211 UNVISITED, VISITED, INSTALLED | 212 UNVISITED, VISITED, INSTALLED |
| 212 }; | 213 }; |
| 213 | 214 |
| 214 class ExtensionStates { | 215 class ExtensionStates { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 global_proxy->set_native_context(*env); | 343 global_proxy->set_native_context(*env); |
| 343 } | 344 } |
| 344 | 345 |
| 345 | 346 |
| 346 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, | 347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, |
| 347 const char* name, | 348 const char* name, |
| 348 InstanceType type, | 349 InstanceType type, |
| 349 int instance_size, | 350 int instance_size, |
| 350 Handle<JSObject> prototype, | 351 Handle<JSObject> prototype, |
| 351 Builtins::Name call, | 352 Builtins::Name call, |
| 352 bool is_ecma_native) { | 353 bool install_initial_map, |
| 354 bool set_instance_class_name) { |
| 353 Isolate* isolate = target->GetIsolate(); | 355 Isolate* isolate = target->GetIsolate(); |
| 354 Factory* factory = isolate->factory(); | 356 Factory* factory = isolate->factory(); |
| 355 Handle<String> internalized_name = factory->InternalizeUtf8String(name); | 357 Handle<String> internalized_name = factory->InternalizeUtf8String(name); |
| 356 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 358 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); |
| 357 Handle<JSFunction> function = prototype.is_null() ? | 359 Handle<JSFunction> function = prototype.is_null() ? |
| 358 factory->NewFunctionWithoutPrototype(internalized_name, call_code) : | 360 factory->NewFunctionWithoutPrototype(internalized_name, call_code) : |
| 359 factory->NewFunctionWithPrototype(internalized_name, | 361 factory->NewFunctionWithPrototype(internalized_name, |
| 360 type, | 362 type, |
| 361 instance_size, | 363 instance_size, |
| 362 prototype, | 364 prototype, |
| 363 call_code, | 365 call_code, |
| 364 is_ecma_native); | 366 install_initial_map); |
| 365 PropertyAttributes attributes; | 367 PropertyAttributes attributes; |
| 366 if (target->IsJSBuiltinsObject()) { | 368 if (target->IsJSBuiltinsObject()) { |
| 367 attributes = | 369 attributes = |
| 368 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 370 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 369 } else { | 371 } else { |
| 370 attributes = DONT_ENUM; | 372 attributes = DONT_ENUM; |
| 371 } | 373 } |
| 372 CHECK_NOT_EMPTY_HANDLE(isolate, | 374 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 373 JSObject::SetLocalPropertyIgnoreAttributes( | 375 JSObject::SetLocalPropertyIgnoreAttributes( |
| 374 target, internalized_name, function, attributes)); | 376 target, internalized_name, function, attributes)); |
| 375 if (is_ecma_native) { | 377 if (set_instance_class_name) { |
| 376 function->shared()->set_instance_class_name(*internalized_name); | 378 function->shared()->set_instance_class_name(*internalized_name); |
| 377 } | 379 } |
| 378 function->shared()->set_native(true); | 380 function->shared()->set_native(true); |
| 379 return function; | 381 return function; |
| 380 } | 382 } |
| 381 | 383 |
| 382 | 384 |
| 383 void Genesis::SetFunctionInstanceDescriptor( | 385 void Genesis::SetFunctionInstanceDescriptor( |
| 384 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 386 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
| 385 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 387 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 Handle<String> object_name = factory->Object_string(); | 838 Handle<String> object_name = factory->Object_string(); |
| 837 CHECK_NOT_EMPTY_HANDLE(isolate, | 839 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 838 JSObject::SetLocalPropertyIgnoreAttributes( | 840 JSObject::SetLocalPropertyIgnoreAttributes( |
| 839 inner_global, object_name, | 841 inner_global, object_name, |
| 840 isolate->object_function(), DONT_ENUM)); | 842 isolate->object_function(), DONT_ENUM)); |
| 841 | 843 |
| 842 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 844 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 843 | 845 |
| 844 // Install global Function object | 846 // Install global Function object |
| 845 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 847 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 846 empty_function, Builtins::kIllegal, true); // ECMA native. | 848 empty_function, Builtins::kIllegal, true, true); |
| 847 | 849 |
| 848 { // --- A r r a y --- | 850 { // --- A r r a y --- |
| 849 Handle<JSFunction> array_function = | 851 Handle<JSFunction> array_function = |
| 850 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 852 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
| 851 isolate->initial_object_prototype(), | 853 isolate->initial_object_prototype(), |
| 852 Builtins::kArrayCode, true); | 854 Builtins::kArrayCode, true, true); |
| 853 array_function->shared()->DontAdaptArguments(); | 855 array_function->shared()->DontAdaptArguments(); |
| 854 | 856 |
| 855 // This seems a bit hackish, but we need to make sure Array.length | 857 // This seems a bit hackish, but we need to make sure Array.length |
| 856 // is 1. | 858 // is 1. |
| 857 array_function->shared()->set_length(1); | 859 array_function->shared()->set_length(1); |
| 858 | 860 |
| 859 Handle<Map> initial_map(array_function->initial_map()); | 861 Handle<Map> initial_map(array_function->initial_map()); |
| 860 Handle<DescriptorArray> array_descriptors( | 862 Handle<DescriptorArray> array_descriptors( |
| 861 factory->NewDescriptorArray(0, 1)); | 863 factory->NewDescriptorArray(0, 1)); |
| 862 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 864 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 886 } else { | 888 } else { |
| 887 array_function->shared()->set_construct_stub( | 889 array_function->shared()->set_construct_stub( |
| 888 isolate->builtins()->builtin(Builtins::kCommonArrayConstructCode)); | 890 isolate->builtins()->builtin(Builtins::kCommonArrayConstructCode)); |
| 889 } | 891 } |
| 890 } | 892 } |
| 891 | 893 |
| 892 { // --- N u m b e r --- | 894 { // --- N u m b e r --- |
| 893 Handle<JSFunction> number_fun = | 895 Handle<JSFunction> number_fun = |
| 894 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 896 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
| 895 isolate->initial_object_prototype(), | 897 isolate->initial_object_prototype(), |
| 896 Builtins::kIllegal, true); | 898 Builtins::kIllegal, true, true); |
| 897 native_context()->set_number_function(*number_fun); | 899 native_context()->set_number_function(*number_fun); |
| 898 } | 900 } |
| 899 | 901 |
| 900 { // --- B o o l e a n --- | 902 { // --- B o o l e a n --- |
| 901 Handle<JSFunction> boolean_fun = | 903 Handle<JSFunction> boolean_fun = |
| 902 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, | 904 InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, |
| 903 isolate->initial_object_prototype(), | 905 isolate->initial_object_prototype(), |
| 904 Builtins::kIllegal, true); | 906 Builtins::kIllegal, true, true); |
| 905 native_context()->set_boolean_function(*boolean_fun); | 907 native_context()->set_boolean_function(*boolean_fun); |
| 906 } | 908 } |
| 907 | 909 |
| 908 { // --- S t r i n g --- | 910 { // --- S t r i n g --- |
| 909 Handle<JSFunction> string_fun = | 911 Handle<JSFunction> string_fun = |
| 910 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, | 912 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, |
| 911 isolate->initial_object_prototype(), | 913 isolate->initial_object_prototype(), |
| 912 Builtins::kIllegal, true); | 914 Builtins::kIllegal, true, true); |
| 913 string_fun->shared()->set_construct_stub( | 915 string_fun->shared()->set_construct_stub( |
| 914 isolate->builtins()->builtin(Builtins::kStringConstructCode)); | 916 isolate->builtins()->builtin(Builtins::kStringConstructCode)); |
| 915 native_context()->set_string_function(*string_fun); | 917 native_context()->set_string_function(*string_fun); |
| 916 | 918 |
| 917 Handle<Map> string_map = | 919 Handle<Map> string_map = |
| 918 Handle<Map>(native_context()->string_function()->initial_map()); | 920 Handle<Map>(native_context()->string_function()->initial_map()); |
| 919 Handle<DescriptorArray> string_descriptors( | 921 Handle<DescriptorArray> string_descriptors( |
| 920 factory->NewDescriptorArray(0, 1)); | 922 factory->NewDescriptorArray(0, 1)); |
| 921 DescriptorArray::WhitenessWitness witness(*string_descriptors); | 923 DescriptorArray::WhitenessWitness witness(*string_descriptors); |
| 922 | 924 |
| 923 Handle<Foreign> string_length( | 925 Handle<Foreign> string_length( |
| 924 factory->NewForeign(&Accessors::StringLength)); | 926 factory->NewForeign(&Accessors::StringLength)); |
| 925 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 927 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 926 DONT_ENUM | DONT_DELETE | READ_ONLY); | 928 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 927 string_map->set_instance_descriptors(*string_descriptors); | 929 string_map->set_instance_descriptors(*string_descriptors); |
| 928 | 930 |
| 929 { // Add length. | 931 { // Add length. |
| 930 CallbacksDescriptor d(*factory->length_string(), *string_length, attribs); | 932 CallbacksDescriptor d(*factory->length_string(), *string_length, attribs); |
| 931 string_map->AppendDescriptor(&d, witness); | 933 string_map->AppendDescriptor(&d, witness); |
| 932 } | 934 } |
| 933 } | 935 } |
| 934 | 936 |
| 935 { // --- D a t e --- | 937 { // --- D a t e --- |
| 936 // Builtin functions for Date.prototype. | 938 // Builtin functions for Date.prototype. |
| 937 Handle<JSFunction> date_fun = | 939 Handle<JSFunction> date_fun = |
| 938 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, | 940 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, |
| 939 isolate->initial_object_prototype(), | 941 isolate->initial_object_prototype(), |
| 940 Builtins::kIllegal, true); | 942 Builtins::kIllegal, true, true); |
| 941 | 943 |
| 942 native_context()->set_date_function(*date_fun); | 944 native_context()->set_date_function(*date_fun); |
| 943 } | 945 } |
| 944 | 946 |
| 945 | 947 |
| 946 { // -- R e g E x p | 948 { // -- R e g E x p |
| 947 // Builtin functions for RegExp.prototype. | 949 // Builtin functions for RegExp.prototype. |
| 948 Handle<JSFunction> regexp_fun = | 950 Handle<JSFunction> regexp_fun = |
| 949 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 951 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
| 950 isolate->initial_object_prototype(), | 952 isolate->initial_object_prototype(), |
| 951 Builtins::kIllegal, true); | 953 Builtins::kIllegal, true, true); |
| 952 native_context()->set_regexp_function(*regexp_fun); | 954 native_context()->set_regexp_function(*regexp_fun); |
| 953 | 955 |
| 954 ASSERT(regexp_fun->has_initial_map()); | 956 ASSERT(regexp_fun->has_initial_map()); |
| 955 Handle<Map> initial_map(regexp_fun->initial_map()); | 957 Handle<Map> initial_map(regexp_fun->initial_map()); |
| 956 | 958 |
| 957 ASSERT_EQ(0, initial_map->inobject_properties()); | 959 ASSERT_EQ(0, initial_map->inobject_properties()); |
| 958 | 960 |
| 959 PropertyAttributes final = | 961 PropertyAttributes final = |
| 960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 962 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); | 963 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 // Initialize the random seed slot. | 1258 // Initialize the random seed slot. |
| 1257 Handle<ByteArray> zeroed_byte_array( | 1259 Handle<ByteArray> zeroed_byte_array( |
| 1258 factory->NewByteArray(kRandomStateSize)); | 1260 factory->NewByteArray(kRandomStateSize)); |
| 1259 native_context()->set_random_seed(*zeroed_byte_array); | 1261 native_context()->set_random_seed(*zeroed_byte_array); |
| 1260 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); | 1262 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); |
| 1261 } | 1263 } |
| 1262 return true; | 1264 return true; |
| 1263 } | 1265 } |
| 1264 | 1266 |
| 1265 | 1267 |
| 1266 Handle<JSFunction> Genesis::InstallTypedArray(const char* name) { | 1268 Handle<JSFunction> Genesis::InstallTypedArray( |
| 1269 const char* name, ElementsKind elementsKind) { |
| 1267 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1270 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1268 return InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1271 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, |
| 1269 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1272 JSTypedArray::kSize, isolate()->initial_object_prototype(), |
| 1270 Builtins::kIllegal, true); | 1273 Builtins::kIllegal, false, true); |
| 1274 |
| 1275 Handle<Map> initial_map = isolate()->factory()->NewMap( |
| 1276 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, elementsKind); |
| 1277 result->set_initial_map(*initial_map); |
| 1278 initial_map->set_constructor(*result); |
| 1279 return result; |
| 1271 } | 1280 } |
| 1272 | 1281 |
| 1273 | 1282 |
| 1274 void Genesis::InitializeExperimentalGlobal() { | 1283 void Genesis::InitializeExperimentalGlobal() { |
| 1275 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1284 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1276 | 1285 |
| 1277 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no | 1286 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no |
| 1278 // longer need to live behind flags, so functions get added to the snapshot. | 1287 // longer need to live behind flags, so functions get added to the snapshot. |
| 1279 | 1288 |
| 1280 if (FLAG_harmony_symbols) { | 1289 if (FLAG_harmony_symbols) { |
| 1281 // --- S y m b o l --- | 1290 // --- S y m b o l --- |
| 1282 Handle<JSFunction> symbol_fun = | 1291 Handle<JSFunction> symbol_fun = |
| 1283 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1292 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
| 1284 isolate()->initial_object_prototype(), | 1293 isolate()->initial_object_prototype(), |
| 1285 Builtins::kIllegal, true); | 1294 Builtins::kIllegal, true, true); |
| 1286 native_context()->set_symbol_function(*symbol_fun); | 1295 native_context()->set_symbol_function(*symbol_fun); |
| 1287 } | 1296 } |
| 1288 | 1297 |
| 1289 if (FLAG_harmony_collections) { | 1298 if (FLAG_harmony_collections) { |
| 1290 { // -- S e t | 1299 { // -- S e t |
| 1291 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, | 1300 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, |
| 1292 isolate()->initial_object_prototype(), | 1301 isolate()->initial_object_prototype(), |
| 1293 Builtins::kIllegal, true); | 1302 Builtins::kIllegal, true, true); |
| 1294 } | 1303 } |
| 1295 { // -- M a p | 1304 { // -- M a p |
| 1296 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, | 1305 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, |
| 1297 isolate()->initial_object_prototype(), | 1306 isolate()->initial_object_prototype(), |
| 1298 Builtins::kIllegal, true); | 1307 Builtins::kIllegal, true, true); |
| 1299 } | 1308 } |
| 1300 { // -- W e a k M a p | 1309 { // -- W e a k M a p |
| 1301 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1310 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
| 1302 isolate()->initial_object_prototype(), | 1311 isolate()->initial_object_prototype(), |
| 1303 Builtins::kIllegal, true); | 1312 Builtins::kIllegal, true, true); |
| 1304 } | 1313 } |
| 1305 } | 1314 } |
| 1306 | 1315 |
| 1307 if (FLAG_harmony_array_buffer) { | 1316 if (FLAG_harmony_array_buffer) { |
| 1308 // -- A r r a y B u f f e r | 1317 // -- A r r a y B u f f e r |
| 1309 Handle<JSFunction> array_buffer_fun = | 1318 Handle<JSFunction> array_buffer_fun = |
| 1310 InstallFunction(global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1319 InstallFunction(global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
| 1311 JSArrayBuffer::kSize, | 1320 JSArrayBuffer::kSize, |
| 1312 isolate()->initial_object_prototype(), | 1321 isolate()->initial_object_prototype(), |
| 1313 Builtins::kIllegal, true); | 1322 Builtins::kIllegal, true, true); |
| 1314 native_context()->set_array_buffer_fun(*array_buffer_fun); | 1323 native_context()->set_array_buffer_fun(*array_buffer_fun); |
| 1315 } | 1324 } |
| 1316 | 1325 |
| 1317 if (FLAG_harmony_typed_arrays) { | 1326 if (FLAG_harmony_typed_arrays) { |
| 1318 // -- T y p e d A r r a y s | 1327 // -- T y p e d A r r a y s |
| 1319 Handle<JSFunction> int8_fun = InstallTypedArray("Int8Array"); | 1328 Handle<JSFunction> int8_fun = InstallTypedArray("Int8Array", |
| 1329 EXTERNAL_BYTE_ELEMENTS); |
| 1320 native_context()->set_int8_array_fun(*int8_fun); | 1330 native_context()->set_int8_array_fun(*int8_fun); |
| 1321 Handle<JSFunction> uint8_fun = InstallTypedArray("Uint8Array"); | 1331 Handle<JSFunction> uint8_fun = InstallTypedArray("Uint8Array", |
| 1332 EXTERNAL_UNSIGNED_BYTE_ELEMENTS); |
| 1322 native_context()->set_uint8_array_fun(*uint8_fun); | 1333 native_context()->set_uint8_array_fun(*uint8_fun); |
| 1323 Handle<JSFunction> int16_fun = InstallTypedArray("Int16Array"); | 1334 Handle<JSFunction> int16_fun = InstallTypedArray("Int16Array", |
| 1335 EXTERNAL_SHORT_ELEMENTS); |
| 1324 native_context()->set_int16_array_fun(*int16_fun); | 1336 native_context()->set_int16_array_fun(*int16_fun); |
| 1325 Handle<JSFunction> uint16_fun = InstallTypedArray("Uint16Array"); | 1337 Handle<JSFunction> uint16_fun = InstallTypedArray("Uint16Array", |
| 1338 EXTERNAL_UNSIGNED_SHORT_ELEMENTS); |
| 1326 native_context()->set_uint16_array_fun(*uint16_fun); | 1339 native_context()->set_uint16_array_fun(*uint16_fun); |
| 1327 Handle<JSFunction> int32_fun = InstallTypedArray("Int32Array"); | 1340 Handle<JSFunction> int32_fun = InstallTypedArray("Int32Array", |
| 1341 EXTERNAL_INT_ELEMENTS); |
| 1328 native_context()->set_int32_array_fun(*int32_fun); | 1342 native_context()->set_int32_array_fun(*int32_fun); |
| 1329 Handle<JSFunction> uint32_fun = InstallTypedArray("Uint32Array"); | 1343 Handle<JSFunction> uint32_fun = InstallTypedArray("Uint32Array", |
| 1344 EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 1330 native_context()->set_uint32_array_fun(*uint32_fun); | 1345 native_context()->set_uint32_array_fun(*uint32_fun); |
| 1331 Handle<JSFunction> float_fun = InstallTypedArray("Float32Array"); | 1346 Handle<JSFunction> float_fun = InstallTypedArray("Float32Array", |
| 1347 EXTERNAL_FLOAT_ELEMENTS); |
| 1332 native_context()->set_float_array_fun(*float_fun); | 1348 native_context()->set_float_array_fun(*float_fun); |
| 1333 Handle<JSFunction> double_fun = InstallTypedArray("Float64Array"); | 1349 Handle<JSFunction> double_fun = InstallTypedArray("Float64Array", |
| 1350 EXTERNAL_DOUBLE_ELEMENTS); |
| 1334 native_context()->set_double_array_fun(*double_fun); | 1351 native_context()->set_double_array_fun(*double_fun); |
| 1335 Handle<JSFunction> uint8c_fun = InstallTypedArray("Uint8ClampedArray"); | 1352 Handle<JSFunction> uint8c_fun = InstallTypedArray("Uint8ClampedArray", |
| 1353 EXTERNAL_PIXEL_ELEMENTS); |
| 1336 native_context()->set_uint8c_array_fun(*uint8c_fun); | 1354 native_context()->set_uint8c_array_fun(*uint8c_fun); |
| 1337 } | 1355 } |
| 1338 | 1356 |
| 1339 if (FLAG_harmony_generators) { | 1357 if (FLAG_harmony_generators) { |
| 1340 // Create generator meta-objects and install them on the builtins object. | 1358 // Create generator meta-objects and install them on the builtins object. |
| 1341 Handle<JSObject> builtins(native_context()->builtins()); | 1359 Handle<JSObject> builtins(native_context()->builtins()); |
| 1342 Handle<JSObject> generator_object_prototype = | 1360 Handle<JSObject> generator_object_prototype = |
| 1343 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1361 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1344 Handle<JSFunction> generator_function_prototype = | 1362 Handle<JSFunction> generator_function_prototype = |
| 1345 InstallFunction(builtins, "GeneratorFunctionPrototype", | 1363 InstallFunction(builtins, "GeneratorFunctionPrototype", |
| 1346 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, | 1364 JS_FUNCTION_TYPE, JSFunction::kHeaderSize, |
| 1347 generator_object_prototype, Builtins::kIllegal, | 1365 generator_object_prototype, Builtins::kIllegal, |
| 1348 false); | 1366 false, false); |
| 1349 InstallFunction(builtins, "GeneratorFunction", | 1367 InstallFunction(builtins, "GeneratorFunction", |
| 1350 JS_FUNCTION_TYPE, JSFunction::kSize, | 1368 JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1351 generator_function_prototype, Builtins::kIllegal, | 1369 generator_function_prototype, Builtins::kIllegal, |
| 1352 false); | 1370 false, false); |
| 1353 | 1371 |
| 1354 // Create maps for generator functions and their prototypes. Store those | 1372 // Create maps for generator functions and their prototypes. Store those |
| 1355 // maps in the native context. | 1373 // maps in the native context. |
| 1356 Handle<Map> function_map(native_context()->function_map()); | 1374 Handle<Map> function_map(native_context()->function_map()); |
| 1357 Handle<Map> generator_function_map = factory()->CopyMap(function_map); | 1375 Handle<Map> generator_function_map = factory()->CopyMap(function_map); |
| 1358 generator_function_map->set_prototype(*generator_function_prototype); | 1376 generator_function_map->set_prototype(*generator_function_prototype); |
| 1359 native_context()->set_generator_function_map(*generator_function_map); | 1377 native_context()->set_generator_function_map(*generator_function_map); |
| 1360 | 1378 |
| 1361 Handle<Map> strict_mode_function_map( | 1379 Handle<Map> strict_mode_function_map( |
| 1362 native_context()->strict_mode_function_map()); | 1380 native_context()->strict_mode_function_map()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 // doesn't inherit from Object.prototype. | 1588 // doesn't inherit from Object.prototype. |
| 1571 // To be used only for internal work by builtins. Instances | 1589 // To be used only for internal work by builtins. Instances |
| 1572 // must not be leaked to user code. | 1590 // must not be leaked to user code. |
| 1573 Handle<JSFunction> array_function = | 1591 Handle<JSFunction> array_function = |
| 1574 InstallFunction(builtins, | 1592 InstallFunction(builtins, |
| 1575 name, | 1593 name, |
| 1576 JS_ARRAY_TYPE, | 1594 JS_ARRAY_TYPE, |
| 1577 JSArray::kSize, | 1595 JSArray::kSize, |
| 1578 isolate()->initial_object_prototype(), | 1596 isolate()->initial_object_prototype(), |
| 1579 Builtins::kInternalArrayCode, | 1597 Builtins::kInternalArrayCode, |
| 1580 true); | 1598 true, true); |
| 1581 Handle<JSObject> prototype = | 1599 Handle<JSObject> prototype = |
| 1582 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1600 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1583 SetPrototype(array_function, prototype); | 1601 SetPrototype(array_function, prototype); |
| 1584 | 1602 |
| 1585 array_function->shared()->set_construct_stub( | 1603 array_function->shared()->set_construct_stub( |
| 1586 isolate()->builtins()->builtin(Builtins::kCommonArrayConstructCode)); | 1604 isolate()->builtins()->builtin(Builtins::kCommonArrayConstructCode)); |
| 1587 | 1605 |
| 1588 array_function->shared()->DontAdaptArguments(); | 1606 array_function->shared()->DontAdaptArguments(); |
| 1589 | 1607 |
| 1590 MaybeObject* maybe_map = array_function->initial_map()->Copy(); | 1608 MaybeObject* maybe_map = array_function->initial_map()->Copy(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1688 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
| 1671 context->set_global_object(*builtins); // override builtins global object | 1689 context->set_global_object(*builtins); // override builtins global object |
| 1672 | 1690 |
| 1673 native_context()->set_runtime_context(*context); | 1691 native_context()->set_runtime_context(*context); |
| 1674 | 1692 |
| 1675 { // -- S c r i p t | 1693 { // -- S c r i p t |
| 1676 // Builtin functions for Script. | 1694 // Builtin functions for Script. |
| 1677 Handle<JSFunction> script_fun = | 1695 Handle<JSFunction> script_fun = |
| 1678 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 1696 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
| 1679 isolate()->initial_object_prototype(), | 1697 isolate()->initial_object_prototype(), |
| 1680 Builtins::kIllegal, false); | 1698 Builtins::kIllegal, false, false); |
| 1681 Handle<JSObject> prototype = | 1699 Handle<JSObject> prototype = |
| 1682 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1700 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1683 SetPrototype(script_fun, prototype); | 1701 SetPrototype(script_fun, prototype); |
| 1684 native_context()->set_script_function(*script_fun); | 1702 native_context()->set_script_function(*script_fun); |
| 1685 | 1703 |
| 1686 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1704 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
| 1687 | 1705 |
| 1688 Handle<DescriptorArray> script_descriptors( | 1706 Handle<DescriptorArray> script_descriptors( |
| 1689 factory()->NewDescriptorArray(0, 13)); | 1707 factory()->NewDescriptorArray(0, 13)); |
| 1690 DescriptorArray::WhitenessWitness witness(*script_descriptors); | 1708 DescriptorArray::WhitenessWitness witness(*script_descriptors); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 heap()->public_set_empty_script(*script); | 1844 heap()->public_set_empty_script(*script); |
| 1827 } | 1845 } |
| 1828 { | 1846 { |
| 1829 // Builtin function for OpaqueReference -- a JSValue-based object, | 1847 // Builtin function for OpaqueReference -- a JSValue-based object, |
| 1830 // that keeps its field isolated from JavaScript code. It may store | 1848 // that keeps its field isolated from JavaScript code. It may store |
| 1831 // objects, that JavaScript code may not access. | 1849 // objects, that JavaScript code may not access. |
| 1832 Handle<JSFunction> opaque_reference_fun = | 1850 Handle<JSFunction> opaque_reference_fun = |
| 1833 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, | 1851 InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, |
| 1834 JSValue::kSize, | 1852 JSValue::kSize, |
| 1835 isolate()->initial_object_prototype(), | 1853 isolate()->initial_object_prototype(), |
| 1836 Builtins::kIllegal, false); | 1854 Builtins::kIllegal, false, false); |
| 1837 Handle<JSObject> prototype = | 1855 Handle<JSObject> prototype = |
| 1838 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1856 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1839 SetPrototype(opaque_reference_fun, prototype); | 1857 SetPrototype(opaque_reference_fun, prototype); |
| 1840 native_context()->set_opaque_reference_function(*opaque_reference_fun); | 1858 native_context()->set_opaque_reference_function(*opaque_reference_fun); |
| 1841 } | 1859 } |
| 1842 | 1860 |
| 1843 // InternalArrays should not use Smi-Only array optimizations. There are too | 1861 // 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 | 1862 // 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 | 1863 // 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 | 1864 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 Handle<JSFunction>::cast( | 1908 Handle<JSFunction>::cast( |
| 1891 GetProperty(isolate(), isolate()->global_object(), key)); | 1909 GetProperty(isolate(), isolate()->global_object(), key)); |
| 1892 Handle<JSObject> proto = | 1910 Handle<JSObject> proto = |
| 1893 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 1911 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
| 1894 | 1912 |
| 1895 // Install the call and the apply functions. | 1913 // Install the call and the apply functions. |
| 1896 Handle<JSFunction> call = | 1914 Handle<JSFunction> call = |
| 1897 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1915 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1898 Handle<JSObject>::null(), | 1916 Handle<JSObject>::null(), |
| 1899 Builtins::kFunctionCall, | 1917 Builtins::kFunctionCall, |
| 1900 false); | 1918 false, false); |
| 1901 Handle<JSFunction> apply = | 1919 Handle<JSFunction> apply = |
| 1902 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1920 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1903 Handle<JSObject>::null(), | 1921 Handle<JSObject>::null(), |
| 1904 Builtins::kFunctionApply, | 1922 Builtins::kFunctionApply, |
| 1905 false); | 1923 false, false); |
| 1906 | 1924 |
| 1907 // Make sure that Function.prototype.call appears to be compiled. | 1925 // Make sure that Function.prototype.call appears to be compiled. |
| 1908 // The code will never be called, but inline caching for call will | 1926 // The code will never be called, but inline caching for call will |
| 1909 // only work if it appears to be compiled. | 1927 // only work if it appears to be compiled. |
| 1910 call->shared()->DontAdaptArguments(); | 1928 call->shared()->DontAdaptArguments(); |
| 1911 ASSERT(call->is_compiled()); | 1929 ASSERT(call->is_compiled()); |
| 1912 | 1930 |
| 1913 // Set the expected parameters for apply to 2; required by builtin. | 1931 // Set the expected parameters for apply to 2; required by builtin. |
| 1914 apply->shared()->set_formal_parameter_count(2); | 1932 apply->shared()->set_formal_parameter_count(2); |
| 1915 | 1933 |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2608 return from + sizeof(NestingCounterType); | 2626 return from + sizeof(NestingCounterType); |
| 2609 } | 2627 } |
| 2610 | 2628 |
| 2611 | 2629 |
| 2612 // Called when the top-level V8 mutex is destroyed. | 2630 // Called when the top-level V8 mutex is destroyed. |
| 2613 void Bootstrapper::FreeThreadResources() { | 2631 void Bootstrapper::FreeThreadResources() { |
| 2614 ASSERT(!IsActive()); | 2632 ASSERT(!IsActive()); |
| 2615 } | 2633 } |
| 2616 | 2634 |
| 2617 } } // namespace v8::internal | 2635 } } // namespace v8::internal |
| OLD | NEW |