Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src: fix tracing infrastructure after v8 upgrade
Browse files Browse the repository at this point in the history
Fix up the dtrace/etw/systemtap infrastructure after the V8 upgrade in
commit 1c7bf24.  The win32 changes are untested but can hardly make
things worse because node doesn't build on windows right now.

Fixes #7313 with some luck.
  • Loading branch information
bnoordhuis authored and indutny committed Mar 16, 2014
1 parent c30cc4e commit 23dfa71
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
16 changes: 11 additions & 5 deletions src/node_counters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using v8::GCPrologueCallback;
using v8::GCType;
using v8::Handle;
using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
Expand Down Expand Up @@ -76,12 +77,16 @@ void COUNTER_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>&) {
}


static void counter_gc_start(GCType type, GCCallbackFlags flags) {
static void counter_gc_start(Isolate* isolate,
GCType type,
GCCallbackFlags flags) {
counter_gc_start_time = NODE_COUNT_GET_GC_RAWTIME();
}


static void counter_gc_done(GCType type, GCCallbackFlags flags) {
static void counter_gc_done(Isolate* isolate,
GCType type,
GCCallbackFlags flags) {
uint64_t endgc = NODE_COUNT_GET_GC_RAWTIME();
if (endgc != 0) {
uint64_t totalperiod = endgc - counter_gc_end_time;
Expand Down Expand Up @@ -117,7 +122,8 @@ void InitPerfCounters(Environment* env, Handle<Object> target) {

for (int i = 0; i < ARRAY_SIZE(tab); i++) {
Local<String> key = OneByteString(env->isolate(), tab[i].name);
Local<Value> val = FunctionTemplate::New(tab[i].func)->GetFunction();
Local<Value> val =
FunctionTemplate::New(env->isolate(), tab[i].func)->GetFunction();
target->Set(key, val);
}

Expand All @@ -129,8 +135,8 @@ void InitPerfCounters(Environment* env, Handle<Object> target) {
counter_gc_start_time = NODE_COUNT_GET_GC_RAWTIME();
counter_gc_end_time = counter_gc_start_time;

v8::V8::AddGCPrologueCallback(counter_gc_start);
v8::V8::AddGCEpilogueCallback(counter_gc_done);
env->isolate()->AddGCPrologueCallback(counter_gc_start);
env->isolate()->AddGCEpilogueCallback(counter_gc_done);
}


Expand Down
27 changes: 13 additions & 14 deletions src/node_dtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
#define NODE_NET_SOCKET_READ_ENABLED() (0)
#define NODE_NET_SOCKET_WRITE(arg0, arg1, arg2, arg3, arg4)
#define NODE_NET_SOCKET_WRITE_ENABLED() (0)
#define NODE_GC_START(arg0, arg1)
#define NODE_GC_DONE(arg0, arg1)
#define NODE_GC_START(arg0, arg1, arg2)
#define NODE_GC_DONE(arg0, arg1, arg2)
#endif

#include "env.h"
Expand All @@ -63,6 +63,7 @@ using v8::GCPrologueCallback;
using v8::GCType;
using v8::Handle;
using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
Expand Down Expand Up @@ -287,19 +288,17 @@ void DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>& args) {
}


int dtrace_gc_start(GCType type, GCCallbackFlags flags) {
NODE_GC_START(type, flags);
/*
* We avoid the tail-call elimination of the USDT probe (which screws up
* args) by forcing a return of 0.
*/
return 0;
void dtrace_gc_start(Isolate* isolate, GCType type, GCCallbackFlags flags) {
// Previous versions of this probe point only logged type and flags.
// That's why for reasons of backwards compatibility the isolate goes last.
NODE_GC_START(type, flags, isolate);
}


int dtrace_gc_done(GCType type, GCCallbackFlags flags) {
NODE_GC_DONE(type, flags);
return 0;
void dtrace_gc_done(Isolate* isolate, GCType type, GCCallbackFlags flags) {
// Previous versions of this probe point only logged type and flags.
// That's why for reasons of backwards compatibility the isolate goes last.
NODE_GC_DONE(type, flags, isolate);
}


Expand Down Expand Up @@ -334,8 +333,8 @@ void InitDTrace(Environment* env, Handle<Object> target) {
#endif

#if defined HAVE_DTRACE || defined HAVE_ETW
v8::V8::AddGCPrologueCallback((GCPrologueCallback)dtrace_gc_start);
v8::V8::AddGCEpilogueCallback((GCEpilogueCallback)dtrace_gc_done);
env->isolate()->AddGCPrologueCallback(dtrace_gc_start);
env->isolate()->AddGCEpilogueCallback(dtrace_gc_done);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/node_provider.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ provider node {
string a, int p, string m, string u, int fd);
probe http__client__response(node_dtrace_connection_t *c, const char *a,
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
probe gc__start(int t, int f);
probe gc__done(int t, int f);
probe gc__start(int t, int f, void *isolate);
probe gc__done(int t, int f, void *isolate);
};

#pragma D attributes Evolving/Evolving/ISA provider node provider
Expand Down
8 changes: 6 additions & 2 deletions src/node_win32_etw_provider-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ void NODE_NET_STREAM_END(node_dtrace_connection_t* conn,
}


void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags) {
void NODE_GC_START(v8::GCType type,
v8::GCCallbackFlags flags,
v8::Isolate* isolate) {
if (events_enabled > 0) {
EVENT_DATA_DESCRIPTOR descriptors[2];
ETW_WRITE_GC(descriptors, type, flags);
Expand All @@ -171,7 +173,9 @@ void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags) {
}


void NODE_GC_DONE(v8::GCType type, v8::GCCallbackFlags flags) {
void NODE_GC_DONE(v8::GCType type,
v8::GCCallbackFlags flags,
v8::Isolate* isolate) {
if (events_enabled > 0) {
EVENT_DATA_DESCRIPTOR descriptors[2];
ETW_WRITE_GC(descriptors, type, flags);
Expand Down
8 changes: 6 additions & 2 deletions src/node_win32_etw_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ INLINE void NODE_NET_SERVER_CONNECTION(node_dtrace_connection_t* conn,
const char *remote, int port, int fd);
INLINE void NODE_NET_STREAM_END(node_dtrace_connection_t* conn,
const char *remote, int port, int fd);
INLINE void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags);
INLINE void NODE_GC_DONE(v8::GCType type, v8::GCCallbackFlags flags);
INLINE void NODE_GC_START(v8::GCType type,
v8::GCCallbackFlags flags,
v8::Isolate* isolate);
INLINE void NODE_GC_DONE(v8::GCType type,
v8::GCCallbackFlags flags,
v8::Isolate* isolate);
INLINE void NODE_V8SYMBOL_REMOVE(const void* addr1, const void* addr2);
INLINE void NODE_V8SYMBOL_MOVE(const void* addr1, const void* addr2);
INLINE void NODE_V8SYMBOL_RESET();
Expand Down

0 comments on commit 23dfa71

Please sign in to comment.