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