v8  9.4.146 (node 16.13.0)
V8 is Google's open source JavaScript engine
api-constants.h
Go to the documentation of this file.
1 // Copyright 2020 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
6 #define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
7 
8 #include <cstddef>
9 #include <cstdint>
10 
11 #include "v8config.h" // NOLINT(build/include_directory)
12 
13 namespace cppgc {
14 namespace internal {
15 
16 // Embedders should not rely on this code!
17 
18 // Internal constants to avoid exposing internal types on the API surface.
19 namespace api_constants {
20 
21 constexpr size_t kKB = 1024;
22 constexpr size_t kMB = kKB * 1024;
23 constexpr size_t kGB = kMB * 1024;
24 
25 // Offset of the uint16_t bitfield from the payload contaning the
26 // in-construction bit. This is subtracted from the payload pointer to get
27 // to the right bitfield.
28 static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
29  2 * sizeof(uint16_t);
30 // Mask for in-construction bit.
31 static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};
32 
33 static constexpr size_t kPageSize = size_t{1} << 17;
34 
35 static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
36 
37 #if defined(CPPGC_CAGED_HEAP)
38 constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(4) * kGB;
40 #endif
41 
42 } // namespace api_constants
43 
44 } // namespace internal
45 } // namespace cppgc
46 
47 #endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_