| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
| 10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 Handle<ObjectTemplateInfo> data = | 814 Handle<ObjectTemplateInfo> data = |
| 815 v8::Utils::OpenHandle(*global_proxy_template); | 815 v8::Utils::OpenHandle(*global_proxy_template); |
| 816 Handle<FunctionTemplateInfo> global_constructor( | 816 Handle<FunctionTemplateInfo> global_constructor( |
| 817 FunctionTemplateInfo::cast(data->constructor())); | 817 FunctionTemplateInfo::cast(data->constructor())); |
| 818 global_proxy_function = | 818 global_proxy_function = |
| 819 factory()->CreateApiFunction(global_constructor, | 819 factory()->CreateApiFunction(global_constructor, |
| 820 factory()->the_hole_value(), | 820 factory()->the_hole_value(), |
| 821 factory()->GlobalProxyType); | 821 factory()->GlobalProxyType); |
| 822 } | 822 } |
| 823 | 823 |
| 824 Handle<String> global_name = factory()->InternalizeOneByteString( | 824 Handle<String> global_name = factory()->global_string(); |
| 825 STATIC_ASCII_VECTOR("global")); | |
| 826 global_proxy_function->shared()->set_instance_class_name(*global_name); | 825 global_proxy_function->shared()->set_instance_class_name(*global_name); |
| 827 global_proxy_function->initial_map()->set_is_access_check_needed(true); | 826 global_proxy_function->initial_map()->set_is_access_check_needed(true); |
| 828 | 827 |
| 829 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects | 828 // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects |
| 830 // Return the global proxy. | 829 // Return the global proxy. |
| 831 | 830 |
| 832 Handle<JSGlobalProxy> global_proxy; | 831 Handle<JSGlobalProxy> global_proxy; |
| 833 if (maybe_global_proxy.ToHandle(&global_proxy)) { | 832 if (maybe_global_proxy.ToHandle(&global_proxy)) { |
| 834 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); | 833 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); |
| 835 } else { | 834 } else { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 854 | 853 |
| 855 void Genesis::HookUpGlobalObject(Handle<GlobalObject> global_object) { | 854 void Genesis::HookUpGlobalObject(Handle<GlobalObject> global_object) { |
| 856 Handle<GlobalObject> global_object_from_snapshot( | 855 Handle<GlobalObject> global_object_from_snapshot( |
| 857 GlobalObject::cast(native_context()->extension())); | 856 GlobalObject::cast(native_context()->extension())); |
| 858 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); | 857 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); |
| 859 native_context()->set_extension(*global_object); | 858 native_context()->set_extension(*global_object); |
| 860 native_context()->set_global_object(*global_object); | 859 native_context()->set_global_object(*global_object); |
| 861 native_context()->set_security_token(*global_object); | 860 native_context()->set_security_token(*global_object); |
| 862 static const PropertyAttributes attributes = | 861 static const PropertyAttributes attributes = |
| 863 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 862 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 864 Runtime::DefineObjectProperty(builtins_global, | 863 Runtime::DefineObjectProperty(builtins_global, factory()->global_string(), |
| 865 factory()->InternalizeOneByteString( | 864 global_object, attributes).Assert(); |
| 866 STATIC_ASCII_VECTOR("global")), | |
| 867 global_object, | |
| 868 attributes).Assert(); | |
| 869 // Set up the reference from the global object to the builtins object. | 865 // Set up the reference from the global object to the builtins object. |
| 870 JSGlobalObject::cast(*global_object)->set_builtins(*builtins_global); | 866 JSGlobalObject::cast(*global_object)->set_builtins(*builtins_global); |
| 871 TransferNamedProperties(global_object_from_snapshot, global_object); | 867 TransferNamedProperties(global_object_from_snapshot, global_object); |
| 872 TransferIndexedProperties(global_object_from_snapshot, global_object); | 868 TransferIndexedProperties(global_object_from_snapshot, global_object); |
| 873 } | 869 } |
| 874 | 870 |
| 875 | 871 |
| 876 // This is only called if we are not using snapshots. The equivalent | 872 // This is only called if we are not using snapshots. The equivalent |
| 877 // work in the snapshot case is done in HookUpGlobalObject. | 873 // work in the snapshot case is done in HookUpGlobalObject. |
| 878 void Genesis::InitializeGlobal(Handle<GlobalObject> global_object, | 874 void Genesis::InitializeGlobal(Handle<GlobalObject> global_object, |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1176 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
| 1181 isolate->initial_object_prototype(), Builtins::kIllegal); | 1177 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1182 // -- W e a k S e t | 1178 // -- W e a k S e t |
| 1183 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, | 1179 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, |
| 1184 isolate->initial_object_prototype(), Builtins::kIllegal); | 1180 isolate->initial_object_prototype(), Builtins::kIllegal); |
| 1185 | 1181 |
| 1186 { // --- sloppy arguments map | 1182 { // --- sloppy arguments map |
| 1187 // Make sure we can recognize argument objects at runtime. | 1183 // Make sure we can recognize argument objects at runtime. |
| 1188 // This is done by introducing an anonymous function with | 1184 // This is done by introducing an anonymous function with |
| 1189 // class_name equals 'Arguments'. | 1185 // class_name equals 'Arguments'. |
| 1190 Handle<String> arguments_string = factory->InternalizeOneByteString( | 1186 Handle<String> arguments_string = factory->Arguments_string(); |
| 1191 STATIC_ASCII_VECTOR("Arguments")); | |
| 1192 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1187 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1193 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( | 1188 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( |
| 1194 arguments_string, code); | 1189 arguments_string, code); |
| 1195 function->shared()->set_instance_class_name(*arguments_string); | 1190 function->shared()->set_instance_class_name(*arguments_string); |
| 1196 | 1191 |
| 1197 Handle<Map> map = | 1192 Handle<Map> map = |
| 1198 factory->NewMap(JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize); | 1193 factory->NewMap(JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize); |
| 1199 // Create the descriptor array for the arguments object. | 1194 // Create the descriptor array for the arguments object. |
| 1200 Map::EnsureDescriptorSlack(map, 2); | 1195 Map::EnsureDescriptorSlack(map, 2); |
| 1201 | 1196 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 | 1935 |
| 1941 // Store the map for the string prototype after the natives has been compiled | 1936 // Store the map for the string prototype after the natives has been compiled |
| 1942 // and the String function has been set up. | 1937 // and the String function has been set up. |
| 1943 Handle<JSFunction> string_function(native_context()->string_function()); | 1938 Handle<JSFunction> string_function(native_context()->string_function()); |
| 1944 DCHECK(JSObject::cast( | 1939 DCHECK(JSObject::cast( |
| 1945 string_function->initial_map()->prototype())->HasFastProperties()); | 1940 string_function->initial_map()->prototype())->HasFastProperties()); |
| 1946 native_context()->set_string_function_prototype_map( | 1941 native_context()->set_string_function_prototype_map( |
| 1947 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 1942 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
| 1948 | 1943 |
| 1949 // Install Function.prototype.call and apply. | 1944 // Install Function.prototype.call and apply. |
| 1950 { Handle<String> key = factory()->function_class_string(); | 1945 { |
| 1946 Handle<String> key = factory()->Function_string(); |
| 1951 Handle<JSFunction> function = | 1947 Handle<JSFunction> function = |
| 1952 Handle<JSFunction>::cast(Object::GetProperty( | 1948 Handle<JSFunction>::cast(Object::GetProperty( |
| 1953 handle(native_context()->global_object()), key).ToHandleChecked()); | 1949 handle(native_context()->global_object()), key).ToHandleChecked()); |
| 1954 Handle<JSObject> proto = | 1950 Handle<JSObject> proto = |
| 1955 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 1951 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
| 1956 | 1952 |
| 1957 // Install the call and the apply functions. | 1953 // Install the call and the apply functions. |
| 1958 Handle<JSFunction> call = | 1954 Handle<JSFunction> call = |
| 1959 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1955 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1960 MaybeHandle<JSObject>(), Builtins::kFunctionCall); | 1956 MaybeHandle<JSObject>(), Builtins::kFunctionCall); |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 return from + sizeof(NestingCounterType); | 2691 return from + sizeof(NestingCounterType); |
| 2696 } | 2692 } |
| 2697 | 2693 |
| 2698 | 2694 |
| 2699 // Called when the top-level V8 mutex is destroyed. | 2695 // Called when the top-level V8 mutex is destroyed. |
| 2700 void Bootstrapper::FreeThreadResources() { | 2696 void Bootstrapper::FreeThreadResources() { |
| 2701 DCHECK(!IsActive()); | 2697 DCHECK(!IsActive()); |
| 2702 } | 2698 } |
| 2703 | 2699 |
| 2704 } } // namespace v8::internal | 2700 } } // namespace v8::internal |
| OLD | NEW |