Browse Source

src: add --track-heap-objects

- This makes v8 add .trace_function_info to the serialized form of
  snapshots from v8::HeapSnapshot::Serialize
- .trace_funciton_info combined with .trace_node in snapshots tells the
  JS location that allocated a specific object

PR-URL: https://github.com/nodejs/io.js/pull/2135
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v4.0.0-rc
Bradley Meck 10 years ago
committed by Trevor Norris
parent
commit
cf14a2427c
  1. 2
      doc/iojs.1
  2. 55
      src/node.cc

2
doc/iojs.1

@ -60,6 +60,8 @@ and servers.
--throw-deprecation throw errors on deprecations --throw-deprecation throw errors on deprecations
--track-heap-objects track heap object allocations for heap snapshots
--v8-options print v8 command line options --v8-options print v8 command line options

55
src/node.cc

@ -117,6 +117,7 @@ static bool trace_deprecation = false;
static bool throw_deprecation = false; static bool throw_deprecation = false;
static bool abort_on_uncaught_exception = false; static bool abort_on_uncaught_exception = false;
static bool trace_sync_io = false; static bool trace_sync_io = false;
static bool track_heap_objects = false;
static const char* eval_string = nullptr; static const char* eval_string = nullptr;
static unsigned int preload_module_count = 0; static unsigned int preload_module_count = 0;
static const char** preload_modules = nullptr; static const char** preload_modules = nullptr;
@ -3053,40 +3054,42 @@ static void PrintHelp() {
" iojs debug script.js [arguments] \n" " iojs debug script.js [arguments] \n"
"\n" "\n"
"Options:\n" "Options:\n"
" -v, --version print io.js version\n" " -v, --version print io.js version\n"
" -e, --eval script evaluate script\n" " -e, --eval script evaluate script\n"
" -p, --print evaluate script and print result\n" " -p, --print evaluate script and print result\n"
" -i, --interactive always enter the REPL even if stdin\n" " -i, --interactive always enter the REPL even if stdin\n"
" does not appear to be a terminal\n" " does not appear to be a terminal\n"
" -r, --require module to preload (option can be repeated)\n" " -r, --require module to preload (option can be repeated)\n"
" --no-deprecation silence deprecation warnings\n" " --no-deprecation silence deprecation warnings\n"
" --throw-deprecation throw an exception anytime a deprecated " " --throw-deprecation throw an exception anytime a deprecated "
"function is used\n" "function is used\n"
" --trace-deprecation show stack traces on deprecations\n" " --trace-deprecation show stack traces on deprecations\n"
" --trace-sync-io show stack trace when use of sync IO\n" " --trace-sync-io show stack trace when use of sync IO\n"
" is detected after the first tick\n" " is detected after the first tick\n"
" --v8-options print v8 command line options\n" " --track-heap-objects track heap object allocations for heap "
"snapshots\n"
" --v8-options print v8 command line options\n"
#if defined(NODE_HAVE_I18N_SUPPORT) #if defined(NODE_HAVE_I18N_SUPPORT)
" --icu-data-dir=dir set ICU data load path to dir\n" " --icu-data-dir=dir set ICU data load path to dir\n"
" (overrides NODE_ICU_DATA)\n" " (overrides NODE_ICU_DATA)\n"
#if !defined(NODE_HAVE_SMALL_ICU) #if !defined(NODE_HAVE_SMALL_ICU)
" Note: linked-in ICU data is\n" " Note: linked-in ICU data is\n"
" present.\n" " present.\n"
#endif #endif
#endif #endif
"\n" "\n"
"Environment variables:\n" "Environment variables:\n"
#ifdef _WIN32 #ifdef _WIN32
"NODE_PATH ';'-separated list of directories\n" "NODE_PATH ';'-separated list of directories\n"
#else #else
"NODE_PATH ':'-separated list of directories\n" "NODE_PATH ':'-separated list of directories\n"
#endif #endif
" prefixed to the module search path.\n" " prefixed to the module search path.\n"
"NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n" "NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n"
#if defined(NODE_HAVE_I18N_SUPPORT) #if defined(NODE_HAVE_I18N_SUPPORT)
"NODE_ICU_DATA Data path for ICU (Intl object) data\n" "NODE_ICU_DATA Data path for ICU (Intl object) data\n"
#if !defined(NODE_HAVE_SMALL_ICU) #if !defined(NODE_HAVE_SMALL_ICU)
" (will extend linked-in data)\n" " (will extend linked-in data)\n"
#endif #endif
#endif #endif
"\n" "\n"
@ -3187,6 +3190,8 @@ static void ParseArgs(int* argc,
trace_deprecation = true; trace_deprecation = true;
} else if (strcmp(arg, "--trace-sync-io") == 0) { } else if (strcmp(arg, "--trace-sync-io") == 0) {
trace_sync_io = true; trace_sync_io = true;
} else if (strcmp(arg, "--track-heap-objects") == 0) {
track_heap_objects = true;
} else if (strcmp(arg, "--throw-deprecation") == 0) { } else if (strcmp(arg, "--throw-deprecation") == 0) {
throw_deprecation = true; throw_deprecation = true;
} else if (strcmp(arg, "--abort-on-uncaught-exception") == 0 || } else if (strcmp(arg, "--abort-on-uncaught-exception") == 0 ||
@ -3876,7 +3881,11 @@ Environment* CreateEnvironment(Isolate* isolate,
static void StartNodeInstance(void* arg) { static void StartNodeInstance(void* arg) {
NodeInstanceData* instance_data = static_cast<NodeInstanceData*>(arg); NodeInstanceData* instance_data = static_cast<NodeInstanceData*>(arg);
Isolate* isolate = Isolate::New(); Isolate* isolate = Isolate::New();
// Fetch a reference to the main isolate, so we have a reference to it if (track_heap_objects) {
isolate->GetHeapProfiler()->StartTrackingHeapObjects(true);
}
// Fetch a reference to the main isolate, so we have a reference to it
// even when we need it to access it from another (debugger) thread. // even when we need it to access it from another (debugger) thread.
if (instance_data->is_main()) if (instance_data->is_main())
node_isolate = isolate; node_isolate = isolate;

Loading…
Cancel
Save