build: --without-profiler option, add Windows build options by brody2consult · Pull Request #10140 · nodejs/node · GitHub
Skip to content
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
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