src: fix building --without-v8-plartform

* declare v8_platform.platform_ unconditionally

  v8_platform.platform_ is referenced by node::Start
  without regard to the value of NODE_USE_V8_PLATFORM,
  so it should be declared unconditionally, otherwise
  Node fails to compile when !NODE_USE_V8_PLATFORM.

* update v8_platform.StartInspector signature

  The call signature of v8_platform.StartInspector needs
  to be the same whether or not NODE_USE_V8_PLATFORM,
  otherwise Node will fail to compile if HAVE_INSPECTOR
  and !NODE_USE_V8_PLATFORM.

* don't call tracing_agent->Start w/nullptr

  node::tracing::Agent::Start can't accept a nullptr
  argument to its platform parameter, so don't call it
  when Node is compiled with NODE_USE_V8_PLATFORM=0.

* refactor tracing_agent into v8_platform

  Move tracing_agent global into the v8_platform struct,
  renaming it to tracing_agent_; CHECK(tracing_agent_ ==
  nullptr) in StartTracingAgent() to detect double calls;
  and relace another tracing_agent->Stop() call with a call
  to StopTracingAgent().

PR-URL: https://github.com/nodejs/node/pull/11088
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
Myk Melez 2017-01-31 09:56:09 -08:00 committed by James M Snell
parent 7d2dc90aeb
commit 046f66a554

View File

@ -200,7 +200,6 @@ static uv_async_t dispatch_debug_messages_async;
static Mutex node_isolate_mutex; static Mutex node_isolate_mutex;
static v8::Isolate* node_isolate; static v8::Isolate* node_isolate;
static tracing::Agent* tracing_agent;
static node::DebugOptions debug_options; static node::DebugOptions debug_options;
@ -228,16 +227,33 @@ static struct {
} }
#endif // HAVE_INSPECTOR #endif // HAVE_INSPECTOR
void StartTracingAgent() {
CHECK(tracing_agent_ == nullptr);
tracing_agent_ = new tracing::Agent();
tracing_agent_->Start(platform_, trace_enabled_categories);
}
void StopTracingAgent() {
tracing_agent_->Stop();
}
v8::Platform* platform_; v8::Platform* platform_;
tracing::Agent* tracing_agent_;
#else // !NODE_USE_V8_PLATFORM #else // !NODE_USE_V8_PLATFORM
void Initialize(int thread_pool_size) {} void Initialize(int thread_pool_size) {}
void PumpMessageLoop(Isolate* isolate) {} void PumpMessageLoop(Isolate* isolate) {}
void Dispose() {} void Dispose() {}
bool StartInspector(Environment *env, const char* script_path, bool StartInspector(Environment *env, const char* script_path,
int port, bool wait) { const node::DebugOptions& options) {
env->ThrowError("Node compiled with NODE_USE_V8_PLATFORM=0"); env->ThrowError("Node compiled with NODE_USE_V8_PLATFORM=0");
return false; // make compiler happy return false; // make compiler happy
} }
void StartTracingAgent() {
fprintf(stderr, "Node compiled with NODE_USE_V8_PLATFORM=0, "
"so event tracing is not available.\n");
}
void StopTracingAgent() {}
#endif // !NODE_USE_V8_PLATFORM #endif // !NODE_USE_V8_PLATFORM
} v8_platform; } v8_platform;
@ -3386,7 +3402,7 @@ void SetupProcessObject(Environment* env,
void SignalExit(int signo) { void SignalExit(int signo) {
uv_tty_reset_mode(); uv_tty_reset_mode();
if (trace_enabled) { if (trace_enabled) {
tracing_agent->Stop(); v8_platform.StopTracingAgent();
} }
#ifdef __FreeBSD__ #ifdef __FreeBSD__
// FreeBSD has a nasty bug, see RegisterSignalHandler for details // FreeBSD has a nasty bug, see RegisterSignalHandler for details
@ -4533,15 +4549,14 @@ int Start(int argc, char** argv) {
if (trace_enabled) { if (trace_enabled) {
fprintf(stderr, "Warning: Trace event is an experimental feature " fprintf(stderr, "Warning: Trace event is an experimental feature "
"and could change at any time.\n"); "and could change at any time.\n");
tracing_agent = new tracing::Agent(); v8_platform.StartTracingAgent();
tracing_agent->Start(v8_platform.platform_, trace_enabled_categories);
} }
V8::Initialize(); V8::Initialize();
v8_initialized = true; v8_initialized = true;
const int exit_code = const int exit_code =
Start(uv_default_loop(), argc, argv, exec_argc, exec_argv); Start(uv_default_loop(), argc, argv, exec_argc, exec_argv);
if (trace_enabled) { if (trace_enabled) {
tracing_agent->Stop(); v8_platform.StopTracingAgent();
} }
v8_initialized = false; v8_initialized = false;
V8::Dispose(); V8::Dispose();