summaryrefslogtreecommitdiffstats
path: root/js/public/friend/UsageStatistics.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/public/friend/UsageStatistics.h
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/public/friend/UsageStatistics.h')
-rw-r--r--js/public/friend/UsageStatistics.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/js/public/friend/UsageStatistics.h b/js/public/friend/UsageStatistics.h
new file mode 100644
index 0000000000..904d277d3a
--- /dev/null
+++ b/js/public/friend/UsageStatistics.h
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: set ts=8 sts=2 et sw=2 tw=80:
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Telemetry and use counter functionality. */
+
+#ifndef js_friend_UsageStatistics_h
+#define js_friend_UsageStatistics_h
+
+#include <stdint.h> // uint32_t
+
+#include "jstypes.h" // JS_FRIEND_API
+
+struct JS_PUBLIC_API JSContext;
+class JS_PUBLIC_API JSObject;
+
+/*
+ * Telemetry reasons passed to the accumulate telemetry callback.
+ *
+ * It's OK for these enum values to change as they will be mapped to a fixed
+ * member of the mozilla::Telemetry::HistogramID enum by the callback.
+ */
+#define MAP_JS_TELEMETRY(_) \
+ _(JS_TELEMETRY_GC_REASON) \
+ _(JS_TELEMETRY_GC_IS_ZONE_GC) \
+ _(JS_TELEMETRY_GC_MS) \
+ _(JS_TELEMETRY_GC_BUDGET_MS_2) \
+ _(JS_TELEMETRY_GC_BUDGET_OVERRUN) \
+ _(JS_TELEMETRY_GC_ANIMATION_MS) \
+ _(JS_TELEMETRY_GC_MAX_PAUSE_MS_2) \
+ _(JS_TELEMETRY_GC_PREPARE_MS) \
+ _(JS_TELEMETRY_GC_MARK_MS) \
+ _(JS_TELEMETRY_GC_SWEEP_MS) \
+ _(JS_TELEMETRY_GC_COMPACT_MS) \
+ _(JS_TELEMETRY_GC_MARK_ROOTS_US) \
+ _(JS_TELEMETRY_GC_MARK_GRAY_MS_2) \
+ _(JS_TELEMETRY_GC_MARK_WEAK_MS) \
+ _(JS_TELEMETRY_GC_SLICE_MS) \
+ _(JS_TELEMETRY_GC_SLOW_PHASE) \
+ _(JS_TELEMETRY_GC_SLOW_TASK) \
+ _(JS_TELEMETRY_GC_MMU_50) \
+ _(JS_TELEMETRY_GC_RESET) \
+ _(JS_TELEMETRY_GC_RESET_REASON) \
+ _(JS_TELEMETRY_GC_NON_INCREMENTAL) \
+ _(JS_TELEMETRY_GC_NON_INCREMENTAL_REASON) \
+ _(JS_TELEMETRY_GC_MINOR_REASON) \
+ _(JS_TELEMETRY_GC_MINOR_REASON_LONG) \
+ _(JS_TELEMETRY_GC_MINOR_US) \
+ _(JS_TELEMETRY_GC_NURSERY_BYTES) \
+ _(JS_TELEMETRY_GC_PRETENURE_COUNT_2) \
+ _(JS_TELEMETRY_GC_NURSERY_PROMOTION_RATE) \
+ _(JS_TELEMETRY_GC_TENURED_SURVIVAL_RATE) \
+ _(JS_TELEMETRY_GC_MARK_RATE_2) \
+ _(JS_TELEMETRY_GC_TIME_BETWEEN_S) \
+ _(JS_TELEMETRY_GC_TIME_BETWEEN_SLICES_MS) \
+ _(JS_TELEMETRY_GC_SLICE_COUNT) \
+ _(JS_TELEMETRY_GC_EFFECTIVENESS) \
+ _(JS_TELEMETRY_RUN_TIME_US) \
+ _(JS_TELEMETRY_WASM_COMPILE_TIME_BASELINE_US) \
+ _(JS_TELEMETRY_WASM_COMPILE_TIME_ION_US) \
+ _(JS_TELEMETRY_WASM_COMPILE_TIME_CRANELIFT_US)
+
+// clang-format off
+#define ENUM_DEF(NAME) NAME ,
+enum {
+ MAP_JS_TELEMETRY(ENUM_DEF)
+ JS_TELEMETRY_END
+};
+#undef ENUM_DEF
+// clang-format on
+
+using JSAccumulateTelemetryDataCallback = void (*)(int, uint32_t, const char*);
+
+extern JS_FRIEND_API void JS_SetAccumulateTelemetryCallback(
+ JSContext* cx, JSAccumulateTelemetryDataCallback callback);
+
+/*
+ * Use counter names passed to the accumulate use counter callback.
+ *
+ * It's OK to for these enum values to change as they will be mapped to a
+ * fixed member of the mozilla::UseCounter enum by the callback.
+ */
+
+enum class JSUseCounter { ASMJS, WASM, WASM_DUPLICATE_IMPORTS };
+
+using JSSetUseCounterCallback = void (*)(JSObject*, JSUseCounter);
+
+extern JS_FRIEND_API void JS_SetSetUseCounterCallback(
+ JSContext* cx, JSSetUseCounterCallback callback);
+
+#endif // js_friend_UsageStatistics_h