@@ -101,7 +101,6 @@ using v8::Exception;
101101using v8::Float64Array;
102102using v8::Function;
103103using v8::FunctionCallbackInfo;
104- using v8::FunctionTemplate;
105104using v8::HandleScope;
106105using v8::HeapStatistics;
107106using v8::Integer;
@@ -2864,39 +2863,15 @@ static void NeedImmediateCallbackSetter(
28642863}
28652864
28662865
2867- void SetIdle (uv_prepare_t * handle) {
2868- Environment* env = Environment::from_idle_prepare_handle (handle);
2869- env->isolate ()->GetCpuProfiler ()->SetIdle (true );
2870- }
2871-
2872-
2873- void ClearIdle (uv_check_t * handle) {
2874- Environment* env = Environment::from_idle_check_handle (handle);
2875- env->isolate ()->GetCpuProfiler ()->SetIdle (false );
2876- }
2877-
2878-
2879- void StartProfilerIdleNotifier (Environment* env) {
2880- uv_prepare_start (env->idle_prepare_handle (), SetIdle);
2881- uv_check_start (env->idle_check_handle (), ClearIdle);
2882- }
2883-
2884-
2885- void StopProfilerIdleNotifier (Environment* env) {
2886- uv_prepare_stop (env->idle_prepare_handle ());
2887- uv_check_stop (env->idle_check_handle ());
2888- }
2889-
2890-
28912866void StartProfilerIdleNotifier (const FunctionCallbackInfo<Value>& args) {
28922867 Environment* env = Environment::GetCurrent (args);
2893- StartProfilerIdleNotifier (env );
2868+ env-> StartProfilerIdleNotifier ();
28942869}
28952870
28962871
28972872void StopProfilerIdleNotifier (const FunctionCallbackInfo<Value>& args) {
28982873 Environment* env = Environment::GetCurrent (args);
2899- StopProfilerIdleNotifier (env );
2874+ env-> StopProfilerIdleNotifier ();
29002875}
29012876
29022877
@@ -4262,20 +4237,6 @@ int EmitExit(Environment* env) {
42624237}
42634238
42644239
4265- static void HandleCloseCb (uv_handle_t * handle) {
4266- Environment* env = reinterpret_cast <Environment*>(handle->data );
4267- env->FinishHandleCleanup (handle);
4268- }
4269-
4270-
4271- static void HandleCleanup (Environment* env,
4272- uv_handle_t * handle,
4273- void * arg) {
4274- handle->data = env;
4275- uv_close (handle, HandleCloseCb);
4276- }
4277-
4278-
42794240IsolateData* CreateIsolateData (Isolate* isolate, uv_loop_t * loop) {
42804241 return new IsolateData (isolate, loop);
42814242}
@@ -4294,64 +4255,9 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
42944255 const char * const * exec_argv) {
42954256 Isolate* isolate = context->GetIsolate ();
42964257 HandleScope handle_scope (isolate);
4297-
42984258 Context::Scope context_scope (context);
42994259 Environment* env = Environment::New (isolate_data, context);
4300-
4301- isolate->SetAutorunMicrotasks (false );
4302-
4303- uv_check_init (env->event_loop (), env->immediate_check_handle ());
4304- uv_unref (
4305- reinterpret_cast <uv_handle_t *>(env->immediate_check_handle ()));
4306-
4307- uv_idle_init (env->event_loop (), env->immediate_idle_handle ());
4308-
4309- // Inform V8's CPU profiler when we're idle. The profiler is sampling-based
4310- // but not all samples are created equal; mark the wall clock time spent in
4311- // epoll_wait() and friends so profiling tools can filter it out. The samples
4312- // still end up in v8.log but with state=IDLE rather than state=EXTERNAL.
4313- // TODO(bnoordhuis) Depends on a libuv implementation detail that we should
4314- // probably fortify in the API contract, namely that the last started prepare
4315- // or check watcher runs first. It's not 100% foolproof; if an add-on starts
4316- // a prepare or check watcher after us, any samples attributed to its callback
4317- // will be recorded with state=IDLE.
4318- uv_prepare_init (env->event_loop (), env->idle_prepare_handle ());
4319- uv_check_init (env->event_loop (), env->idle_check_handle ());
4320- uv_unref (reinterpret_cast <uv_handle_t *>(env->idle_prepare_handle ()));
4321- uv_unref (reinterpret_cast <uv_handle_t *>(env->idle_check_handle ()));
4322-
4323- // Register handle cleanups
4324- env->RegisterHandleCleanup (
4325- reinterpret_cast <uv_handle_t *>(env->immediate_check_handle ()),
4326- HandleCleanup,
4327- nullptr );
4328- env->RegisterHandleCleanup (
4329- reinterpret_cast <uv_handle_t *>(env->immediate_idle_handle ()),
4330- HandleCleanup,
4331- nullptr );
4332- env->RegisterHandleCleanup (
4333- reinterpret_cast <uv_handle_t *>(env->idle_prepare_handle ()),
4334- HandleCleanup,
4335- nullptr );
4336- env->RegisterHandleCleanup (
4337- reinterpret_cast <uv_handle_t *>(env->idle_check_handle ()),
4338- HandleCleanup,
4339- nullptr );
4340-
4341- if (v8_is_profiling) {
4342- StartProfilerIdleNotifier (env);
4343- }
4344-
4345- Local<FunctionTemplate> process_template = FunctionTemplate::New (isolate);
4346- process_template->SetClassName (FIXED_ONE_BYTE_STRING (isolate, " process" ));
4347-
4348- Local<Object> process_object =
4349- process_template->GetFunction ()->NewInstance (context).ToLocalChecked ();
4350- env->set_process_object (process_object);
4351-
4352- SetupProcessObject (env, argc, argv, exec_argc, exec_argv);
4353- LoadAsyncWrapperInfo (env);
4354-
4260+ env->Start (argc, argv, exec_argc, exec_argv, v8_is_profiling);
43554261 return env;
43564262}
43574263
0 commit comments