Files
Igor Sheludko e74e6c524c [cppgc] Rename src/heap/cppgc/ to src/heap/cppgc-internal/
Rename the internal cppgc directory to src/heap/cppgc-internal/ to
clearly distinguish it from the public include/cppgc/ headers and
avoid potential naming confusion.
The collision occurs on Windows builds where -Wmicrosoft-include
is enabled by Clang in MSVC compatible mode. MSVC on Windows uses
different order of directories where the files are searched by the
compiler and `#include "cppgc/blah.h"` in public headers might end up
including "src/heap/cppgc/blah.h" if it exists.

All internal #include paths, include guards, and build configurations
(BUILD.gn and BUILD.bazel) have been updated to reflect the new path.

TAG=agy
CONV=47b06028-d652-41a8-b4f1-39e3cc478096

Bug: 515252150
Change-Id: Idf7ca1d193a8b6bb9d53b22f01320f4363df36f4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7963663
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Cr-Commit-Position: refs/heads/main@{#108143}
2026-06-22 02:41:04 -07:00

88 lines
2.4 KiB
C++

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/cppgc/allocation.h"
#include "include/cppgc/garbage-collected.h"
#include "include/cppgc/persistent.h"
#include "src/base/macros.h"
#include "src/heap/cppgc-internal/globals.h"
#include "src/heap/cppgc-internal/heap.h"
#include "test/benchmarks/cpp/cppgc/benchmark_utils.h"
#include "third_party/google_benchmark_chrome/src/include/benchmark/benchmark.h"
#include "v8config.h"
namespace cppgc {
namespace internal {
namespace {
using Trace = testing::BenchmarkWithHeap;
class GCed : public cppgc::GarbageCollected<GCed> {
public:
virtual void Trace(Visitor*) const {}
};
class OtherPayload {
public:
virtual void* DummyGetter() { return nullptr; }
};
class Mixin : public GarbageCollectedMixin {
public:
void Trace(Visitor*) const override {}
};
class GCedWithMixin final : public GCed, public OtherPayload, public Mixin {
public:
void Trace(Visitor* visitor) const final {
GCed::Trace(visitor);
Mixin::Trace(visitor);
}
};
class Holder : public cppgc::GarbageCollected<Holder> {
public:
explicit Holder(GCedWithMixin* object)
: base_ref(object), mixin_ref(object) {}
virtual void Trace(Visitor* visitor) const {
visitor->Trace(base_ref);
visitor->Trace(mixin_ref);
}
cppgc::Member<GCedWithMixin> base_ref;
cppgc::Member<Mixin> mixin_ref;
};
template <typename T>
V8_NOINLINE void DispatchTrace(Visitor* visitor, T& ref) {
visitor->Trace(ref);
}
BENCHMARK_F(Trace, Static)(benchmark::State& st) {
cppgc::Persistent<Holder> holder(cppgc::MakeGarbageCollected<Holder>(
heap().GetAllocationHandle(), cppgc::MakeGarbageCollected<GCedWithMixin>(
heap().GetAllocationHandle())));
VisitorBase visitor;
for (auto _ : st) {
USE(_);
DispatchTrace(&visitor, holder->base_ref);
}
}
BENCHMARK_F(Trace, Dynamic)(benchmark::State& st) {
cppgc::Persistent<Holder> holder(cppgc::MakeGarbageCollected<Holder>(
heap().GetAllocationHandle(), cppgc::MakeGarbageCollected<GCedWithMixin>(
heap().GetAllocationHandle())));
VisitorBase visitor;
for (auto _ : st) {
USE(_);
DispatchTrace(&visitor, holder->mixin_ref);
}
}
} // namespace
} // namespace internal
} // namespace cppgc