Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:15:55

0001 // Copyright 2022 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
0006 #define INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
0007 
0008 #include "cppgc/heap-handle.h"
0009 #include "cppgc/internal/api-constants.h"
0010 #include "cppgc/internal/logging.h"
0011 #include "v8config.h"  // NOLINT(build/include_directory)
0012 
0013 namespace cppgc {
0014 namespace internal {
0015 
0016 // The class is needed in the header to allow for fast access to HeapHandle in
0017 // the write barrier.
0018 class BasePageHandle {
0019  public:
0020   static V8_INLINE BasePageHandle* FromPayload(void* payload) {
0021     return reinterpret_cast<BasePageHandle*>(
0022         reinterpret_cast<uintptr_t>(payload) & ~(api_constants::kPageSize - 1));
0023   }
0024   static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
0025     return FromPayload(const_cast<void*>(payload));
0026   }
0027 
0028   HeapHandle& heap_handle() { return heap_handle_; }
0029   const HeapHandle& heap_handle() const { return heap_handle_; }
0030 
0031  protected:
0032   explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
0033     CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
0034                  0);
0035   }
0036 
0037   HeapHandle& heap_handle_;
0038 };
0039 
0040 }  // namespace internal
0041 }  // namespace cppgc
0042 
0043 #endif  // INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_