Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/node/cppgc/internal/caged-heap.h
$ cat -n /usr/include/node/cppgc/internal/caged-heap.h 1 // Copyright 2022 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_CAGED_HEAP_H_ 6 #define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_ 7 8 #include
9 #include
10 11 #include "cppgc/internal/api-constants.h" 12 #include "cppgc/internal/base-page-handle.h" 13 #include "v8config.h" // NOLINT(build/include_directory) 14 15 #if defined(CPPGC_CAGED_HEAP) 16 17 namespace cppgc { 18 namespace internal { 19 20 class V8_EXPORT CagedHeapBase { 21 public: 22 V8_INLINE static uintptr_t OffsetFromAddress(const void* address) { 23 return reinterpret_cast
(address) & 24 (api_constants::kCagedHeapReservationAlignment - 1); 25 } 26 27 V8_INLINE static bool IsWithinCage(const void* address) { 28 CPPGC_DCHECK(g_heap_base_); 29 return (reinterpret_cast
(address) & 30 ~(api_constants::kCagedHeapReservationAlignment - 1)) == 31 g_heap_base_; 32 } 33 34 V8_INLINE static bool AreWithinCage(const void* addr1, const void* addr2) { 35 #if defined(CPPGC_2GB_CAGE) 36 static constexpr size_t kHeapBaseShift = sizeof(uint32_t) * CHAR_BIT - 1; 37 #else //! defined(CPPGC_2GB_CAGE) 38 #if defined(CPPGC_POINTER_COMPRESSION) 39 static constexpr size_t kHeapBaseShift = 40 31 + api_constants::kPointerCompressionShift; 41 #else // !defined(CPPGC_POINTER_COMPRESSION) 42 static constexpr size_t kHeapBaseShift = sizeof(uint32_t) * CHAR_BIT; 43 #endif // !defined(CPPGC_POINTER_COMPRESSION) 44 #endif //! defined(CPPGC_2GB_CAGE) 45 static_assert((static_cast
(1) << kHeapBaseShift) == 46 api_constants::kCagedHeapMaxReservationSize); 47 CPPGC_DCHECK(g_heap_base_); 48 return !(((reinterpret_cast
(addr1) ^ g_heap_base_) | 49 (reinterpret_cast
(addr2) ^ g_heap_base_)) >> 50 kHeapBaseShift); 51 } 52 53 V8_INLINE static uintptr_t GetBase() { return g_heap_base_; } 54 V8_INLINE static size_t GetAgeTableSize() { return g_age_table_size_; } 55 56 private: 57 friend class CagedHeap; 58 59 static uintptr_t g_heap_base_; 60 static size_t g_age_table_size_; 61 }; 62 63 } // namespace internal 64 } // namespace cppgc 65 66 #endif // defined(CPPGC_CAGED_HEAP) 67 68 #endif // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2026 MyWebUniversity.com ™