@@ -138,10 +138,16 @@ int NodeMain(int argc, char* argv[]) {
138
138
// Initialize gin::IsolateHolder.
139
139
JavascriptEnvironment gin_env (loop);
140
140
141
+ v8::Isolate* isolate = gin_env.isolate ();
142
+
141
143
node::IsolateData* isolate_data =
142
- node::CreateIsolateData (gin_env. isolate () , loop, gin_env.platform ());
144
+ node::CreateIsolateData (isolate, loop, gin_env.platform ());
143
145
CHECK_NE (nullptr , isolate_data);
144
146
147
+ v8::Locker locker (isolate);
148
+ v8::Isolate::Scope isolate_scope (isolate);
149
+ v8::HandleScope handle_scope (isolate);
150
+
145
151
node::Environment* env = node::CreateEnvironment (
146
152
isolate_data, gin_env.context (), argc, argv, exec_argc, exec_argv);
147
153
CHECK_NE (nullptr , env);
@@ -155,18 +161,17 @@ int NodeMain(int argc, char* argv[]) {
155
161
156
162
// This is needed in order to enable v8 host weakref hooks.
157
163
// TODO(codebytere): we shouldn't have to call this - upstream?
158
- gin_env. isolate () ->SetHostCleanupFinalizationGroupCallback (
164
+ isolate->SetHostCleanupFinalizationGroupCallback (
159
165
HostCleanupFinalizationGroupCallback);
160
166
161
- gin_helper::Dictionary process (gin_env. isolate () , env->process_object ());
167
+ gin_helper::Dictionary process (isolate, env->process_object ());
162
168
#if defined(OS_WIN)
163
169
process.SetMethod (" log" , &ElectronBindings::Log);
164
170
#endif
165
171
process.SetMethod (" crash" , &ElectronBindings::Crash);
166
172
167
173
// Setup process.crashReporter.start in child node processes
168
- gin_helper::Dictionary reporter =
169
- gin::Dictionary::CreateEmpty (gin_env.isolate ());
174
+ gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty (isolate);
170
175
reporter.SetMethod (" start" , &crash_reporter::CrashReporter::StartInstance);
171
176
172
177
#if !defined(OS_LINUX)
@@ -190,15 +195,13 @@ int NodeMain(int argc, char* argv[]) {
190
195
node::LoadEnvironment (env);
191
196
}
192
197
193
- v8::Isolate* isolate = env->isolate ();
194
-
195
198
{
196
199
v8::SealHandleScope seal (isolate);
197
200
bool more;
198
201
do {
199
202
uv_run (env->event_loop (), UV_RUN_DEFAULT);
200
203
201
- gin_env.platform ()->DrainTasks (env-> isolate () );
204
+ gin_env.platform ()->DrainTasks (isolate);
202
205
203
206
more = uv_loop_alive (env->event_loop ());
204
207
if (more && !env->is_stopping ())
0 commit comments