Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: --without-profiler option, add Windows build options #10140

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
Expand Down
9 changes: 9 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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)"' ],
}],
Expand Down
11 changes: 9 additions & 2 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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()) {
}
Expand Down Expand Up @@ -100,6 +104,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Local<Value> wrapper) {

return new RetainedAsyncInfo(class_id, wrap);
}
#endif


// end RetainedAsyncInfo
Expand Down Expand Up @@ -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) \
Expand All @@ -223,6 +229,7 @@ void LoadAsyncWrapperInfo(Environment* env) {
NODE_ASYNC_PROVIDER_TYPES(V)
#undef V
}
#endif


AsyncWrap::AsyncWrap(Environment* env,
Expand Down
2 changes: 2 additions & 0 deletions src/async-wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
Expand All @@ -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_)
Expand Down
2 changes: 2 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ class Environment {
bool start_profiler_idle_notifier);
void AssignToContext(v8::Local<v8::Context> 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;
Expand Down
14 changes: 14 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2979,6 +2985,7 @@ static void NeedImmediateCallbackSetter(
}


#if defined(NODE_USE_PROFILER) && NODE_USE_PROFILER
void StartProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
env->StartProfilerIdleNotifier();
Expand All @@ -2989,6 +2996,7 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
env->StopProfilerIdleNotifier();
}
#endif


#define READONLY_PROPERTY(obj, str, var) \
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "string_search.h"
#include "util.h"
#include "util-inl.h"
#include "v8-profiler.h"

#include "v8.h"

#include <string.h>
Expand Down
9 changes: 8 additions & 1 deletion vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down