Chromium Code Reviews| Index: src/bootstrapper.cc |
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
| index 0be96ea46c5e6a8cab680bb321b842dfdab3bcd5..50625b03115e92f370c42f2183d64cad2e78fcc7 100644 |
| --- a/src/bootstrapper.cc |
| +++ b/src/bootstrapper.cc |
| @@ -141,6 +141,8 @@ class Genesis BASE_EMBEDDED { |
| v8::Local<v8::ObjectTemplate> global_proxy_template, |
| v8::ExtensionConfiguration* extensions, size_t context_snapshot_index, |
| GlobalContextType context_type); |
| + Genesis(Isolate* isolate, |
| + v8::Local<v8::ObjectTemplate> global_proxy_template); |
| ~Genesis() { } |
| Isolate* isolate() const { return isolate_; } |
| @@ -149,6 +151,8 @@ class Genesis BASE_EMBEDDED { |
| Handle<Context> result() { return result_; } |
| + Handle<JSGlobalProxy> global_proxy() { return global_proxy_; } |
| + |
| private: |
| Handle<Context> native_context() { return native_context_; } |
| @@ -302,6 +306,7 @@ class Genesis BASE_EMBEDDED { |
| Isolate* isolate_; |
| Handle<Context> result_; |
| Handle<Context> native_context_; |
| + Handle<JSGlobalProxy> global_proxy_; |
| // Function maps. Function maps are created initially with a read only |
| // prototype for the processing of JS builtins. Later the function maps are |
| @@ -337,6 +342,14 @@ Handle<Context> Bootstrapper::CreateEnvironment( |
| return scope.CloseAndEscape(env); |
| } |
| +Handle<JSGlobalProxy> Bootstrapper::NewDetachedGlobal( |
| + v8::Local<v8::ObjectTemplate> global_proxy_template) { |
| + HandleScope scope(isolate_); |
| + Genesis genesis(isolate_, global_proxy_template); |
| + Handle<JSGlobalProxy> global_proxy = genesis.global_proxy(); |
| + if (global_proxy.is_null()) return Handle<JSGlobalProxy>(); |
| + return scope.CloseAndEscape(global_proxy); |
| +} |
| static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { |
| // object.__proto__ = proto; |
| @@ -3811,6 +3824,8 @@ Genesis::Genesis(Isolate* isolate, |
| : isolate_(isolate), active_(isolate->bootstrapper()) { |
| NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); |
| result_ = Handle<Context>::null(); |
| + global_proxy_ = Handle<JSGlobalProxy>::null(); |
| + |
| // Before creating the roots we must save the context and restore it |
| // on all function exits. |
| SaveContext saved_context(isolate); |
| @@ -3919,6 +3934,56 @@ Genesis::Genesis(Isolate* isolate, |
| result_ = native_context(); |
| } |
| +Genesis::Genesis(Isolate* isolate, |
| + v8::Local<v8::ObjectTemplate> global_proxy_template) |
| + : isolate_(isolate), active_(isolate->bootstrapper()) { |
| + NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); |
| + result_ = Handle<Context>::null(); |
| + global_proxy_ = Handle<JSGlobalProxy>::null(); |
| + |
| + // Before creating the roots we must save the context and restore it |
| + // on all function exits. |
| + SaveContext saved_context(isolate); |
| + |
| + // During genesis, the boilerplate for stack overflow won't work until the |
| + // environment has been at least partially initialized. Add a stack check |
| + // before entering JS code to catch overflow early. |
| + StackLimitCheck check(isolate); |
| + if (check.HasOverflowed()) { |
| + isolate->StackOverflow(); |
| + return; |
| + } |
| + |
| + Handle<JSGlobalProxy> global_proxy = |
| + factory()->NewUninitializedJSGlobalProxy(); |
| + |
| + // CreateNewGlobals. |
| + Handle<ObjectTemplateInfo> global_proxy_data = |
| + v8::Utils::OpenHandle(*global_proxy_template); |
| + Handle<FunctionTemplateInfo> global_constructor( |
| + FunctionTemplateInfo::cast(global_proxy_data->constructor())); |
| + |
| + Handle<Map> initial_map = |
| + CreateSloppyFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE); |
| + Handle<JSFunction> global_proxy_function = |
| + ApiNatives::CreateApiFunctionWithMap( |
| + isolate, factory()->undefined_value(), global_constructor, |
| + initial_map, factory()->the_hole_value(), |
| + ApiNatives::GlobalProxyType); |
| + Handle<String> global_name = factory()->global_string(); |
| + global_proxy_function->shared()->set_instance_class_name(*global_name); |
| + global_proxy_function->initial_map()->set_is_access_check_needed(true); |
| + global_proxy_function->initial_map()->set_has_hidden_prototype(true); |
| + factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); |
| + |
| + // HookUpGlobalProxy. |
| + global_proxy->set_native_context(*factory()->null_value()); |
| + |
|
jochen (gone - plz use gerrit)
2016/06/28 14:27:00
The regular genesis path would also invoke Configu
|
| + // DetachGlobal. |
| + SetObjectPrototype(global_proxy, factory()->null_value()); |
|
jochen (gone - plz use gerrit)
2016/06/28 14:27:00
regular DetachGlobal would also delete the constru
|
| + |
| + global_proxy_ = global_proxy; |
| +} |
| // Support for thread preemption. |