| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 Handle<JSBuiltinsObject> builtins_global(global_context_->builtins()); | 828 Handle<JSBuiltinsObject> builtins_global(global_context_->builtins()); |
| 829 global_context_->set_extension(*inner_global); | 829 global_context_->set_extension(*inner_global); |
| 830 global_context_->set_global(*inner_global); | 830 global_context_->set_global(*inner_global); |
| 831 global_context_->set_security_token(*inner_global); | 831 global_context_->set_security_token(*inner_global); |
| 832 static const PropertyAttributes attributes = | 832 static const PropertyAttributes attributes = |
| 833 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 833 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 834 ForceSetProperty(builtins_global, | 834 ForceSetProperty(builtins_global, |
| 835 factory()->LookupAsciiSymbol("global"), | 835 factory()->LookupAsciiSymbol("global"), |
| 836 inner_global, | 836 inner_global, |
| 837 attributes); | 837 attributes); |
| 838 // Setup the reference from the global object to the builtins object. | 838 // Set up the reference from the global object to the builtins object. |
| 839 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 839 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); |
| 840 TransferNamedProperties(inner_global_from_snapshot, inner_global); | 840 TransferNamedProperties(inner_global_from_snapshot, inner_global); |
| 841 TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 841 TransferIndexedProperties(inner_global_from_snapshot, inner_global); |
| 842 } | 842 } |
| 843 | 843 |
| 844 | 844 |
| 845 // This is only called if we are not using snapshots. The equivalent | 845 // This is only called if we are not using snapshots. The equivalent |
| 846 // work in the snapshot case is done in HookUpInnerGlobal. | 846 // work in the snapshot case is done in HookUpInnerGlobal. |
| 847 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 847 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, |
| 848 Handle<JSFunction> empty_function) { | 848 Handle<JSFunction> empty_function) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 0, | 1353 0, |
| 1354 0, | 1354 0, |
| 1355 extension, | 1355 extension, |
| 1356 NULL, | 1356 NULL, |
| 1357 Handle<String>::null(), | 1357 Handle<String>::null(), |
| 1358 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); | 1358 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); |
| 1359 if (function_info.is_null()) return false; | 1359 if (function_info.is_null()) return false; |
| 1360 if (cache != NULL) cache->Add(name, function_info); | 1360 if (cache != NULL) cache->Add(name, function_info); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 // Setup the function context. Conceptually, we should clone the | 1363 // Set up the function context. Conceptually, we should clone the |
| 1364 // function before overwriting the context but since we're in a | 1364 // function before overwriting the context but since we're in a |
| 1365 // single-threaded environment it is not strictly necessary. | 1365 // single-threaded environment it is not strictly necessary. |
| 1366 ASSERT(top_context->IsGlobalContext()); | 1366 ASSERT(top_context->IsGlobalContext()); |
| 1367 Handle<Context> context = | 1367 Handle<Context> context = |
| 1368 Handle<Context>(use_runtime_context | 1368 Handle<Context>(use_runtime_context |
| 1369 ? Handle<Context>(top_context->runtime_context()) | 1369 ? Handle<Context>(top_context->runtime_context()) |
| 1370 : top_context); | 1370 : top_context); |
| 1371 Handle<JSFunction> fun = | 1371 Handle<JSFunction> fun = |
| 1372 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 1372 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
| 1373 | 1373 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 Handle<String> name = factory()->LookupAsciiSymbol("builtins"); | 1440 Handle<String> name = factory()->LookupAsciiSymbol("builtins"); |
| 1441 builtins_fun->shared()->set_instance_class_name(*name); | 1441 builtins_fun->shared()->set_instance_class_name(*name); |
| 1442 | 1442 |
| 1443 // Allocate the builtins object. | 1443 // Allocate the builtins object. |
| 1444 Handle<JSBuiltinsObject> builtins = | 1444 Handle<JSBuiltinsObject> builtins = |
| 1445 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 1445 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); |
| 1446 builtins->set_builtins(*builtins); | 1446 builtins->set_builtins(*builtins); |
| 1447 builtins->set_global_context(*global_context()); | 1447 builtins->set_global_context(*global_context()); |
| 1448 builtins->set_global_receiver(*builtins); | 1448 builtins->set_global_receiver(*builtins); |
| 1449 | 1449 |
| 1450 // Setup the 'global' properties of the builtins object. The | 1450 // Set up the 'global' properties of the builtins object. The |
| 1451 // 'global' property that refers to the global object is the only | 1451 // 'global' property that refers to the global object is the only |
| 1452 // way to get from code running in the builtins context to the | 1452 // way to get from code running in the builtins context to the |
| 1453 // global object. | 1453 // global object. |
| 1454 static const PropertyAttributes attributes = | 1454 static const PropertyAttributes attributes = |
| 1455 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1455 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 1456 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); | 1456 Handle<String> global_symbol = factory()->LookupAsciiSymbol("global"); |
| 1457 Handle<Object> global_obj(global_context()->global()); | 1457 Handle<Object> global_obj(global_context()->global()); |
| 1458 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1458 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 1459 JSObject::SetLocalPropertyIgnoreAttributes( | 1459 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1460 builtins, global_symbol, global_obj, attributes)); | 1460 builtins, global_symbol, global_obj, attributes)); |
| 1461 | 1461 |
| 1462 // Setup the reference from the global object to the builtins object. | 1462 // Set up the reference from the global object to the builtins object. |
| 1463 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); | 1463 JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); |
| 1464 | 1464 |
| 1465 // Create a bridge function that has context in the global context. | 1465 // Create a bridge function that has context in the global context. |
| 1466 Handle<JSFunction> bridge = | 1466 Handle<JSFunction> bridge = |
| 1467 factory()->NewFunction(factory()->empty_symbol(), | 1467 factory()->NewFunction(factory()->empty_symbol(), |
| 1468 factory()->undefined_value()); | 1468 factory()->undefined_value()); |
| 1469 ASSERT(bridge->context() == *isolate()->global_context()); | 1469 ASSERT(bridge->context() == *isolate()->global_context()); |
| 1470 | 1470 |
| 1471 // Allocate the builtins context. | 1471 // Allocate the builtins context. |
| 1472 Handle<Context> context = | 1472 Handle<Context> context = |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 if (!CompileBuiltin(isolate(), i)) return false; | 1676 if (!CompileBuiltin(isolate(), i)) return false; |
| 1677 // TODO(ager): We really only need to install the JS builtin | 1677 // TODO(ager): We really only need to install the JS builtin |
| 1678 // functions on the builtins object after compiling and running | 1678 // functions on the builtins object after compiling and running |
| 1679 // runtime.js. | 1679 // runtime.js. |
| 1680 if (!InstallJSBuiltins(builtins)) return false; | 1680 if (!InstallJSBuiltins(builtins)) return false; |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 InstallNativeFunctions(); | 1683 InstallNativeFunctions(); |
| 1684 | 1684 |
| 1685 // Store the map for the string prototype after the natives has been compiled | 1685 // Store the map for the string prototype after the natives has been compiled |
| 1686 // and the String function has been setup. | 1686 // and the String function has been set up. |
| 1687 Handle<JSFunction> string_function(global_context()->string_function()); | 1687 Handle<JSFunction> string_function(global_context()->string_function()); |
| 1688 ASSERT(JSObject::cast( | 1688 ASSERT(JSObject::cast( |
| 1689 string_function->initial_map()->prototype())->HasFastProperties()); | 1689 string_function->initial_map()->prototype())->HasFastProperties()); |
| 1690 global_context()->set_string_function_prototype_map( | 1690 global_context()->set_string_function_prototype_map( |
| 1691 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 1691 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
| 1692 | 1692 |
| 1693 // Install Function.prototype.call and apply. | 1693 // Install Function.prototype.call and apply. |
| 1694 { Handle<String> key = factory()->function_class_symbol(); | 1694 { Handle<String> key = factory()->function_class_symbol(); |
| 1695 Handle<JSFunction> function = | 1695 Handle<JSFunction> function = |
| 1696 Handle<JSFunction>::cast(GetProperty(isolate()->global(), key)); | 1696 Handle<JSFunction>::cast(GetProperty(isolate()->global(), key)); |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2374 return from + sizeof(NestingCounterType); | 2374 return from + sizeof(NestingCounterType); |
| 2375 } | 2375 } |
| 2376 | 2376 |
| 2377 | 2377 |
| 2378 // Called when the top-level V8 mutex is destroyed. | 2378 // Called when the top-level V8 mutex is destroyed. |
| 2379 void Bootstrapper::FreeThreadResources() { | 2379 void Bootstrapper::FreeThreadResources() { |
| 2380 ASSERT(!IsActive()); | 2380 ASSERT(!IsActive()); |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 } } // namespace v8::internal | 2383 } } // namespace v8::internal |
| OLD | NEW |