Persistentv8: Context: New (v8: ExtensionConfiguration * extensions, v8: Handleglobal_template, v8: Handleglobal_object) {I: Isolate: EnsureDefaultIsolate ();
Persistent V8: Context: New (
V8: ExtensionConfiguration * extensions,
V8: Handle Global_template,
V8: Handle Global_object ){
I: Isolate: EnsureDefaultIsolate ();
I: Isolate * isolate = I: Isolate: Current ();
EnsureInitializedForIsolate (isolate, "v8: Context: New ()");
LOG_API (isolate, "Context: New ");
On_initlout (isolate, "v8: Context: New ()", return Persistent ());
// Add the following content to blog 1
// Enter V8 via an ENTER_V8 scope.
I: Handle Env;
{
// Enter the engine and use the VMState class to exit the engine during analysis.
ENTER_V8 (isolate );
V8: Handle Proxy_template = global_template;
I: Handle Proxy_constructor;
I: Handle Global_constructor;
If (! Global_template.IsEmpty ()){
// Make sure that the global_template has a constructor.
Global_constructor =
EnsureConstructor (Utils: OpenHandle (* global_template ));
// Create a fresh template for the global proxy object.
Proxy_template = ObjectTemplate: New ();
Proxy_constructor =
EnsureConstructor (Utils: OpenHandle (* proxy_template ));
// Set the global template to be the prototype template
// Global proxy template.
Proxy_constructor-> set_prototype_template (
* Utils: OpenHandle (* global_template ));
// Migrate security handlers from global_template
// Proxy_template. Temporarily removing access check
// Information from the global template.
If (! Global_constructor-> access_check_info ()-> IsUndefined ()){
Proxy_constructor-> set_access_check_info (
Global_constructor-> access_check_info ());
Proxy_constructor-> set_needs_access_check (
Global_constructor-> needs_access_check ());
Global_constructor-> set_needs_access_check (false );
Global_constructor-> set_access_check_info (
Isolate-> heap ()-> undefined_value ());
}
}
// Create the environment.
Env = isolate-> bootstrapper ()-> CreateEnvironment (
Isolate,
Utils: OpenHandle (* global_object, true ),
Proxy_template,
Extensions );
// Restore the access check info on the global template.
If (! Global_template.IsEmpty ()){
ASSERT (! Global_constructor.is_null ());
ASSERT (! Proxy_constructor.is_null ());
Global_constructor-> set_access_check_info (
Proxy_constructor-> access_check_info ());
Global_constructor-> set_needs_access_check (
Proxy_constructor-> needs_access_check ());
}
Isolate-> runtime_profiler ()-> Reset ();
}
// Leave V8.
If (env. is_null ()){
Return Persistent ();
}
Return Persistent (Utils: ToLocal (env ));
}