2020-03-25 15:59:13 +00:00
|
|
|
// 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.
|
|
|
|
|
2020-04-07 21:54:43 +00:00
|
|
|
#ifndef INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
|
|
|
|
#define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
|
2020-03-25 15:59:13 +00:00
|
|
|
|
2021-05-20 09:36:52 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2020-03-25 15:59:13 +00:00
|
|
|
|
2020-04-27 16:29:03 +00:00
|
|
|
#include "v8config.h" // NOLINT(build/include_directory)
|
2020-03-25 15:59:13 +00:00
|
|
|
|
|
|
|
namespace cppgc {
|
|
|
|
namespace internal {
|
|
|
|
|
2020-03-27 10:02:58 +00:00
|
|
|
// Embedders should not rely on this code!
|
|
|
|
|
2020-03-25 15:59:13 +00:00
|
|
|
// Internal constants to avoid exposing internal types on the API surface.
|
|
|
|
namespace api_constants {
|
2020-06-15 18:57:06 +00:00
|
|
|
|
|
|
|
constexpr size_t kKB = 1024;
|
|
|
|
constexpr size_t kMB = kKB * 1024;
|
|
|
|
constexpr size_t kGB = kMB * 1024;
|
|
|
|
|
2020-03-25 15:59:13 +00:00
|
|
|
// Offset of the uint16_t bitfield from the payload contaning the
|
|
|
|
// in-construction bit. This is subtracted from the payload pointer to get
|
|
|
|
// to the right bitfield.
|
|
|
|
static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
|
|
|
|
2 * sizeof(uint16_t);
|
|
|
|
// Mask for in-construction bit.
|
2020-11-11 16:07:43 +00:00
|
|
|
static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};
|
2020-03-25 15:59:13 +00:00
|
|
|
|
2020-04-09 07:18:50 +00:00
|
|
|
static constexpr size_t kPageSize = size_t{1} << 17;
|
|
|
|
|
2022-06-27 11:37:04 +00:00
|
|
|
#if defined(V8_TARGET_ARCH_ARM64) && defined(V8_OS_MACOS)
|
2022-06-08 15:07:01 +00:00
|
|
|
constexpr size_t kGuardPageSize = 0;
|
|
|
|
#else
|
|
|
|
constexpr size_t kGuardPageSize = 4096;
|
|
|
|
#endif
|
|
|
|
|
2020-04-09 07:18:50 +00:00
|
|
|
static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
|
2020-04-01 15:15:38 +00:00
|
|
|
|
2020-06-15 18:57:06 +00:00
|
|
|
#if defined(CPPGC_CAGED_HEAP)
|
|
|
|
constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(4) * kGB;
|
|
|
|
constexpr size_t kCagedHeapReservationAlignment = kCagedHeapReservationSize;
|
2022-06-05 13:30:41 +00:00
|
|
|
|
|
|
|
constexpr size_t kCagedHeapNormalPageReservationSize =
|
|
|
|
kCagedHeapReservationSize / 2;
|
2020-06-15 18:57:06 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-12 11:23:03 +00:00
|
|
|
static constexpr size_t kDefaultAlignment = sizeof(void*);
|
|
|
|
|
|
|
|
// Maximum support alignment for a type as in `alignof(T)`.
|
|
|
|
static constexpr size_t kMaxSupportedAlignment = 2 * kDefaultAlignment;
|
|
|
|
|
2022-04-13 13:19:02 +00:00
|
|
|
// Granularity of heap allocations.
|
|
|
|
constexpr size_t kAllocationGranularity = sizeof(void*);
|
|
|
|
|
2020-03-25 15:59:13 +00:00
|
|
|
} // namespace api_constants
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace cppgc
|
|
|
|
|
2020-04-07 21:54:43 +00:00
|
|
|
#endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
|