From 31a8341fb0e2f7b9c0affda0c638e9f1e257abbb Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 4 Dec 2016 02:58:39 +0100 Subject: [PATCH 1/2] build: --without-profiler option Hides ugly warnings in Windows build --- configure | 7 +++++++ node.gyp | 9 +++++++++ src/async-wrap.cc | 11 +++++++++-- src/async-wrap.h | 2 ++ src/env.cc | 10 ++++++++++ src/env.h | 2 ++ src/node.cc | 14 ++++++++++++++ src/node_buffer.cc | 2 +- 8 files changed, 54 insertions(+), 3 deletions(-) diff --git a/configure b/configure index bf937ca702a550..17cfed4cc48449 100755 --- a/configure +++ b/configure @@ -458,6 +458,11 @@ parser.add_option('--without-bundled-v8', help='do not use V8 includes from the bundled deps folder. ' + '(This mode is not officially supported for regular applications)') +parser.add_option('--without-profiler', + action='store_true', + dest='without_profiler', + help='disable V8 profiler usage') + (options, args) = parser.parse_args() # Expand ~ in the install prefix now, it gets written to multiple files. @@ -878,6 +883,8 @@ def configure_node(o): else: o['variables']['coverage'] = 'false' + o['variables']['node_use_profiler'] = b(not options.without_profiler) + def configure_library(lib, output): shared_lib = 'shared_' + lib output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib)) diff --git a/node.gyp b/node.gyp index f59037737c905a..be0a676509e994 100644 --- a/node.gyp +++ b/node.gyp @@ -275,6 +275,15 @@ 'NODE_USE_V8_PLATFORM=0', ], }], + [ 'node_use_v8_platform=="true"' and 'node_use_profiler=="true"', { + 'defines': [ + 'NODE_USE_PROFILER=1', + ], + }, { + 'defines': [ + 'NODE_USE_PROFILER=0', + ], + }], [ 'node_tag!=""', { 'defines': [ 'NODE_TAG="<(node_tag)"' ], }], diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 42463bd22b31f4..2628eb3da5835e 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -6,8 +6,11 @@ #include "util-inl.h" #include "uv.h" + #include "v8.h" +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER #include "v8-profiler.h" +#endif using v8::Boolean; using v8::Context; @@ -28,7 +31,8 @@ using v8::Value; namespace node { -static const char* const provider_names[] = { +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER +static const char* const retained_async_provider_names[] = { #define V(PROVIDER) \ #PROVIDER, NODE_ASYNC_PROVIDER_TYPES(V) @@ -54,7 +58,7 @@ class RetainedAsyncInfo: public RetainedObjectInfo { RetainedAsyncInfo::RetainedAsyncInfo(uint16_t class_id, AsyncWrap* wrap) - : label_(provider_names[class_id - NODE_ASYNC_ID_OFFSET]), + : label_(retained_async_provider_names[class_id - NODE_ASYNC_ID_OFFSET]), wrap_(wrap), length_(wrap->self_size()) { } @@ -100,6 +104,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Local wrapper) { return new RetainedAsyncInfo(class_id, wrap); } +#endif // end RetainedAsyncInfo @@ -215,6 +220,7 @@ void AsyncWrap::DestroyIdsCb(uv_idle_t* handle) { } +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER void LoadAsyncWrapperInfo(Environment* env) { HeapProfiler* heap_profiler = env->isolate()->GetHeapProfiler(); #define V(PROVIDER) \ @@ -223,6 +229,7 @@ void LoadAsyncWrapperInfo(Environment* env) { NODE_ASYNC_PROVIDER_TYPES(V) #undef V } +#endif AsyncWrap::AsyncWrap(Environment* env, diff --git a/src/async-wrap.h b/src/async-wrap.h index d01c6ce9f9b724..202f0903e117a5 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -91,7 +91,9 @@ class AsyncWrap : public BaseObject { const int64_t uid_; }; +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER void LoadAsyncWrapperInfo(Environment* env); +#endif } // namespace node diff --git a/src/env.cc b/src/env.cc index 40f0c9ebd66a07..f2a6b90548e798 100644 --- a/src/env.cc +++ b/src/env.cc @@ -1,8 +1,12 @@ #include "env.h" #include "env-inl.h" #include "async-wrap.h" + #include "v8.h" + +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER #include "v8-profiler.h" +#endif #if defined(_MSC_VER) #define getpid GetCurrentProcessId @@ -77,9 +81,11 @@ void Environment::Start(int argc, close_and_finish, nullptr); +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER if (start_profiler_idle_notifier) { StartProfilerIdleNotifier(); } +#endif auto process_template = FunctionTemplate::New(isolate()); process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate(), "process")); @@ -89,9 +95,12 @@ void Environment::Start(int argc, set_process_object(process_object); SetupProcessObject(this, argc, argv, exec_argc, exec_argv); +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER LoadAsyncWrapperInfo(this); +#endif } +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER void Environment::StartProfilerIdleNotifier() { uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) { Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle); @@ -108,6 +117,7 @@ void Environment::StopProfilerIdleNotifier() { uv_prepare_stop(&idle_prepare_handle_); uv_check_stop(&idle_check_handle_); } +#endif void Environment::PrintSyncTrace() const { if (!trace_sync_io_) diff --git a/src/env.h b/src/env.h index b99bb45f819e59..43c84fb8be2f38 100644 --- a/src/env.h +++ b/src/env.h @@ -422,8 +422,10 @@ class Environment { bool start_profiler_idle_notifier); void AssignToContext(v8::Local context); +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER void StartProfilerIdleNotifier(); void StopProfilerIdleNotifier(); +#endif inline v8::Isolate* isolate() const; inline uv_loop_t* event_loop() const; diff --git a/src/node.cc b/src/node.cc index e87bddcb6ff2cc..1debb3d2e6a0b8 100644 --- a/src/node.cc +++ b/src/node.cc @@ -38,12 +38,18 @@ #include "req-wrap-inl.h" #include "string_bytes.h" #include "util.h" + #include "uv.h" + #if NODE_USE_V8_PLATFORM #include "libplatform/libplatform.h" #endif // NODE_USE_V8_PLATFORM + #include "v8-debug.h" +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER #include "v8-profiler.h" +#endif + #include "zlib.h" #ifdef NODE_ENABLE_VTUNE_PROFILING @@ -2979,6 +2985,7 @@ static void NeedImmediateCallbackSetter( } +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER void StartProfilerIdleNotifier(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); env->StartProfilerIdleNotifier(); @@ -2989,6 +2996,7 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); env->StopProfilerIdleNotifier(); } +#endif #define READONLY_PROPERTY(obj, str, var) \ @@ -3314,12 +3322,16 @@ void SetupProcessObject(Environment* env, env->as_external()).FromJust()); // define various internal methods + +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER env->SetMethod(process, "_startProfilerIdleNotifier", StartProfilerIdleNotifier); env->SetMethod(process, "_stopProfilerIdleNotifier", StopProfilerIdleNotifier); +#endif + env->SetMethod(process, "_getActiveRequests", GetActiveRequests); env->SetMethod(process, "_getActiveHandles", GetActiveHandles); env->SetMethod(process, "reallyExit", Exit); @@ -4490,9 +4502,11 @@ inline int Start(uv_loop_t* event_loop, isolate->SetAutorunMicrotasks(false); isolate->SetFatalErrorHandler(OnFatalError); +#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER if (track_heap_objects) { isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); } +#endif { Mutex::ScopedLock scoped_lock(node_isolate_mutex); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 540de1827f9716..505bf58fc34889 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -7,7 +7,7 @@ #include "string_search.h" #include "util.h" #include "util-inl.h" -#include "v8-profiler.h" + #include "v8.h" #include From 056cd2d71edd064a0a6bebecd1db597cd8935d87 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 5 Dec 2016 11:43:20 +0100 Subject: [PATCH 2/2] vcbuild.bat: without-inspector/-profiler options --- vcbuild.bat | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vcbuild.bat b/vcbuild.bat index 3cf7fe910a6f26..938045c90c4791 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -39,6 +39,8 @@ set enable_vtune_arg= set configure_flags= set build_addons= set dll= +set noinspector= +set noprofiler= :next-arg if "%1"=="" goto args-done @@ -77,11 +79,13 @@ if /i "%1"=="upload" set upload=1&goto arg-ok if /i "%1"=="small-icu" set i18n_arg=%1&goto arg-ok if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok -if /i "%1"=="without-intl" set i18n_arg=%1&goto arg-ok if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok if /i "%1"=="enable-vtune" set enable_vtune_arg=1&goto arg-ok if /i "%1"=="dll" set dll=1&goto arg-ok +if /i "%1"=="without-intl" set i18n_arg=%1&goto arg-ok +if /i "%1"=="without-inspector" set noinspector=1&goto arg-ok +if /i "%1"=="without-profiler" set noprofiler=1&goto arg-ok echo Error: invalid command line option `%1`. exit /b 1 @@ -119,6 +123,9 @@ if "%i18n_arg%"=="small-icu" set configure_flags=%configure_flags% --with-intl=s if "%i18n_arg%"=="intl-none" set configure_flags=%configure_flags% --with-intl=none if "%i18n_arg%"=="without-intl" set configure_flags=%configure_flags% --without-intl +if defined noinspector set configure_flags=%configure_flags% --without-inspector +if defined noprofiler set configure_flags=%configure_flags% --without-profiler + if defined config_flags set configure_flags=%configure_flags% %config_flags% if not exist "%~dp0deps\icu" goto no-depsicu