Commit d5d3ecae authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[API] Avoid macro list for defining API methods

The macro list makes it difficult to impossible to deprecate individual
methods (like the one receiving a {WasmModuleTieredUp} struct).
Hence avoid the macro list and instead call the macro explicitly for
each definition.

R=cbruni@chromium.org

Bug: v8:12899
Change-Id: I4139de7721c4a1450920c5be312e91e7478e6fa7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3667076Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80865}
parent 851b529d
......@@ -136,20 +136,6 @@ struct WasmModulesPerIsolate {
size_t count = 0;
};
#define V8_MAIN_THREAD_METRICS_EVENTS(V) \
V(GarbageCollectionFullCycle) \
V(GarbageCollectionFullMainThreadIncrementalMark) \
V(GarbageCollectionFullMainThreadBatchedIncrementalMark) \
V(GarbageCollectionFullMainThreadIncrementalSweep) \
V(GarbageCollectionFullMainThreadBatchedIncrementalSweep) \
V(GarbageCollectionYoungCycle) \
V(WasmModuleDecoded) \
V(WasmModuleCompiled) \
V(WasmModuleInstantiated) \
V(WasmModuleTieredUp)
#define V8_THREAD_SAFE_METRICS_EVENTS(V) V(WasmModulesPerIsolate)
/**
* This class serves as a base class for recording event-based metrics in V8.
* There a two kinds of metrics, those which are expected to be thread-safe and
......@@ -159,19 +145,6 @@ struct WasmModulesPerIsolate {
* background thread, it will be delayed and executed by the foreground task
* runner.
*
* The thread-safe events are listed in the V8_THREAD_SAFE_METRICS_EVENTS
* macro above while the main thread event are listed in
* V8_MAIN_THREAD_METRICS_EVENTS above. For the former, a virtual method
* AddMainThreadEvent(const E& event, v8::Context::Token token) will be
* generated and for the latter AddThreadSafeEvent(const E& event).
*
* Thread-safe events are not allowed to access the context and therefore do
* not carry a context ID with them. These IDs can be generated using
* Recorder::GetContextId() and the ID will be valid throughout the lifetime
* of the isolate. It is not guaranteed that the ID will still resolve to
* a valid context using Recorder::GetContext() at the time the metric is
* recorded. In this case, an empty handle will be returned.
*
* The embedder is expected to call v8::Isolate::SetMetricsRecorder()
* providing its implementation and have the virtual methods overwritten
* for the events it cares about.
......@@ -202,14 +175,31 @@ class V8_EXPORT Recorder {
virtual ~Recorder() = default;
// Main thread events. Those are only triggered on the main thread, and hence
// can access the context.
#define ADD_MAIN_THREAD_EVENT(E) \
virtual void AddMainThreadEvent(const E& event, ContextId context_id) {}
V8_MAIN_THREAD_METRICS_EVENTS(ADD_MAIN_THREAD_EVENT)
virtual void AddMainThreadEvent(const E&, ContextId) {}
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullCycle)
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadIncrementalMark)
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadBatchedIncrementalMark)
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadIncrementalSweep)
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadBatchedIncrementalSweep)
ADD_MAIN_THREAD_EVENT(GarbageCollectionYoungCycle)
ADD_MAIN_THREAD_EVENT(WasmModuleDecoded)
ADD_MAIN_THREAD_EVENT(WasmModuleCompiled)
ADD_MAIN_THREAD_EVENT(WasmModuleInstantiated)
ADD_MAIN_THREAD_EVENT(WasmModuleTieredUp)
#undef ADD_MAIN_THREAD_EVENT
// Thread-safe events are not allowed to access the context and therefore do
// not carry a context ID with them. These IDs can be generated using
// Recorder::GetContextId() and the ID will be valid throughout the lifetime
// of the isolate. It is not guaranteed that the ID will still resolve to
// a valid context using Recorder::GetContext() at the time the metric is
// recorded. In this case, an empty handle will be returned.
#define ADD_THREAD_SAFE_EVENT(E) \
virtual void AddThreadSafeEvent(const E& event) {}
V8_THREAD_SAFE_METRICS_EVENTS(ADD_THREAD_SAFE_EVENT)
virtual void AddThreadSafeEvent(const E&) {}
ADD_THREAD_SAFE_EVENT(WasmModulesPerIsolate)
#undef ADD_THREAD_SAFE_EVENT
virtual void NotifyIsolateDisposal() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment