Chromium Code Reviews| 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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1662 builtins_fun->initial_map()->set_dictionary_map(true); | 1662 builtins_fun->initial_map()->set_dictionary_map(true); |
| 1663 builtins_fun->initial_map()->set_prototype(heap()->null_value()); | 1663 builtins_fun->initial_map()->set_prototype(heap()->null_value()); |
| 1664 | 1664 |
| 1665 // Allocate the builtins object. | 1665 // Allocate the builtins object. |
| 1666 Handle<JSBuiltinsObject> builtins = | 1666 Handle<JSBuiltinsObject> builtins = |
| 1667 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 1667 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); |
| 1668 builtins->set_builtins(*builtins); | 1668 builtins->set_builtins(*builtins); |
| 1669 builtins->set_native_context(*native_context()); | 1669 builtins->set_native_context(*native_context()); |
| 1670 builtins->set_global_context(*native_context()); | 1670 builtins->set_global_context(*native_context()); |
| 1671 builtins->set_global_receiver(*builtins); | 1671 builtins->set_global_receiver(*builtins); |
| 1672 builtins->set_global_receiver(native_context()->global_proxy()); | |
| 1673 | |
| 1672 | 1674 |
| 1673 // Set up the 'global' properties of the builtins object. The | 1675 // Set up the 'global' properties of the builtins object. The |
| 1674 // 'global' property that refers to the global object is the only | 1676 // 'global' property that refers to the global object is the only |
| 1675 // way to get from code running in the builtins context to the | 1677 // way to get from code running in the builtins context to the |
| 1676 // global object. | 1678 // global object. |
| 1677 static const PropertyAttributes attributes = | 1679 static const PropertyAttributes attributes = |
| 1678 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1680 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 1679 Handle<String> global_string = | 1681 Handle<String> global_string = |
| 1680 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); | 1682 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); |
| 1681 Handle<Object> global_obj(native_context()->global_object(), isolate()); | 1683 Handle<Object> global_obj(native_context()->global_object(), isolate()); |
| 1682 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1684 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 1683 JSObject::SetLocalPropertyIgnoreAttributes( | 1685 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1684 builtins, global_string, global_obj, attributes)); | 1686 builtins, global_string, global_obj, attributes)); |
| 1687 Handle<String> builtins_string = | |
| 1688 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); | |
| 1689 CHECK_NOT_EMPTY_HANDLE(isolate(), | |
| 1690 JSObject::SetLocalPropertyIgnoreAttributes( | |
| 1691 builtins, builtins_string, builtins, attributes)); | |
| 1685 | 1692 |
| 1686 // Set up the reference from the global object to the builtins object. | 1693 // Set up the reference from the global object to the builtins object. |
| 1687 JSGlobalObject::cast(native_context()->global_object())-> | 1694 JSGlobalObject::cast(native_context()->global_object())-> |
| 1688 set_builtins(*builtins); | 1695 set_builtins(*builtins); |
| 1689 | 1696 |
| 1690 // Create a bridge function that has context in the native context. | 1697 // Create a bridge function that has context in the native context. |
| 1691 Handle<JSFunction> bridge = | 1698 Handle<JSFunction> bridge = |
| 1692 factory()->NewFunction(factory()->empty_string(), | 1699 factory()->NewFunction(factory()->empty_string(), |
| 1693 factory()->undefined_value()); | 1700 factory()->undefined_value()); |
| 1694 ASSERT(bridge->context() == *isolate()->native_context()); | 1701 ASSERT(bridge->context() == *isolate()->native_context()); |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2595 InitializeGlobal(inner_global, empty_function); | 2602 InitializeGlobal(inner_global, empty_function); |
| 2596 InstallJSFunctionResultCaches(); | 2603 InstallJSFunctionResultCaches(); |
| 2597 InitializeNormalizedMapCaches(); | 2604 InitializeNormalizedMapCaches(); |
| 2598 if (!InstallNatives()) return; | 2605 if (!InstallNatives()) return; |
| 2599 | 2606 |
| 2600 MakeFunctionInstancePrototypeWritable(); | 2607 MakeFunctionInstancePrototypeWritable(); |
| 2601 | 2608 |
| 2602 if (!ConfigureGlobalObjects(global_template)) return; | 2609 if (!ConfigureGlobalObjects(global_template)) return; |
| 2603 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2610 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 2604 } | 2611 } |
| 2612 native_context()->builtins()->set_global_receiver( | |
| 2613 native_context()->global_proxy()); | |
|
Toon Verwaest
2013/12/18 13:09:33
I think we should only be doing this if we are des
| |
| 2614 | |
| 2605 | 2615 |
| 2606 // Initialize experimental globals and install experimental natives. | 2616 // Initialize experimental globals and install experimental natives. |
| 2607 InitializeExperimentalGlobal(); | 2617 InitializeExperimentalGlobal(); |
| 2608 if (!InstallExperimentalNatives()) return; | 2618 if (!InstallExperimentalNatives()) return; |
| 2609 | 2619 |
| 2610 // We can't (de-)serialize typed arrays currently, but we are lucky: The state | 2620 // We can't (de-)serialize typed arrays currently, but we are lucky: The state |
| 2611 // of the random number generator needs no initialization during snapshot | 2621 // of the random number generator needs no initialization during snapshot |
| 2612 // creation time and we don't need trigonometric functions then. | 2622 // creation time and we don't need trigonometric functions then. |
| 2613 if (!Serializer::enabled()) { | 2623 if (!Serializer::enabled()) { |
| 2614 // Initially seed the per-context random number generator using the | 2624 // Initially seed the per-context random number generator using the |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2695 return from + sizeof(NestingCounterType); | 2705 return from + sizeof(NestingCounterType); |
| 2696 } | 2706 } |
| 2697 | 2707 |
| 2698 | 2708 |
| 2699 // Called when the top-level V8 mutex is destroyed. | 2709 // Called when the top-level V8 mutex is destroyed. |
| 2700 void Bootstrapper::FreeThreadResources() { | 2710 void Bootstrapper::FreeThreadResources() { |
| 2701 ASSERT(!IsActive()); | 2711 ASSERT(!IsActive()); |
| 2702 } | 2712 } |
| 2703 | 2713 |
| 2704 } } // namespace v8::internal | 2714 } } // namespace v8::internal |
| OLD | NEW |