Commit 370cae1d authored by Nikolaos Papaspyrou's avatar Nikolaos Papaspyrou Committed by V8 LUCI CQ

heap: Inline GCTracer::Scope::Name

This is a follow-up to https://crrev.com/c/3581774.
It inlines method GCTracer::Scope::Name so that the calculation of the
name of the trace event can be performed at compile time and optimized
away, at most call sites.

Bug: chromium:1318062
Change-Id: I483d8fdfcc2c82c2a88d245326f27e7e787979aa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3602511Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80122}
parent 28d526ec
......@@ -77,6 +77,33 @@ GCTracer::Scope::~Scope() {
#endif // defined(V8_RUNTIME_CALL_STATS)
}
constexpr const char* GCTracer::Scope::Name(ScopeId id) {
#define CASE(scope) \
case Scope::scope: \
return "V8.GC_" #scope;
switch (id) {
TRACER_SCOPES(CASE)
TRACER_BACKGROUND_SCOPES(CASE)
case Scope::NUMBER_OF_SCOPES:
break;
}
#undef CASE
UNREACHABLE();
}
constexpr bool GCTracer::Scope::NeedsYoungEpoch(ScopeId id) {
#define CASE(scope) \
case Scope::scope: \
return true;
switch (id) {
TRACER_YOUNG_EPOCH_SCOPES(CASE)
default:
return false;
}
#undef CASE
UNREACHABLE();
}
constexpr int GCTracer::Scope::IncrementalOffset(ScopeId id) {
DCHECK_LE(FIRST_INCREMENTAL_SCOPE, id);
DCHECK_GE(LAST_INCREMENTAL_SCOPE, id);
......
......@@ -58,33 +58,6 @@ void GCTracer::Scope::AssertMainThread() {
}
#endif // DEBUG
const char* GCTracer::Scope::Name(ScopeId id) {
#define CASE(scope) \
case Scope::scope: \
return "V8.GC_" #scope;
switch (id) {
TRACER_SCOPES(CASE)
TRACER_BACKGROUND_SCOPES(CASE)
case Scope::NUMBER_OF_SCOPES:
break;
}
#undef CASE
UNREACHABLE();
}
bool GCTracer::Scope::NeedsYoungEpoch(ScopeId id) {
#define CASE(scope) \
case Scope::scope: \
return true;
switch (id) {
TRACER_YOUNG_EPOCH_SCOPES(CASE)
default:
return false;
}
#undef CASE
UNREACHABLE();
}
GCTracer::Event::Event(Type type, State state,
GarbageCollectionReason gc_reason,
const char* collector_reason)
......
......@@ -97,9 +97,9 @@ class V8_EXPORT_PRIVATE GCTracer {
V8_INLINE ~Scope();
Scope(const Scope&) = delete;
Scope& operator=(const Scope&) = delete;
static const char* Name(ScopeId id);
static bool NeedsYoungEpoch(ScopeId id);
V8_INLINE static constexpr int IncrementalOffset(ScopeId id);
static constexpr const char* Name(ScopeId id);
static constexpr bool NeedsYoungEpoch(ScopeId id);
static constexpr int IncrementalOffset(ScopeId id);
private:
#if DEBUG
......
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