v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
Recorder Class Reference

#include <v8-metrics.h>

Data Structures

class  ContextId
 

Public Member Functions

virtual ~Recorder ()=default
 
virtual void NotifyIsolateDisposal ()
 

Static Public Member Functions

static MaybeLocal< ContextGetContext (Isolate *isolate, ContextId id)
 
static ContextId GetContextId (Local< Context > context)
 

Detailed Description

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 whose implementation is required to fulfill this requirement and those whose implementation does not have that requirement and only needs to be executable on the main thread. If such an event is triggered from a 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.

Definition at line 141 of file v8-metrics.h.

Constructor & Destructor Documentation

◆ ~Recorder()

virtual ~Recorder ( )
virtualdefault

Member Function Documentation

◆ GetContext()

static MaybeLocal<Context> GetContext ( Isolate isolate,
ContextId  id 
)
static

◆ GetContextId()

static ContextId GetContextId ( Local< Context context)
static

◆ NotifyIsolateDisposal()

virtual void NotifyIsolateDisposal ( )
inlinevirtual

Definition at line 177 of file v8-metrics.h.


The documentation for this class was generated from the following file: