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 | |
1674 | 1672 |
1675 // Set up the 'global' properties of the builtins object. The | 1673 // Set up the 'global' properties of the builtins object. The |
1676 // 'global' property that refers to the global object is the only | 1674 // 'global' property that refers to the global object is the only |
1677 // way to get from code running in the builtins context to the | 1675 // way to get from code running in the builtins context to the |
1678 // global object. | 1676 // global object. |
1679 static const PropertyAttributes attributes = | 1677 static const PropertyAttributes attributes = |
1680 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 1678 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
1681 Handle<String> global_string = | 1679 Handle<String> global_string = |
1682 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); | 1680 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global")); |
1683 Handle<Object> global_obj(native_context()->global_object(), isolate()); | 1681 Handle<Object> global_obj(native_context()->global_object(), isolate()); |
1684 CHECK_NOT_EMPTY_HANDLE(isolate(), | 1682 CHECK_NOT_EMPTY_HANDLE(isolate(), |
1685 JSObject::SetLocalPropertyIgnoreAttributes( | 1683 JSObject::SetLocalPropertyIgnoreAttributes( |
1686 builtins, global_string, global_obj, attributes)); | 1684 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)); | |
1692 | 1685 |
1693 // Set up the reference from the global object to the builtins object. | 1686 // Set up the reference from the global object to the builtins object. |
1694 JSGlobalObject::cast(native_context()->global_object())-> | 1687 JSGlobalObject::cast(native_context()->global_object())-> |
1695 set_builtins(*builtins); | 1688 set_builtins(*builtins); |
1696 | 1689 |
1697 // Create a bridge function that has context in the native context. | 1690 // Create a bridge function that has context in the native context. |
1698 Handle<JSFunction> bridge = | 1691 Handle<JSFunction> bridge = |
1699 factory()->NewFunction(factory()->empty_string(), | 1692 factory()->NewFunction(factory()->empty_string(), |
1700 factory()->undefined_value()); | 1693 factory()->undefined_value()); |
1701 ASSERT(bridge->context() == *isolate()->native_context()); | 1694 ASSERT(bridge->context() == *isolate()->native_context()); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 isolate->set_context(*native_context()); | 2574 isolate->set_context(*native_context()); |
2582 isolate->counters()->contexts_created_by_snapshot()->Increment(); | 2575 isolate->counters()->contexts_created_by_snapshot()->Increment(); |
2583 Handle<GlobalObject> inner_global; | 2576 Handle<GlobalObject> inner_global; |
2584 Handle<JSGlobalProxy> global_proxy = | 2577 Handle<JSGlobalProxy> global_proxy = |
2585 CreateNewGlobals(global_template, | 2578 CreateNewGlobals(global_template, |
2586 global_object, | 2579 global_object, |
2587 &inner_global); | 2580 &inner_global); |
2588 | 2581 |
2589 HookUpGlobalProxy(inner_global, global_proxy); | 2582 HookUpGlobalProxy(inner_global, global_proxy); |
2590 HookUpInnerGlobal(inner_global); | 2583 HookUpInnerGlobal(inner_global); |
2591 native_context()->builtins()->set_global_receiver( | |
2592 native_context()->global_proxy()); | |
2593 | 2584 |
2594 if (!ConfigureGlobalObjects(global_template)) return; | 2585 if (!ConfigureGlobalObjects(global_template)) return; |
2595 } else { | 2586 } else { |
2596 // We get here if there was no context snapshot. | 2587 // We get here if there was no context snapshot. |
2597 CreateRoots(); | 2588 CreateRoots(); |
2598 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 2589 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
2599 CreateStrictModeFunctionMaps(empty_function); | 2590 CreateStrictModeFunctionMaps(empty_function); |
2600 Handle<GlobalObject> inner_global; | 2591 Handle<GlobalObject> inner_global; |
2601 Handle<JSGlobalProxy> global_proxy = | 2592 Handle<JSGlobalProxy> global_proxy = |
2602 CreateNewGlobals(global_template, global_object, &inner_global); | 2593 CreateNewGlobals(global_template, global_object, &inner_global); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 return from + sizeof(NestingCounterType); | 2695 return from + sizeof(NestingCounterType); |
2705 } | 2696 } |
2706 | 2697 |
2707 | 2698 |
2708 // Called when the top-level V8 mutex is destroyed. | 2699 // Called when the top-level V8 mutex is destroyed. |
2709 void Bootstrapper::FreeThreadResources() { | 2700 void Bootstrapper::FreeThreadResources() { |
2710 ASSERT(!IsActive()); | 2701 ASSERT(!IsActive()); |
2711 } | 2702 } |
2712 | 2703 |
2713 } } // namespace v8::internal | 2704 } } // namespace v8::internal |
OLD | NEW |