diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index ff31654b17e4..f3453827e793 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -128,6 +128,12 @@ enum Reason { NUM_TELEMETRY_REASONS = 100 }; +/** + * Get a statically allocated C string explaining the given GC reason. + */ +extern JS_PUBLIC_API(const char*) +ExplainReason(JS::gcreason::Reason reason); + } /* namespace gcreason */ /* diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index e55d895f19be..cfc8b0b32f27 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -600,7 +600,7 @@ js::Nursery::collect(JSRuntime* rt, JS::gcreason::Reason reason, ObjectGroupList } #define FMT " %6" PRIu64 - fprintf(stderr, "MinorGC: %20s %5.1f%% %4d " FMT, js::gcstats::ExplainReason(reason), + fprintf(stderr, "MinorGC: %20s %5.1f%% %4d " FMT, JS::gcreason::ExplainReason(reason), promotionRate * 100, numActiveChunks_, totalTime); for (auto &entry : PrintList) { fprintf(stderr, FMT, entry.time); diff --git a/js/src/gc/Statistics.cpp b/js/src/gc/Statistics.cpp index b52eaaeec8af..2962c45cd7ce 100644 --- a/js/src/gc/Statistics.cpp +++ b/js/src/gc/Statistics.cpp @@ -48,8 +48,8 @@ js::gcstats::ExplainInvocationKind(JSGCInvocationKind gckind) return "Shrinking"; } -const char* -js::gcstats::ExplainReason(JS::gcreason::Reason reason) +JS_PUBLIC_API(const char*) +JS::gcreason::ExplainReason(JS::gcreason::Reason reason) { switch (reason) { #define SWITCH_REASON(name) \ diff --git a/js/src/gc/Statistics.h b/js/src/gc/Statistics.h index db35ed799490..ff1f1dcb034f 100644 --- a/js/src/gc/Statistics.h +++ b/js/src/gc/Statistics.h @@ -423,7 +423,6 @@ struct MOZ_RAII AutoSCC }; const char* ExplainInvocationKind(JSGCInvocationKind gckind); -const char* ExplainReason(JS::gcreason::Reason reason); } /* namespace gcstats */ } /* namespace js */ diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 9e3d5ad31de4..2391925aca7f 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -8519,7 +8519,7 @@ GarbageCollectionEvent::Create(JSRuntime* rt, ::js::gcstats::Statistics& stats, // reasons this data is stored and replicated on each slice. Each // slice used to have its own GCReason, but now they are all the // same. - data->reason = gcstats::ExplainReason(range.front().reason); + data->reason = gcreason::ExplainReason(range.front().reason); MOZ_ASSERT(data->reason); }