Files
darude/include/cppgc/sentinel-pointer.h
T
Kevin Babbitt 7622afda36 cppgc: Add a compile-time flag to enable larger cages
This CL introduces gn flag cppgc_enable_larger_cage and corresponding
When this flag is enabled, the caged heap can grow up to 16GB.

Testing: The test I would have written for this CL is to validate that
pointer compression and decompression work correctly under 3-bit shift,
which is already covered by MemberTest.CompressDecompress. I ran the
MemberTest unit tests locally with the flag enabled and confirmed that
they pass. I also ran a full CQ dry run with the flag enabled here:
https://chromium-review.googlesource.com/c/v8/v8/+/4491403

Bug: chromium:1434388
Change-Id: I7fb07c84f3a408add2a67b875acb513906b3e18c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4491284
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87419}
2023-05-03 16:11:24 +00:00

40 lines
1.2 KiB
C++

// Copyright 2021 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.
#ifndef INCLUDE_CPPGC_SENTINEL_POINTER_H_
#define INCLUDE_CPPGC_SENTINEL_POINTER_H_
#include <cstdint>
#include "cppgc/internal/api-constants.h"
namespace cppgc {
namespace internal {
// Special tag type used to denote some sentinel member. The semantics of the
// sentinel is defined by the embedder.
struct SentinelPointer {
#if defined(CPPGC_POINTER_COMPRESSION)
static constexpr intptr_t kSentinelValue =
1 << api_constants::kPointerCompressionShift;
#else // !defined(CPPGC_POINTER_COMPRESSION)
static constexpr intptr_t kSentinelValue = 0b10;
#endif // !defined(CPPGC_POINTER_COMPRESSION)
template <typename T>
operator T*() const {
return reinterpret_cast<T*>(kSentinelValue);
}
// Hidden friends.
friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
};
} // namespace internal
constexpr internal::SentinelPointer kSentinelPointer;
} // namespace cppgc
#endif // INCLUDE_CPPGC_SENTINEL_POINTER_H_