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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2574 isolate->set_context(*native_context()); | 2581 isolate->set_context(*native_context()); |
2575 isolate->counters()->contexts_created_by_snapshot()->Increment(); | 2582 isolate->counters()->contexts_created_by_snapshot()->Increment(); |
2576 Handle<GlobalObject> inner_global; | 2583 Handle<GlobalObject> inner_global; |
2577 Handle<JSGlobalProxy> global_proxy = | 2584 Handle<JSGlobalProxy> global_proxy = |
2578 CreateNewGlobals(global_template, | 2585 CreateNewGlobals(global_template, |
2579 global_object, | 2586 global_object, |
2580 &inner_global); | 2587 &inner_global); |
2581 | 2588 |
2582 HookUpGlobalProxy(inner_global, global_proxy); | 2589 HookUpGlobalProxy(inner_global, global_proxy); |
2583 HookUpInnerGlobal(inner_global); | 2590 HookUpInnerGlobal(inner_global); |
| 2591 native_context()->builtins()->set_global_receiver( |
| 2592 native_context()->global_proxy()); |
2584 | 2593 |
2585 if (!ConfigureGlobalObjects(global_template)) return; | 2594 if (!ConfigureGlobalObjects(global_template)) return; |
2586 } else { | 2595 } else { |
2587 // We get here if there was no context snapshot. | 2596 // We get here if there was no context snapshot. |
2588 CreateRoots(); | 2597 CreateRoots(); |
2589 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 2598 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
2590 CreateStrictModeFunctionMaps(empty_function); | 2599 CreateStrictModeFunctionMaps(empty_function); |
2591 Handle<GlobalObject> inner_global; | 2600 Handle<GlobalObject> inner_global; |
2592 Handle<JSGlobalProxy> global_proxy = | 2601 Handle<JSGlobalProxy> global_proxy = |
2593 CreateNewGlobals(global_template, global_object, &inner_global); | 2602 CreateNewGlobals(global_template, global_object, &inner_global); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 return from + sizeof(NestingCounterType); | 2704 return from + sizeof(NestingCounterType); |
2696 } | 2705 } |
2697 | 2706 |
2698 | 2707 |
2699 // Called when the top-level V8 mutex is destroyed. | 2708 // Called when the top-level V8 mutex is destroyed. |
2700 void Bootstrapper::FreeThreadResources() { | 2709 void Bootstrapper::FreeThreadResources() { |
2701 ASSERT(!IsActive()); | 2710 ASSERT(!IsActive()); |
2702 } | 2711 } |
2703 | 2712 |
2704 } } // namespace v8::internal | 2713 } } // namespace v8::internal |
OLD | NEW |