@@ -524,6 +524,11 @@ WallProfiler::WallProfiler(std::chrono::microseconds samplingPeriod,
524
524
workaroundV8Bug_ = workaroundV8Bug && DD_WALL_USE_SIGPROF && detectV8Bug_;
525
525
collectCpuTime_ = collectCpuTime && withContexts;
526
526
collectAsyncId_ = collectAsyncId && withContexts;
527
+ #if NODE_MAJOR_VERSION >= 23
528
+ useCPED_ = useCPED && withContexts;
529
+ #else
530
+ useCPED_ = false ;
531
+ #endif
527
532
528
533
if (withContexts_) {
529
534
contexts_.reserve (duration * 2 / samplingPeriod);
@@ -629,6 +634,13 @@ NAN_METHOD(WallProfiler::New) {
629
634
DD_WALL_PROFILER_GET_BOOLEAN_CONFIG (isMainThread);
630
635
DD_WALL_PROFILER_GET_BOOLEAN_CONFIG (useCPED);
631
636
637
+ #if NODE_MAJOR_VERSION < 23
638
+ if (useCPED) {
639
+ return Nan::ThrowTypeError (
640
+ " useCPED is not supported on this Node.js version." );
641
+ }
642
+ #endif
643
+
632
644
if (withContexts && !DD_WALL_USE_SIGPROF) {
633
645
return Nan::ThrowTypeError (" Contexts are not supported." );
634
646
}
@@ -1016,6 +1028,7 @@ class PersistentContextPtr : AtomicContextPtr {
1016
1028
};
1017
1029
1018
1030
void WallProfiler::SetContext (Isolate* isolate, Local<Value> value) {
1031
+ #if NODE_MAJOR_VERSION >= 23
1019
1032
if (!useCPED_) {
1020
1033
curContext_.Set (isolate, value);
1021
1034
return ;
@@ -1049,6 +1062,9 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
1049
1062
}
1050
1063
1051
1064
contextPtr->Set (isolate, value);
1065
+ #else
1066
+ curContext_.Set (isolate, value);
1067
+ #endif
1052
1068
}
1053
1069
1054
1070
ContextPtr WallProfiler::GetContextPtrSignalSafe (Isolate* isolate) {
@@ -1071,6 +1087,7 @@ ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
1071
1087
}
1072
1088
1073
1089
ContextPtr WallProfiler::GetContextPtr (Isolate* isolate) {
1090
+ #if NODE_MAJOR_VERSION >= 23
1074
1091
if (!useCPED_) {
1075
1092
return curContext_.Get ();
1076
1093
}
@@ -1088,6 +1105,9 @@ ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
1088
1105
1089
1106
return static_cast <PersistentContextPtr*>(profData.As <External>()->Value ())
1090
1107
->Get ();
1108
+ #else
1109
+ return curContext_.Get ();
1110
+ #endif
1091
1111
}
1092
1112
1093
1113
NAN_GETTER (WallProfiler::GetContext) {
@@ -1142,7 +1162,7 @@ void WallProfiler::OnGCStart(v8::Isolate* isolate) {
1142
1162
if (useCPED_) {
1143
1163
gcContext = GetContextPtrSignalSafe (isolate);
1144
1164
}
1145
- }
1165
+ }
1146
1166
gcCount.store (curCount + 1 , std::memory_order_relaxed);
1147
1167
std::atomic_signal_fence (std::memory_order_release);
1148
1168
}
0 commit comments