@@ -3363,12 +3363,6 @@ void LoadEnvironment(Environment* env) {
33633363}
33643364
33653365
3366- void FreeEnvironment (Environment* env) {
3367- CHECK_NE (env, nullptr );
3368- env->Dispose ();
3369- }
3370-
3371-
33723366static void PrintHelp ();
33733367
33743368static bool ParseDebugOpt (const char * arg) {
@@ -4256,12 +4250,17 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
42564250 Isolate* isolate = context->GetIsolate ();
42574251 HandleScope handle_scope (isolate);
42584252 Context::Scope context_scope (context);
4259- Environment* env = Environment::New (isolate_data, context);
4253+ auto env = new Environment (isolate_data, context);
42604254 env->Start (argc, argv, exec_argc, exec_argv, v8_is_profiling);
42614255 return env;
42624256}
42634257
42644258
4259+ void FreeEnvironment (Environment* env) {
4260+ delete env;
4261+ }
4262+
4263+
42654264// Entry point for new node instances, also called directly for the main
42664265// node instance.
42674266static void StartNodeInstance (void * arg) {
@@ -4293,60 +4292,60 @@ static void StartNodeInstance(void* arg) {
42934292 array_buffer_allocator.zero_fill_field ());
42944293 Local<Context> context = Context::New (isolate);
42954294 Context::Scope context_scope (context);
4296- Environment* env = CreateEnvironment (&isolate_data,
4297- context ,
4298- instance_data->argc (),
4299- instance_data->argv (),
4300- instance_data->exec_argc (),
4301- instance_data-> exec_argv () );
4295+ Environment env (&isolate_data, context);
4296+ env. Start (instance_data-> argc () ,
4297+ instance_data->argv (),
4298+ instance_data->exec_argc (),
4299+ instance_data->exec_argv (),
4300+ v8_is_profiling );
43024301
43034302 isolate->SetAbortOnUncaughtExceptionCallback (
43044303 ShouldAbortOnUncaughtException);
43054304
43064305 // Start debug agent when argv has --debug
43074306 if (instance_data->use_debug_agent ())
4308- StartDebug (env, debug_wait_connect);
4307+ StartDebug (& env, debug_wait_connect);
43094308
43104309 {
4311- Environment::AsyncCallbackScope callback_scope (env);
4312- LoadEnvironment (env);
4310+ Environment::AsyncCallbackScope callback_scope (& env);
4311+ LoadEnvironment (& env);
43134312 }
43144313
4315- env-> set_trace_sync_io (trace_sync_io);
4314+ env. set_trace_sync_io (trace_sync_io);
43164315
43174316 // Enable debugger
43184317 if (instance_data->use_debug_agent ())
4319- EnableDebug (env);
4318+ EnableDebug (& env);
43204319
43214320 {
43224321 SealHandleScope seal (isolate);
43234322 bool more;
43244323 do {
43254324 v8::platform::PumpMessageLoop (default_platform, isolate);
4326- more = uv_run (env-> event_loop (), UV_RUN_ONCE);
4325+ more = uv_run (env. event_loop (), UV_RUN_ONCE);
43274326
43284327 if (more == false ) {
43294328 v8::platform::PumpMessageLoop (default_platform, isolate);
4330- EmitBeforeExit (env);
4329+ EmitBeforeExit (& env);
43314330
43324331 // Emit `beforeExit` if the loop became alive either after emitting
43334332 // event, or after running some callbacks.
4334- more = uv_loop_alive (env-> event_loop ());
4335- if (uv_run (env-> event_loop (), UV_RUN_NOWAIT) != 0 )
4333+ more = uv_loop_alive (env. event_loop ());
4334+ if (uv_run (env. event_loop (), UV_RUN_NOWAIT) != 0 )
43364335 more = true ;
43374336 }
43384337 } while (more == true );
43394338 }
43404339
4341- env-> set_trace_sync_io (false );
4340+ env. set_trace_sync_io (false );
43424341
4343- int exit_code = EmitExit (env);
4342+ int exit_code = EmitExit (& env);
43444343 if (instance_data->is_main ())
43454344 instance_data->set_exit_code (exit_code);
4346- RunAtExit (env);
4345+ RunAtExit (& env);
43474346
43484347#if HAVE_INSPECTOR
4349- if (env-> inspector_agent ()->connected ()) {
4348+ if (env. inspector_agent ()->connected ()) {
43504349 // Restore signal dispositions, the app is done and is no longer
43514350 // capable of handling signals.
43524351#ifdef __POSIX__
@@ -4359,16 +4358,13 @@ static void StartNodeInstance(void* arg) {
43594358 CHECK_EQ (0 , sigaction (nr, &act, nullptr ));
43604359 }
43614360#endif
4362- env-> inspector_agent ()->WaitForDisconnect ();
4361+ env. inspector_agent ()->WaitForDisconnect ();
43634362 }
43644363#endif
43654364
43664365#if defined(LEAK_SANITIZER)
43674366 __lsan_do_leak_check ();
43684367#endif
4369-
4370- env->Dispose ();
4371- env = nullptr ;
43724368 }
43734369
43744370 uv_mutex_lock (&node_isolate_mutex);
0 commit comments