fix: remove catch-all HandleScope (#22531)
This commit is contained in:
parent
4bca5205bb
commit
19314d3caf
21 changed files with 131 additions and 75 deletions
|
@ -139,55 +139,59 @@ int NodeMain(int argc, char* argv[]) {
|
|||
JavascriptEnvironment gin_env(loop);
|
||||
|
||||
v8::Isolate* isolate = gin_env.isolate();
|
||||
|
||||
node::IsolateData* isolate_data =
|
||||
node::CreateIsolateData(isolate, loop, gin_env.platform());
|
||||
CHECK_NE(nullptr, isolate_data);
|
||||
|
||||
v8::Locker locker(isolate);
|
||||
v8::Isolate::Scope isolate_scope(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Locker locker(isolate);
|
||||
node::Environment* env = nullptr;
|
||||
node::IsolateData* isolate_data = nullptr;
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
isolate_data, gin_env.context(), argc, argv, exec_argc, exec_argv);
|
||||
CHECK_NE(nullptr, env);
|
||||
isolate_data = node::CreateIsolateData(isolate, loop, gin_env.platform());
|
||||
CHECK_NE(nullptr, isolate_data);
|
||||
|
||||
env = node::CreateEnvironment(isolate_data, gin_env.context(), argc, argv,
|
||||
exec_argc, exec_argv);
|
||||
CHECK_NE(nullptr, env);
|
||||
|
||||
// TODO(codebytere): we shouldn't have to call this - upstream?
|
||||
env->InitializeDiagnostics();
|
||||
|
||||
// This is needed in order to enable v8 host weakref hooks.
|
||||
// TODO(codebytere): we shouldn't have to call this - upstream?
|
||||
isolate->SetHostCleanupFinalizationGroupCallback(
|
||||
HostCleanupFinalizationGroupCallback);
|
||||
|
||||
gin_helper::Dictionary process(isolate, env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &ElectronBindings::Log);
|
||||
#endif
|
||||
process.SetMethod("crash", &ElectronBindings::Crash);
|
||||
|
||||
// Setup process.crashReporter.start in child node processes
|
||||
gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
|
||||
reporter.SetMethod("start",
|
||||
&crash_reporter::CrashReporter::StartInstance);
|
||||
|
||||
#if !defined(OS_LINUX)
|
||||
reporter.SetMethod("addExtraParameter", &AddExtraParameter);
|
||||
reporter.SetMethod("removeExtraParameter", &RemoveExtraParameter);
|
||||
#endif
|
||||
|
||||
process.Set("crashReporter", reporter);
|
||||
|
||||
gin_helper::Dictionary versions;
|
||||
if (process.Get("versions", &versions)) {
|
||||
versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
// Enable support for v8 inspector.
|
||||
NodeDebugger node_debugger(env);
|
||||
node_debugger.Start();
|
||||
|
||||
// TODO(codebytere): we shouldn't have to call this - upstream?
|
||||
env->InitializeDiagnostics();
|
||||
|
||||
// This is needed in order to enable v8 host weakref hooks.
|
||||
// TODO(codebytere): we shouldn't have to call this - upstream?
|
||||
isolate->SetHostCleanupFinalizationGroupCallback(
|
||||
HostCleanupFinalizationGroupCallback);
|
||||
|
||||
gin_helper::Dictionary process(isolate, env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &ElectronBindings::Log);
|
||||
#endif
|
||||
process.SetMethod("crash", &ElectronBindings::Crash);
|
||||
|
||||
// Setup process.crashReporter.start in child node processes
|
||||
gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
|
||||
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
|
||||
|
||||
#if !defined(OS_LINUX)
|
||||
reporter.SetMethod("addExtraParameter", &AddExtraParameter);
|
||||
reporter.SetMethod("removeExtraParameter", &RemoveExtraParameter);
|
||||
#endif
|
||||
|
||||
process.Set("crashReporter", reporter);
|
||||
|
||||
gin_helper::Dictionary versions;
|
||||
if (process.Get("versions", &versions)) {
|
||||
versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING);
|
||||
}
|
||||
|
||||
// TODO(codebytere): we should try to handle this upstream.
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
node::InternalCallbackScope callback_scope(
|
||||
env, v8::Local<v8::Object>(), {1, 0},
|
||||
node::InternalCallbackScope::kAllowEmptyResource |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue