| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, | 347 static Handle<JSFunction> InstallFunction(Handle<JSObject> target, |
| 348 const char* name, | 348 const char* name, |
| 349 InstanceType type, | 349 InstanceType type, |
| 350 int instance_size, | 350 int instance_size, |
| 351 Handle<JSObject> prototype, | 351 Handle<JSObject> prototype, |
| 352 Builtins::Name call, | 352 Builtins::Name call, |
| 353 bool is_ecma_native) { | 353 bool is_ecma_native) { |
| 354 Isolate* isolate = target->GetIsolate(); | 354 Isolate* isolate = target->GetIsolate(); |
| 355 Factory* factory = isolate->factory(); | 355 Factory* factory = isolate->factory(); |
| 356 Handle<String> symbol = factory->LookupAsciiSymbol(name); | 356 Handle<String> symbol = factory->LookupUtf8Symbol(name); |
| 357 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 357 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); |
| 358 Handle<JSFunction> function = prototype.is_null() ? | 358 Handle<JSFunction> function = prototype.is_null() ? |
| 359 factory->NewFunctionWithoutPrototype(symbol, call_code) : | 359 factory->NewFunctionWithoutPrototype(symbol, call_code) : |
| 360 factory->NewFunctionWithPrototype(symbol, | 360 factory->NewFunctionWithPrototype(symbol, |
| 361 type, | 361 type, |
| 362 instance_size, | 362 instance_size, |
| 363 prototype, | 363 prototype, |
| 364 call_code, | 364 call_code, |
| 365 is_ecma_native); | 365 is_ecma_native); |
| 366 PropertyAttributes attributes; | 366 PropertyAttributes attributes; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 Handle<JSObject> prototype = factory->NewJSObject( | 481 Handle<JSObject> prototype = factory->NewJSObject( |
| 482 isolate->object_function(), | 482 isolate->object_function(), |
| 483 TENURED); | 483 TENURED); |
| 484 | 484 |
| 485 native_context()->set_initial_object_prototype(*prototype); | 485 native_context()->set_initial_object_prototype(*prototype); |
| 486 SetPrototype(object_fun, prototype); | 486 SetPrototype(object_fun, prototype); |
| 487 } | 487 } |
| 488 | 488 |
| 489 // Allocate the empty function as the prototype for function ECMAScript | 489 // Allocate the empty function as the prototype for function ECMAScript |
| 490 // 262 15.3.4. | 490 // 262 15.3.4. |
| 491 Handle<String> symbol = factory->LookupAsciiSymbol("Empty"); | 491 Handle<String> symbol = |
| 492 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("Empty")); |
| 492 Handle<JSFunction> empty_function = | 493 Handle<JSFunction> empty_function = |
| 493 factory->NewFunctionWithoutPrototype(symbol, CLASSIC_MODE); | 494 factory->NewFunctionWithoutPrototype(symbol, CLASSIC_MODE); |
| 494 | 495 |
| 495 // --- E m p t y --- | 496 // --- E m p t y --- |
| 496 Handle<Code> code = | 497 Handle<Code> code = |
| 497 Handle<Code>(isolate->builtins()->builtin( | 498 Handle<Code>(isolate->builtins()->builtin( |
| 498 Builtins::kEmptyFunction)); | 499 Builtins::kEmptyFunction)); |
| 499 empty_function->set_code(*code); | 500 empty_function->set_code(*code); |
| 500 empty_function->shared()->set_code(*code); | 501 empty_function->shared()->set_code(*code); |
| 501 Handle<String> source = factory->NewStringFromAscii(CStrVector("() {}")); | 502 Handle<String> source = factory->NewStringFromAscii(CStrVector("() {}")); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 564 } |
| 564 CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); | 565 CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); |
| 565 map->AppendDescriptor(&d, witness); | 566 map->AppendDescriptor(&d, witness); |
| 566 } | 567 } |
| 567 } | 568 } |
| 568 | 569 |
| 569 | 570 |
| 570 // ECMAScript 5th Edition, 13.2.3 | 571 // ECMAScript 5th Edition, 13.2.3 |
| 571 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { | 572 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { |
| 572 if (throw_type_error_function.is_null()) { | 573 if (throw_type_error_function.is_null()) { |
| 573 Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError"); | 574 Handle<String> name = factory()->LookupOneByteSymbol( |
| 575 STATIC_ASCII_VECTOR("ThrowTypeError")); |
| 574 throw_type_error_function = | 576 throw_type_error_function = |
| 575 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); | 577 factory()->NewFunctionWithoutPrototype(name, CLASSIC_MODE); |
| 576 Handle<Code> code(isolate()->builtins()->builtin( | 578 Handle<Code> code(isolate()->builtins()->builtin( |
| 577 Builtins::kStrictModePoisonPill)); | 579 Builtins::kStrictModePoisonPill)); |
| 578 throw_type_error_function->set_map( | 580 throw_type_error_function->set_map( |
| 579 native_context()->function_map()); | 581 native_context()->function_map()); |
| 580 throw_type_error_function->set_code(*code); | 582 throw_type_error_function->set_code(*code); |
| 581 throw_type_error_function->shared()->set_code(*code); | 583 throw_type_error_function->shared()->set_code(*code); |
| 582 throw_type_error_function->shared()->DontAdaptArguments(); | 584 throw_type_error_function->shared()->DontAdaptArguments(); |
| 583 | 585 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } else { | 766 } else { |
| 765 Handle<ObjectTemplateInfo> data = | 767 Handle<ObjectTemplateInfo> data = |
| 766 v8::Utils::OpenHandle(*global_template); | 768 v8::Utils::OpenHandle(*global_template); |
| 767 Handle<FunctionTemplateInfo> global_constructor( | 769 Handle<FunctionTemplateInfo> global_constructor( |
| 768 FunctionTemplateInfo::cast(data->constructor())); | 770 FunctionTemplateInfo::cast(data->constructor())); |
| 769 global_proxy_function = | 771 global_proxy_function = |
| 770 factory()->CreateApiFunction(global_constructor, | 772 factory()->CreateApiFunction(global_constructor, |
| 771 factory()->OuterGlobalObject); | 773 factory()->OuterGlobalObject); |
| 772 } | 774 } |
| 773 | 775 |
| 774 Handle<String> global_name = factory()->LookupAsciiSymbol("global"); | 776 Handle<String> global_name = factory()->LookupOneByteSymbol( |
| 777 STATIC_ASCII_VECTOR("global")); |
| 775 global_proxy_function->shared()->set_instance_class_name(*global_name); | 778 global_proxy_function->shared()->set_instance_class_name(*global_name); |
| 776 global_proxy_function->initial_map()->set_is_access_check_needed(true); | 779 global_proxy_function->initial_map()->set_is_access_check_needed(true); |
| 777 | 780 |
| 778 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects | 781 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects |
| 779 // Return the global proxy. | 782 // Return the global proxy. |
| 780 | 783 |
| 781 if (global_object.location() != NULL) { | 784 if (global_object.location() != NULL) { |
| 782 ASSERT(global_object->IsJSGlobalProxy()); | 785 ASSERT(global_object->IsJSGlobalProxy()); |
| 783 return ReinitializeJSGlobalProxy( | 786 return ReinitializeJSGlobalProxy( |
| 784 global_proxy_function, | 787 global_proxy_function, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 804 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { | 807 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { |
| 805 Handle<GlobalObject> inner_global_from_snapshot( | 808 Handle<GlobalObject> inner_global_from_snapshot( |
| 806 GlobalObject::cast(native_context_->extension())); | 809 GlobalObject::cast(native_context_->extension())); |
| 807 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins()); | 810 Handle<JSBuiltinsObject> builtins_global(native_context_->builtins()); |
| 808 native_context_->set_extension(*inner_global); | 811 native_context_->set_extension(*inner_global); |
| 809 native_context_->set_global_object(*inner_global); | 812 native_context_->set_global_object(*inner_global); |
| 810 native_context_->set_security_token(*inner_global); | 813 native_context_->set_security_token(*inner_global); |
| 811 static const PropertyAttributes attributes = | 814 static const PropertyAttributes attributes = |
| 812 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 815 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 813 ForceSetProperty(builtins_global, | 816 ForceSetProperty(builtins_global, |
| 814 factory()->LookupAsciiSymbol("global"), | 817 factory()->LookupOneByteSymbol( |
| 818 STATIC_ASCII_VECTOR("global")), |
| 815 inner_global, | 819 inner_global, |
| 816 attributes); | 820 attributes); |
| 817 // Set up the reference from the global object to the builtins object. | 821 // Set up the reference from the global object to the builtins object. |
| 818 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 822 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); |
| 819 TransferNamedProperties(inner_global_from_snapshot, inner_global); | 823 TransferNamedProperties(inner_global_from_snapshot, inner_global); |
| 820 TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 824 TransferIndexedProperties(inner_global_from_snapshot, inner_global); |
| 821 } | 825 } |
| 822 | 826 |
| 823 | 827 |
| 824 // This is only called if we are not using snapshots. The equivalent | 828 // This is only called if we are not using snapshots. The equivalent |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 CHECK_NOT_EMPTY_HANDLE(isolate, | 1046 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1043 JSObject::SetLocalPropertyIgnoreAttributes( | 1047 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1044 global, name, json_object, DONT_ENUM)); | 1048 global, name, json_object, DONT_ENUM)); |
| 1045 native_context()->set_json_object(*json_object); | 1049 native_context()->set_json_object(*json_object); |
| 1046 } | 1050 } |
| 1047 | 1051 |
| 1048 { // --- arguments_boilerplate_ | 1052 { // --- arguments_boilerplate_ |
| 1049 // Make sure we can recognize argument objects at runtime. | 1053 // Make sure we can recognize argument objects at runtime. |
| 1050 // This is done by introducing an anonymous function with | 1054 // This is done by introducing an anonymous function with |
| 1051 // class_name equals 'Arguments'. | 1055 // class_name equals 'Arguments'. |
| 1052 Handle<String> symbol = factory->LookupAsciiSymbol("Arguments"); | 1056 Handle<String> symbol = factory->LookupOneByteSymbol( |
| 1057 STATIC_ASCII_VECTOR("Arguments")); |
| 1053 Handle<Code> code = Handle<Code>( | 1058 Handle<Code> code = Handle<Code>( |
| 1054 isolate->builtins()->builtin(Builtins::kIllegal)); | 1059 isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1055 Handle<JSObject> prototype = | 1060 Handle<JSObject> prototype = |
| 1056 Handle<JSObject>( | 1061 Handle<JSObject>( |
| 1057 JSObject::cast(native_context()->object_function()->prototype())); | 1062 JSObject::cast(native_context()->object_function()->prototype())); |
| 1058 | 1063 |
| 1059 Handle<JSFunction> function = | 1064 Handle<JSFunction> function = |
| 1060 factory->NewFunctionWithPrototype(symbol, | 1065 factory->NewFunctionWithPrototype(symbol, |
| 1061 JS_OBJECT_TYPE, | 1066 JS_OBJECT_TYPE, |
| 1062 JSObject::kHeaderSize, | 1067 JSObject::kHeaderSize, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 // Create a function for the context extension objects. | 1205 // Create a function for the context extension objects. |
| 1201 Handle<Code> code = Handle<Code>( | 1206 Handle<Code> code = Handle<Code>( |
| 1202 isolate->builtins()->builtin(Builtins::kIllegal)); | 1207 isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1203 Handle<JSFunction> context_extension_fun = | 1208 Handle<JSFunction> context_extension_fun = |
| 1204 factory->NewFunction(factory->empty_symbol(), | 1209 factory->NewFunction(factory->empty_symbol(), |
| 1205 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 1210 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
| 1206 JSObject::kHeaderSize, | 1211 JSObject::kHeaderSize, |
| 1207 code, | 1212 code, |
| 1208 true); | 1213 true); |
| 1209 | 1214 |
| 1210 Handle<String> name = factory->LookupAsciiSymbol("context_extension"); | 1215 Handle<String> name = |
| 1216 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("context_extension")); |
| 1211 context_extension_fun->shared()->set_instance_class_name(*name); | 1217 context_extension_fun->shared()->set_instance_class_name(*name); |
| 1212 native_context()->set_context_extension_function(*context_extension_fun); | 1218 native_context()->set_context_extension_function(*context_extension_fun); |
| 1213 } | 1219 } |
| 1214 | 1220 |
| 1215 | 1221 |
| 1216 { | 1222 { |
| 1217 // Set up the call-as-function delegate. | 1223 // Set up the call-as-function delegate. |
| 1218 Handle<Code> code = | 1224 Handle<Code> code = |
| 1219 Handle<Code>(isolate->builtins()->builtin( | 1225 Handle<Code>(isolate->builtins()->builtin( |
| 1220 Builtins::kHandleApiCallAsFunction)); | 1226 Builtins::kHandleApiCallAsFunction)); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 Handle<Object>(use_runtime_context | 1380 Handle<Object>(use_runtime_context |
| 1375 ? top_context->builtins() | 1381 ? top_context->builtins() |
| 1376 : top_context->global_object()); | 1382 : top_context->global_object()); |
| 1377 bool has_pending_exception; | 1383 bool has_pending_exception; |
| 1378 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1384 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1379 if (has_pending_exception) return false; | 1385 if (has_pending_exception) return false; |
| 1380 return true; | 1386 return true; |
| 1381 } | 1387 } |
| 1382 | 1388 |
| 1383 | 1389 |
| 1384 #define INSTALL_NATIVE(Type, name, var) \ | 1390 #define INSTALL_NATIVE(Type, name, var) \ |
| 1385 Handle<String> var##_name = factory()->LookupAsciiSymbol(name); \ | 1391 Handle<String> var##_name = \ |
| 1386 Object* var##_native = \ | 1392 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR(name)); \ |
| 1387 native_context()->builtins()->GetPropertyNoExceptionThrown( \ | 1393 Object* var##_native = \ |
| 1388 *var##_name); \ | 1394 native_context()->builtins()->GetPropertyNoExceptionThrown( \ |
| 1395 *var##_name); \ |
| 1389 native_context()->set_##var(Type::cast(var##_native)); | 1396 native_context()->set_##var(Type::cast(var##_native)); |
| 1390 | 1397 |
| 1391 | 1398 |
| 1392 void Genesis::InstallNativeFunctions() { | 1399 void Genesis::InstallNativeFunctions() { |
| 1393 HandleScope scope; | 1400 HandleScope scope; |
| 1394 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1401 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); |
| 1395 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | 1402 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); |
| 1396 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | 1403 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); |
| 1397 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | 1404 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); |
| 1398 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); | 1405 INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 // Create a function for the builtins object. Allocate space for the | 1439 // Create a function for the builtins object. Allocate space for the |
| 1433 // JavaScript builtins, a reference to the builtins object | 1440 // JavaScript builtins, a reference to the builtins object |
| 1434 // (itself) and a reference to the native_context directly in the object. | 1441 // (itself) and a reference to the native_context directly in the object. |
| 1435 Handle<Code> code = Handle<Code>( | 1442 Handle<Code> code = Handle<Code>( |
| 1436 isolate()->builtins()->builtin(Builtins::kIllegal)); | 1443 isolate()->builtins()->builtin(Builtins::kIllegal)); |
| 1437 Handle<JSFunction> builtins_fun = | 1444 Handle<JSFunction> builtins_fun = |
| 1438 factory()->NewFunction(factory()->empty_symbol(), | 1445 factory()->NewFunction(factory()->empty_symbol(), |
| 1439 JS_BUILTINS_OBJECT_TYPE, | 1446 JS_BUILTINS_OBJECT_TYPE, |
| 1440 JSBuiltinsObject::kSize, code, true); | 1447 JSBuiltinsObject::kSize, code, true); |
| 1441 | 1448 |
| 1442 Handle<String> name = factory()->LookupAsciiSymbol("builtins"); | 1449 Handle<String> name = |
| 1450 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("builtins")); |
| 1443 builtins_fun->shared()->set_instance_class_name(*name); | 1451 builtins_fun->shared()->set_instance_class_name(*name); |
| 1444 builtins_fun->initial_map()->set_dictionary_map(true); | 1452 builtins_fun->initial_map()->set_dictionary_map(true); |
| 1445 builtins_fun->initial_map()->set_prototype(heap()->null_value()); | 1453 builtins_fun->initial_map()->set_prototype(heap()->null_value()); |
| 1446 | 1454 |
| 1447 // Allocate the builtins object. | 1455 // Allocate the builtins object. |
| 1448 Handle<JSBuiltinsObject> builtins = | 1456 Handle<JSBuiltinsObject> builtins = |
| 1449 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 1457 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); |
| 1450 builtins->set_builtins(*builtins); | 1458 builtins->set_builtins(*builtins); |
| 1451 builtins->set_native_context(*native_context()); | 1459 builtins->set_native_context(*native_context()); |
| 1452 builtins->set_global_context(*native_context()); | 1460 builtins->set_global_context(*native_context()); |
| 1453 builtins->set_global_receiver(*builtins); | 1461 builtins->set_global_receiver(*builtins); |
| 1454 | 1462 |
| 1455 // Set up the 'global' properties of the builtins object. The | 1463 // Set up the 'global' properties of the builtins object. The |
| 1456 // 'global' property that refers to the global object is the only | 1464 // 'global' property that refers to the global object is the only |
| 1457 // way to get from code running in the builtins context to the | 1465 // way to get from code running in the builtins context to the |
| 1458 // global object. | 1466 // global object. |
| 1459 static const PropertyAttributes attributes = | 1467 static const PropertyAttributes attributes = |
| 1460 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1468 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 1461 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 1469 Handle<String> global_symbol = |
| 1470 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("global")); |
| 1462 Handle<Object> global_obj(native_context()->global_object()); | 1471 Handle<Object> global_obj(native_context()->global_object()); |
| 1463 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1472 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 1464 JSObject::SetLocalPropertyIgnoreAttributes( | 1473 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1465 builtins, global_symbol, global_obj, attributes)); | 1474 builtins, global_symbol, global_obj, attributes)); |
| 1466 | 1475 |
| 1467 // Set up the reference from the global object to the builtins object. | 1476 // Set up the reference from the global object to the builtins object. |
| 1468 JSGlobalObject::cast(native_context()->global_object())-> | 1477 JSGlobalObject::cast(native_context()->global_object())-> |
| 1469 set_builtins(*builtins); | 1478 set_builtins(*builtins); |
| 1470 | 1479 |
| 1471 // Create a bridge function that has context in the native context. | 1480 // Create a bridge function that has context in the native context. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1494 | 1503 |
| 1495 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1504 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
| 1496 | 1505 |
| 1497 Handle<DescriptorArray> script_descriptors( | 1506 Handle<DescriptorArray> script_descriptors( |
| 1498 factory()->NewDescriptorArray(0, 13)); | 1507 factory()->NewDescriptorArray(0, 13)); |
| 1499 DescriptorArray::WhitenessWitness witness(*script_descriptors); | 1508 DescriptorArray::WhitenessWitness witness(*script_descriptors); |
| 1500 | 1509 |
| 1501 Handle<Foreign> script_source( | 1510 Handle<Foreign> script_source( |
| 1502 factory()->NewForeign(&Accessors::ScriptSource)); | 1511 factory()->NewForeign(&Accessors::ScriptSource)); |
| 1503 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); | 1512 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); |
| 1504 Handle<String> id_symbol(factory()->LookupAsciiSymbol("id")); | 1513 Handle<String> id_symbol(factory()->LookupOneByteSymbol( |
| 1514 STATIC_ASCII_VECTOR("id"))); |
| 1505 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); | 1515 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); |
| 1506 Handle<String> line_offset_symbol( | 1516 Handle<String> line_offset_symbol( |
| 1507 factory()->LookupAsciiSymbol("line_offset")); | 1517 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("line_offset"))); |
| 1508 Handle<Foreign> script_line_offset( | 1518 Handle<Foreign> script_line_offset( |
| 1509 factory()->NewForeign(&Accessors::ScriptLineOffset)); | 1519 factory()->NewForeign(&Accessors::ScriptLineOffset)); |
| 1510 Handle<String> column_offset_symbol( | 1520 Handle<String> column_offset_symbol( |
| 1511 factory()->LookupAsciiSymbol("column_offset")); | 1521 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("column_offset"))); |
| 1512 Handle<Foreign> script_column_offset( | 1522 Handle<Foreign> script_column_offset( |
| 1513 factory()->NewForeign(&Accessors::ScriptColumnOffset)); | 1523 factory()->NewForeign(&Accessors::ScriptColumnOffset)); |
| 1514 Handle<String> data_symbol(factory()->LookupAsciiSymbol("data")); | 1524 Handle<String> data_symbol(factory()->LookupOneByteSymbol( |
| 1525 STATIC_ASCII_VECTOR("data"))); |
| 1515 Handle<Foreign> script_data(factory()->NewForeign(&Accessors::ScriptData)); | 1526 Handle<Foreign> script_data(factory()->NewForeign(&Accessors::ScriptData)); |
| 1516 Handle<String> type_symbol(factory()->LookupAsciiSymbol("type")); | 1527 Handle<String> type_symbol(factory()->LookupOneByteSymbol( |
| 1528 STATIC_ASCII_VECTOR("type"))); |
| 1517 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType)); | 1529 Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType)); |
| 1518 Handle<String> compilation_type_symbol( | 1530 Handle<String> compilation_type_symbol( |
| 1519 factory()->LookupAsciiSymbol("compilation_type")); | 1531 factory()->LookupOneByteSymbol( |
| 1532 STATIC_ASCII_VECTOR("compilation_type"))); |
| 1520 Handle<Foreign> script_compilation_type( | 1533 Handle<Foreign> script_compilation_type( |
| 1521 factory()->NewForeign(&Accessors::ScriptCompilationType)); | 1534 factory()->NewForeign(&Accessors::ScriptCompilationType)); |
| 1522 Handle<String> line_ends_symbol(factory()->LookupAsciiSymbol("line_ends")); | 1535 Handle<String> line_ends_symbol(factory()->LookupOneByteSymbol( |
| 1536 STATIC_ASCII_VECTOR("line_ends"))); |
| 1523 Handle<Foreign> script_line_ends( | 1537 Handle<Foreign> script_line_ends( |
| 1524 factory()->NewForeign(&Accessors::ScriptLineEnds)); | 1538 factory()->NewForeign(&Accessors::ScriptLineEnds)); |
| 1525 Handle<String> context_data_symbol( | 1539 Handle<String> context_data_symbol( |
| 1526 factory()->LookupAsciiSymbol("context_data")); | 1540 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("context_data"))); |
| 1527 Handle<Foreign> script_context_data( | 1541 Handle<Foreign> script_context_data( |
| 1528 factory()->NewForeign(&Accessors::ScriptContextData)); | 1542 factory()->NewForeign(&Accessors::ScriptContextData)); |
| 1529 Handle<String> eval_from_script_symbol( | 1543 Handle<String> eval_from_script_symbol( |
| 1530 factory()->LookupAsciiSymbol("eval_from_script")); | 1544 factory()->LookupOneByteSymbol( |
| 1545 STATIC_ASCII_VECTOR("eval_from_script"))); |
| 1531 Handle<Foreign> script_eval_from_script( | 1546 Handle<Foreign> script_eval_from_script( |
| 1532 factory()->NewForeign(&Accessors::ScriptEvalFromScript)); | 1547 factory()->NewForeign(&Accessors::ScriptEvalFromScript)); |
| 1533 Handle<String> eval_from_script_position_symbol( | 1548 Handle<String> eval_from_script_position_symbol( |
| 1534 factory()->LookupAsciiSymbol("eval_from_script_position")); | 1549 factory()->LookupOneByteSymbol( |
| 1550 STATIC_ASCII_VECTOR("eval_from_script_position"))); |
| 1535 Handle<Foreign> script_eval_from_script_position( | 1551 Handle<Foreign> script_eval_from_script_position( |
| 1536 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); | 1552 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); |
| 1537 Handle<String> eval_from_function_name_symbol( | 1553 Handle<String> eval_from_function_name_symbol( |
| 1538 factory()->LookupAsciiSymbol("eval_from_function_name")); | 1554 factory()->LookupOneByteSymbol( |
| 1555 STATIC_ASCII_VECTOR("eval_from_function_name"))); |
| 1539 Handle<Foreign> script_eval_from_function_name( | 1556 Handle<Foreign> script_eval_from_function_name( |
| 1540 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); | 1557 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); |
| 1541 PropertyAttributes attribs = | 1558 PropertyAttributes attribs = |
| 1542 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1559 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 1543 script_map->set_instance_descriptors(*script_descriptors); | 1560 script_map->set_instance_descriptors(*script_descriptors); |
| 1544 | 1561 |
| 1545 { | 1562 { |
| 1546 CallbacksDescriptor d( | 1563 CallbacksDescriptor d( |
| 1547 *factory()->source_symbol(), *script_source, attribs); | 1564 *factory()->source_symbol(), *script_source, attribs); |
| 1548 script_map->AppendDescriptor(&d, witness); | 1565 script_map->AppendDescriptor(&d, witness); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 | 1865 |
| 1849 | 1866 |
| 1850 static Handle<JSObject> ResolveBuiltinIdHolder( | 1867 static Handle<JSObject> ResolveBuiltinIdHolder( |
| 1851 Handle<Context> native_context, | 1868 Handle<Context> native_context, |
| 1852 const char* holder_expr) { | 1869 const char* holder_expr) { |
| 1853 Factory* factory = native_context->GetIsolate()->factory(); | 1870 Factory* factory = native_context->GetIsolate()->factory(); |
| 1854 Handle<GlobalObject> global(native_context->global_object()); | 1871 Handle<GlobalObject> global(native_context->global_object()); |
| 1855 const char* period_pos = strchr(holder_expr, '.'); | 1872 const char* period_pos = strchr(holder_expr, '.'); |
| 1856 if (period_pos == NULL) { | 1873 if (period_pos == NULL) { |
| 1857 return Handle<JSObject>::cast( | 1874 return Handle<JSObject>::cast( |
| 1858 GetProperty(global, factory->LookupAsciiSymbol(holder_expr))); | 1875 GetProperty(global, factory->LookupUtf8Symbol(holder_expr))); |
| 1859 } | 1876 } |
| 1860 ASSERT_EQ(".prototype", period_pos); | 1877 ASSERT_EQ(".prototype", period_pos); |
| 1861 Vector<const char> property(holder_expr, | 1878 Vector<const char> property(holder_expr, |
| 1862 static_cast<int>(period_pos - holder_expr)); | 1879 static_cast<int>(period_pos - holder_expr)); |
| 1863 Handle<JSFunction> function = Handle<JSFunction>::cast( | 1880 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 1864 GetProperty(global, factory->LookupSymbol(property))); | 1881 GetProperty(global, factory->LookupUtf8Symbol(property))); |
| 1865 return Handle<JSObject>(JSObject::cast(function->prototype())); | 1882 return Handle<JSObject>(JSObject::cast(function->prototype())); |
| 1866 } | 1883 } |
| 1867 | 1884 |
| 1868 | 1885 |
| 1869 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 1886 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
| 1870 const char* function_name, | 1887 const char* function_name, |
| 1871 BuiltinFunctionId id) { | 1888 BuiltinFunctionId id) { |
| 1872 Factory* factory = holder->GetIsolate()->factory(); | 1889 Factory* factory = holder->GetIsolate()->factory(); |
| 1873 Handle<String> name = factory->LookupAsciiSymbol(function_name); | 1890 Handle<String> name = factory->LookupUtf8Symbol(function_name); |
| 1874 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); | 1891 Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); |
| 1875 Handle<JSFunction> function(JSFunction::cast(function_object)); | 1892 Handle<JSFunction> function(JSFunction::cast(function_object)); |
| 1876 function->shared()->set_function_data(Smi::FromInt(id)); | 1893 function->shared()->set_function_data(Smi::FromInt(id)); |
| 1877 } | 1894 } |
| 1878 | 1895 |
| 1879 | 1896 |
| 1880 void Genesis::InstallBuiltinFunctionIds() { | 1897 void Genesis::InstallBuiltinFunctionIds() { |
| 1881 HandleScope scope; | 1898 HandleScope scope; |
| 1882 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ | 1899 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ |
| 1883 { \ | 1900 { \ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 | 1971 |
| 1955 | 1972 |
| 1956 void Genesis::InstallSpecialObjects(Handle<Context> native_context) { | 1973 void Genesis::InstallSpecialObjects(Handle<Context> native_context) { |
| 1957 Isolate* isolate = native_context->GetIsolate(); | 1974 Isolate* isolate = native_context->GetIsolate(); |
| 1958 Factory* factory = isolate->factory(); | 1975 Factory* factory = isolate->factory(); |
| 1959 HandleScope scope; | 1976 HandleScope scope; |
| 1960 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 1977 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
| 1961 native_context->global_object())); | 1978 native_context->global_object())); |
| 1962 // Expose the natives in global if a name for it is specified. | 1979 // Expose the natives in global if a name for it is specified. |
| 1963 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 1980 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
| 1964 Handle<String> natives = factory->LookupAsciiSymbol(FLAG_expose_natives_as); | 1981 Handle<String> natives = factory->LookupUtf8Symbol(FLAG_expose_natives_as); |
| 1965 CHECK_NOT_EMPTY_HANDLE(isolate, | 1982 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1966 JSObject::SetLocalPropertyIgnoreAttributes( | 1983 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1967 global, natives, | 1984 global, natives, |
| 1968 Handle<JSObject>(global->builtins()), | 1985 Handle<JSObject>(global->builtins()), |
| 1969 DONT_ENUM)); | 1986 DONT_ENUM)); |
| 1970 } | 1987 } |
| 1971 | 1988 |
| 1972 Handle<Object> Error = GetProperty(global, "Error"); | 1989 Handle<Object> Error = GetProperty(global, "Error"); |
| 1973 if (Error->IsJSObject()) { | 1990 if (Error->IsJSObject()) { |
| 1974 Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit"); | 1991 Handle<String> name = |
| 1992 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("stackTraceLimit")); |
| 1975 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); | 1993 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); |
| 1976 CHECK_NOT_EMPTY_HANDLE(isolate, | 1994 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1977 JSObject::SetLocalPropertyIgnoreAttributes( | 1995 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1978 Handle<JSObject>::cast(Error), name, | 1996 Handle<JSObject>::cast(Error), name, |
| 1979 stack_trace_limit, NONE)); | 1997 stack_trace_limit, NONE)); |
| 1980 } | 1998 } |
| 1981 | 1999 |
| 1982 #ifdef ENABLE_DEBUGGER_SUPPORT | 2000 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1983 // Expose the debug global object in global if a name for it is specified. | 2001 // Expose the debug global object in global if a name for it is specified. |
| 1984 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2002 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
| 1985 Debug* debug = Isolate::Current()->debug(); | 2003 Debug* debug = Isolate::Current()->debug(); |
| 1986 // If loading fails we just bail out without installing the | 2004 // If loading fails we just bail out without installing the |
| 1987 // debugger but without tanking the whole context. | 2005 // debugger but without tanking the whole context. |
| 1988 if (!debug->Load()) return; | 2006 if (!debug->Load()) return; |
| 1989 // Set the security token for the debugger context to the same as | 2007 // Set the security token for the debugger context to the same as |
| 1990 // the shell native context to allow calling between these (otherwise | 2008 // the shell native context to allow calling between these (otherwise |
| 1991 // exposing debug global object doesn't make much sense). | 2009 // exposing debug global object doesn't make much sense). |
| 1992 debug->debug_context()->set_security_token( | 2010 debug->debug_context()->set_security_token( |
| 1993 native_context->security_token()); | 2011 native_context->security_token()); |
| 1994 | 2012 |
| 1995 Handle<String> debug_string = | 2013 Handle<String> debug_string = |
| 1996 factory->LookupAsciiSymbol(FLAG_expose_debug_as); | 2014 factory->LookupUtf8Symbol(FLAG_expose_debug_as); |
| 1997 Handle<Object> global_proxy(debug->debug_context()->global_proxy()); | 2015 Handle<Object> global_proxy(debug->debug_context()->global_proxy()); |
| 1998 CHECK_NOT_EMPTY_HANDLE(isolate, | 2016 CHECK_NOT_EMPTY_HANDLE(isolate, |
| 1999 JSObject::SetLocalPropertyIgnoreAttributes( | 2017 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2000 global, debug_string, global_proxy, DONT_ENUM)); | 2018 global, debug_string, global_proxy, DONT_ENUM)); |
| 2001 } | 2019 } |
| 2002 #endif | 2020 #endif |
| 2003 } | 2021 } |
| 2004 | 2022 |
| 2005 static uint32_t Hash(RegisteredExtension* extension) { | 2023 static uint32_t Hash(RegisteredExtension* extension) { |
| 2006 return v8::internal::ComputePointerHash(extension); | 2024 return v8::internal::ComputePointerHash(extension); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 isolate->NotifyExtensionInstalled(); | 2148 isolate->NotifyExtensionInstalled(); |
| 2131 return result; | 2149 return result; |
| 2132 } | 2150 } |
| 2133 | 2151 |
| 2134 | 2152 |
| 2135 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | 2153 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { |
| 2136 HandleScope scope; | 2154 HandleScope scope; |
| 2137 Factory* factory = builtins->GetIsolate()->factory(); | 2155 Factory* factory = builtins->GetIsolate()->factory(); |
| 2138 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 2156 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
| 2139 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 2157 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
| 2140 Handle<String> name = factory->LookupAsciiSymbol(Builtins::GetName(id)); | 2158 Handle<String> name = factory->LookupUtf8Symbol(Builtins::GetName(id)); |
| 2141 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); | 2159 Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); |
| 2142 Handle<JSFunction> function | 2160 Handle<JSFunction> function |
| 2143 = Handle<JSFunction>(JSFunction::cast(function_object)); | 2161 = Handle<JSFunction>(JSFunction::cast(function_object)); |
| 2144 builtins->set_javascript_builtin(id, *function); | 2162 builtins->set_javascript_builtin(id, *function); |
| 2145 if (!JSFunction::CompileLazy(function, CLEAR_EXCEPTION)) { | 2163 if (!JSFunction::CompileLazy(function, CLEAR_EXCEPTION)) { |
| 2146 return false; | 2164 return false; |
| 2147 } | 2165 } |
| 2148 builtins->set_javascript_builtin_code(id, function->shared()->code()); | 2166 builtins->set_javascript_builtin_code(id, function->shared()->code()); |
| 2149 } | 2167 } |
| 2150 return true; | 2168 return true; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 return from + sizeof(NestingCounterType); | 2428 return from + sizeof(NestingCounterType); |
| 2411 } | 2429 } |
| 2412 | 2430 |
| 2413 | 2431 |
| 2414 // Called when the top-level V8 mutex is destroyed. | 2432 // Called when the top-level V8 mutex is destroyed. |
| 2415 void Bootstrapper::FreeThreadResources() { | 2433 void Bootstrapper::FreeThreadResources() { |
| 2416 ASSERT(!IsActive()); | 2434 ASSERT(!IsActive()); |
| 2417 } | 2435 } |
| 2418 | 2436 |
| 2419 } } // namespace v8::internal | 2437 } } // namespace v8::internal |
| OLD | NEW |