Skip to content

Commit 23dfa71

Browse files
bnoordhuisindutny
authored andcommitted
src: fix tracing infrastructure after v8 upgrade
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 nodejs#7313 with some luck.
1 parent c30cc4e commit 23dfa71

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

src/node_counters.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ using v8::GCPrologueCallback;
3737
using v8::GCType;
3838
using v8::Handle;
3939
using v8::HandleScope;
40+
using v8::Isolate;
4041
using v8::Local;
4142
using v8::Object;
4243
using v8::String;
@@ -76,12 +77,16 @@ void COUNTER_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>&) {
7677
}
7778

7879

79-
static void counter_gc_start(GCType type, GCCallbackFlags flags) {
80+
static void counter_gc_start(Isolate* isolate,
81+
GCType type,
82+
GCCallbackFlags flags) {
8083
counter_gc_start_time = NODE_COUNT_GET_GC_RAWTIME();
8184
}
8285

8386

84-
static void counter_gc_done(GCType type, GCCallbackFlags flags) {
87+
static void counter_gc_done(Isolate* isolate,
88+
GCType type,
89+
GCCallbackFlags flags) {
8590
uint64_t endgc = NODE_COUNT_GET_GC_RAWTIME();
8691
if (endgc != 0) {
8792
uint64_t totalperiod = endgc - counter_gc_end_time;
@@ -117,7 +122,8 @@ void InitPerfCounters(Environment* env, Handle<Object> target) {
117122

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

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

132-
v8::V8::AddGCPrologueCallback(counter_gc_start);
133-
v8::V8::AddGCEpilogueCallback(counter_gc_done);
138+
env->isolate()->AddGCPrologueCallback(counter_gc_start);
139+
env->isolate()->AddGCEpilogueCallback(counter_gc_done);
134140
}
135141

136142

src/node_dtrace.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#define NODE_NET_SOCKET_READ_ENABLED() (0)
4747
#define NODE_NET_SOCKET_WRITE(arg0, arg1, arg2, arg3, arg4)
4848
#define NODE_NET_SOCKET_WRITE_ENABLED() (0)
49-
#define NODE_GC_START(arg0, arg1)
50-
#define NODE_GC_DONE(arg0, arg1)
49+
#define NODE_GC_START(arg0, arg1, arg2)
50+
#define NODE_GC_DONE(arg0, arg1, arg2)
5151
#endif
5252

5353
#include "env.h"
@@ -63,6 +63,7 @@ using v8::GCPrologueCallback;
6363
using v8::GCType;
6464
using v8::Handle;
6565
using v8::HandleScope;
66+
using v8::Isolate;
6667
using v8::Local;
6768
using v8::Object;
6869
using v8::String;
@@ -287,19 +288,17 @@ void DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>& args) {
287288
}
288289

289290

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

299297

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

305304

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

336335
#if defined HAVE_DTRACE || defined HAVE_ETW
337-
v8::V8::AddGCPrologueCallback((GCPrologueCallback)dtrace_gc_start);
338-
v8::V8::AddGCEpilogueCallback((GCEpilogueCallback)dtrace_gc_done);
336+
env->isolate()->AddGCPrologueCallback(dtrace_gc_start);
337+
env->isolate()->AddGCEpilogueCallback(dtrace_gc_done);
339338
#endif
340339
}
341340

src/node_provider.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ provider node {
7575
string a, int p, string m, string u, int fd);
7676
probe http__client__response(node_dtrace_connection_t *c, const char *a,
7777
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
78-
probe gc__start(int t, int f);
79-
probe gc__done(int t, int f);
78+
probe gc__start(int t, int f, void *isolate);
79+
probe gc__done(int t, int f, void *isolate);
8080
};
8181

8282
#pragma D attributes Evolving/Evolving/ISA provider node provider

src/node_win32_etw_provider-inl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ void NODE_NET_STREAM_END(node_dtrace_connection_t* conn,
162162
}
163163

164164

165-
void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags) {
165+
void NODE_GC_START(v8::GCType type,
166+
v8::GCCallbackFlags flags,
167+
v8::Isolate* isolate) {
166168
if (events_enabled > 0) {
167169
EVENT_DATA_DESCRIPTOR descriptors[2];
168170
ETW_WRITE_GC(descriptors, type, flags);
@@ -171,7 +173,9 @@ void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags) {
171173
}
172174

173175

174-
void NODE_GC_DONE(v8::GCType type, v8::GCCallbackFlags flags) {
176+
void NODE_GC_DONE(v8::GCType type,
177+
v8::GCCallbackFlags flags,
178+
v8::Isolate* isolate) {
175179
if (events_enabled > 0) {
176180
EVENT_DATA_DESCRIPTOR descriptors[2];
177181
ETW_WRITE_GC(descriptors, type, flags);

src/node_win32_etw_provider.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ INLINE void NODE_NET_SERVER_CONNECTION(node_dtrace_connection_t* conn,
6868
const char *remote, int port, int fd);
6969
INLINE void NODE_NET_STREAM_END(node_dtrace_connection_t* conn,
7070
const char *remote, int port, int fd);
71-
INLINE void NODE_GC_START(v8::GCType type, v8::GCCallbackFlags flags);
72-
INLINE void NODE_GC_DONE(v8::GCType type, v8::GCCallbackFlags flags);
71+
INLINE void NODE_GC_START(v8::GCType type,
72+
v8::GCCallbackFlags flags,
73+
v8::Isolate* isolate);
74+
INLINE void NODE_GC_DONE(v8::GCType type,
75+
v8::GCCallbackFlags flags,
76+
v8::Isolate* isolate);
7377
INLINE void NODE_V8SYMBOL_REMOVE(const void* addr1, const void* addr2);
7478
INLINE void NODE_V8SYMBOL_MOVE(const void* addr1, const void* addr2);
7579
INLINE void NODE_V8SYMBOL_RESET();

0 commit comments

Comments
 (0)