Commit 189bef0b authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Fix variable shadowing when using TRACE_GC() macro

Introduce IDENTIFIER_WITH_LINE() that can be similarly used in other
scope-based macros throughout the codebase.

Bug: v8:12244,v8:12245
Change-Id: If9d45b7065d7eb3df0297f35eb9be777b497ea95
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3181524
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77038}
parent 3e3ecd9b
......@@ -18,6 +18,11 @@
// This macro does nothing. That's all.
#define NOTHING(...)
#define CONCAT_(a, b) a##b
#define CONCAT(a, b) CONCAT_(a, b)
// Creates an unique identifier. Useful for scopes to avoid shadowing names.
#define UNIQUE_IDENTIFIER(base) CONCAT(base, __COUNTER__)
// TODO(all) Replace all uses of this macro with C++'s offsetof. To do that, we
// have to make sure that only standard-layout types and simple field
// designators are used.
......
......@@ -7,6 +7,7 @@
#include "include/v8-metrics.h"
#include "src/base/compiler-specific.h"
#include "src/base/macros.h"
#include "src/base/optional.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
......@@ -32,22 +33,23 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
"devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.gc")
#define TRACE_GC(tracer, scope_id) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id, \
ThreadKind::kMain); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, GCTracer::Scope::Name(gc_tracer_scope_id))
GCTracer::Scope UNIQUE_IDENTIFIER(gc_tracer_scope)( \
tracer, GCTracer::Scope::ScopeId(scope_id), ThreadKind::kMain); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, \
GCTracer::Scope::Name(GCTracer::Scope::ScopeId(scope_id)))
#define TRACE_GC1(tracer, scope_id, thread_kind) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id, thread_kind); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, GCTracer::Scope::Name(gc_tracer_scope_id))
GCTracer::Scope UNIQUE_IDENTIFIER(gc_tracer_scope)( \
tracer, GCTracer::Scope::ScopeId(scope_id), thread_kind); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, \
GCTracer::Scope::Name(GCTracer::Scope::ScopeId(scope_id)))
#define TRACE_GC_EPOCH(tracer, scope_id, thread_kind) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id, thread_kind); \
CollectionEpoch gc_tracer_epoch = tracer->CurrentEpoch(scope_id); \
TRACE_EVENT1(TRACE_GC_CATEGORIES, GCTracer::Scope::Name(gc_tracer_scope_id), \
"epoch", gc_tracer_epoch)
GCTracer::Scope UNIQUE_IDENTIFIER(gc_tracer_scope)( \
tracer, GCTracer::Scope::ScopeId(scope_id), thread_kind); \
TRACE_EVENT1(TRACE_GC_CATEGORIES, \
GCTracer::Scope::Name(GCTracer::Scope::ScopeId(scope_id)), \
"epoch", tracer->CurrentEpoch(scope_id))
// GCTracer collects and prints ONE line after each garbage collector
// invocation IFF --trace_gc is used.
......
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