@@ -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,12 @@ 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 (" useCPED is not supported on this Node.js version." );
639
+ }
640
+ #endif
641
+
631
642
if (withContexts && !DD_WALL_USE_SIGPROF) {
632
643
return Nan::ThrowTypeError (" Contexts are not supported." );
633
644
}
@@ -1015,6 +1026,7 @@ class PersistentContextPtr : AtomicContextPtr {
1015
1026
};
1016
1027
1017
1028
void WallProfiler::SetContext (Isolate* isolate, Local<Value> value) {
1029
+ #if NODE_MAJOR_VERSION >= 23
1018
1030
if (!useCPED_) {
1019
1031
curContext_.Set (isolate, value);
1020
1032
return ;
@@ -1048,6 +1060,9 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
1048
1060
}
1049
1061
1050
1062
contextPtr->Set (isolate, value);
1063
+ #else
1064
+ curContext_.Set (isolate, value);
1065
+ #endif
1051
1066
}
1052
1067
1053
1068
ContextPtr WallProfiler::GetContextPtrSignalSafe (Isolate* isolate) {
@@ -1070,6 +1085,7 @@ ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
1070
1085
}
1071
1086
1072
1087
ContextPtr WallProfiler::GetContextPtr (Isolate* isolate) {
1088
+ #if NODE_MAJOR_VERSION >= 23
1073
1089
if (!useCPED_) {
1074
1090
return curContext_.Get ();
1075
1091
}
@@ -1087,6 +1103,9 @@ ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
1087
1103
1088
1104
return static_cast <PersistentContextPtr*>(profData.As <External>()->Value ())
1089
1105
->Get ();
1106
+ #else
1107
+ return curContext_.Get ();
1108
+ #endif
1090
1109
}
1091
1110
1092
1111
NAN_GETTER (WallProfiler::GetContext) {
0 commit comments