| 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/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4920 } | 4920 } |
| 4921 | 4921 |
| 4922 const int proxy_size = JSGlobalProxy::SizeWithInternalFields( | 4922 const int proxy_size = JSGlobalProxy::SizeWithInternalFields( |
| 4923 global_proxy_template->InternalFieldCount()); | 4923 global_proxy_template->InternalFieldCount()); |
| 4924 | 4924 |
| 4925 Handle<JSGlobalProxy> global_proxy; | 4925 Handle<JSGlobalProxy> global_proxy; |
| 4926 if (!maybe_global_proxy.ToHandle(&global_proxy)) { | 4926 if (!maybe_global_proxy.ToHandle(&global_proxy)) { |
| 4927 global_proxy = factory()->NewUninitializedJSGlobalProxy(proxy_size); | 4927 global_proxy = factory()->NewUninitializedJSGlobalProxy(proxy_size); |
| 4928 } | 4928 } |
| 4929 | 4929 |
| 4930 // CreateNewGlobals. | 4930 // Create a remote object as the global object. |
| 4931 Handle<ObjectTemplateInfo> global_proxy_data = | 4931 Handle<ObjectTemplateInfo> global_proxy_data = |
| 4932 v8::Utils::OpenHandle(*global_proxy_template); | 4932 Utils::OpenHandle(*global_proxy_template); |
| 4933 Handle<FunctionTemplateInfo> global_constructor( | 4933 Handle<FunctionTemplateInfo> global_constructor( |
| 4934 FunctionTemplateInfo::cast(global_proxy_data->constructor())); | 4934 FunctionTemplateInfo::cast(global_proxy_data->constructor())); |
| 4935 |
| 4936 Handle<ObjectTemplateInfo> global_object_template( |
| 4937 ObjectTemplateInfo::cast(global_constructor->prototype_template())); |
| 4938 Handle<JSObject> global_object = |
| 4939 ApiNatives::InstantiateRemoteObject( |
| 4940 global_object_template).ToHandleChecked(); |
| 4941 |
| 4942 // (Re)initialize the global proxy object. |
| 4935 Handle<SharedFunctionInfo> shared = | 4943 Handle<SharedFunctionInfo> shared = |
| 4936 FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, | 4944 FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, |
| 4937 global_constructor); | 4945 global_constructor); |
| 4938 Handle<Map> initial_map = | 4946 Handle<Map> initial_map = |
| 4939 factory()->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); | 4947 factory()->CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); |
| 4940 Handle<JSFunction> global_proxy_function = | 4948 Handle<JSFunction> global_proxy_function = |
| 4941 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 4949 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 4942 initial_map, shared, factory()->undefined_value()); | 4950 initial_map, shared, factory()->undefined_value()); |
| 4943 DCHECK_EQ(global_proxy_data->internal_field_count(), | 4951 DCHECK_EQ(global_proxy_data->internal_field_count(), |
| 4944 global_proxy_template->InternalFieldCount()); | 4952 global_proxy_template->InternalFieldCount()); |
| 4945 Handle<Map> global_proxy_map = isolate->factory()->NewMap( | 4953 Handle<Map> global_proxy_map = isolate->factory()->NewMap( |
| 4946 JS_GLOBAL_PROXY_TYPE, proxy_size, FAST_HOLEY_SMI_ELEMENTS); | 4954 JS_GLOBAL_PROXY_TYPE, proxy_size, FAST_HOLEY_SMI_ELEMENTS); |
| 4947 JSFunction::SetInitialMap(global_proxy_function, global_proxy_map, | 4955 JSFunction::SetInitialMap(global_proxy_function, global_proxy_map, |
| 4948 factory()->null_value()); | 4956 factory()->null_value()); |
| 4949 global_proxy_map->set_is_access_check_needed(true); | 4957 global_proxy_map->set_is_access_check_needed(true); |
| 4950 global_proxy_map->set_is_callable(); | 4958 global_proxy_map->set_is_callable(); |
| 4951 global_proxy_map->set_is_constructor(true); | 4959 global_proxy_map->set_is_constructor(true); |
| 4952 global_proxy_map->set_has_hidden_prototype(true); | 4960 global_proxy_map->set_has_hidden_prototype(true); |
| 4953 | 4961 |
| 4954 Handle<String> global_name = factory()->global_string(); | 4962 Handle<String> global_name = factory()->global_string(); |
| 4955 global_proxy_function->shared()->set_instance_class_name(*global_name); | 4963 global_proxy_function->shared()->set_instance_class_name(*global_name); |
| 4956 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); | 4964 factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); |
| 4957 | 4965 |
| 4958 // GlobalProxy. | 4966 // A remote global proxy has no native context. |
| 4959 global_proxy->set_native_context(heap()->null_value()); | 4967 global_proxy->set_native_context(heap()->null_value()); |
| 4960 | 4968 |
| 4961 // DetachGlobal. | 4969 // Configure the hidden prototype chain of the global proxy. |
| 4962 JSObject::ForceSetPrototype(global_proxy, factory()->null_value()); | 4970 JSObject::ForceSetPrototype(global_proxy, global_object); |
| 4971 // TODO(dcheng): This is a hack. Why does this need to be manually called |
| 4972 // here? Line 4812 should have taken care of it? |
| 4973 global_proxy->map()->set_has_hidden_prototype(true); |
| 4963 | 4974 |
| 4964 global_proxy_ = global_proxy; | 4975 global_proxy_ = global_proxy; |
| 4965 } | 4976 } |
| 4966 | 4977 |
| 4967 // Support for thread preemption. | 4978 // Support for thread preemption. |
| 4968 | 4979 |
| 4969 // Reserve space for statics needing saving and restoring. | 4980 // Reserve space for statics needing saving and restoring. |
| 4970 int Bootstrapper::ArchiveSpacePerThread() { | 4981 int Bootstrapper::ArchiveSpacePerThread() { |
| 4971 return sizeof(NestingCounterType); | 4982 return sizeof(NestingCounterType); |
| 4972 } | 4983 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4987 } | 4998 } |
| 4988 | 4999 |
| 4989 | 5000 |
| 4990 // Called when the top-level V8 mutex is destroyed. | 5001 // Called when the top-level V8 mutex is destroyed. |
| 4991 void Bootstrapper::FreeThreadResources() { | 5002 void Bootstrapper::FreeThreadResources() { |
| 4992 DCHECK(!IsActive()); | 5003 DCHECK(!IsActive()); |
| 4993 } | 5004 } |
| 4994 | 5005 |
| 4995 } // namespace internal | 5006 } // namespace internal |
| 4996 } // namespace v8 | 5007 } // namespace v8 |
| OLD | NEW |