Download include/node/cppgc/internal/caged-heap-local-data.h from Ouzhang/node-v20-11-0-linux-x64: direct link, hf CLI and curl.
- Browser
- Download file 3.36 kB
-
https://huggingface.co/datasets/Ouzhang/node-v20-11-0-linux-x64/resolve/main/include/node/cppgc/internal/caged-heap-local-data.h
- Command line
-
hf download hf://datasets/Ouzhang/node-v20-11-0-linux-x64/include/node/cppgc/internal/caged-heap-local-data.h
-
curl -L -o caged-heap-local-data.h https://huggingface.co/datasets/Ouzhang/node-v20-11-0-linux-x64/resolve/main/include/node/cppgc/internal/caged-heap-local-data.h
3.36 kB
| // 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. | |
| namespace cppgc { | |
| namespace internal { | |
| class HeapBase; | |
| class HeapBaseHandle; | |
| // AgeTable is the bytemap needed for the fast generation check in the write | |
| // barrier. AgeTable contains entries that correspond to 4096 bytes memory | |
| // regions (cards). Each entry in the table represents generation of the objects | |
| // that reside on the corresponding card (young, old or mixed). | |
| class V8_EXPORT AgeTable final { | |
| static constexpr size_t kRequiredSize = 1 * api_constants::kMB; | |
| static constexpr size_t kAllocationGranularity = | |
| api_constants::kAllocationGranularity; | |
| public: | |
| // Represents age of the objects living on a single card. | |
| enum class Age : uint8_t { kOld, kYoung, kMixed }; | |
| // When setting age for a range, consider or ignore ages of the adjacent | |
| // cards. | |
| enum class AdjacentCardsPolicy : uint8_t { kConsider, kIgnore }; | |
| static constexpr size_t kCardSizeInBytes = | |
| api_constants::kCagedHeapReservationSize / kRequiredSize; | |
| void SetAge(uintptr_t cage_offset, Age age) { | |
| table_[card(cage_offset)] = age; | |
| } | |
| V8_INLINE Age GetAge(uintptr_t cage_offset) const { | |
| return table_[card(cage_offset)]; | |
| } | |
| void SetAgeForRange(uintptr_t cage_offset_begin, uintptr_t cage_offset_end, | |
| Age age, AdjacentCardsPolicy adjacent_cards_policy); | |
| Age GetAgeForRange(uintptr_t cage_offset_begin, | |
| uintptr_t cage_offset_end) const; | |
| void ResetForTesting(); | |
| private: | |
| V8_INLINE size_t card(uintptr_t offset) const { | |
| constexpr size_t kGranularityBits = | |
| std::countr_zero(static_cast<uint32_t>(kCardSizeInBytes)); | |
| __builtin_ctz(static_cast<uint32_t>(kCardSizeInBytes)); | |
| // Hardcode and check with assert. | |
| 11; | |
| 12; | |
| static_assert((1 << kGranularityBits) == kCardSizeInBytes); | |
| const size_t entry = offset >> kGranularityBits; | |
| CPPGC_DCHECK(table_.size() > entry); | |
| return entry; | |
| } | |
| std::array<Age, kRequiredSize> table_; | |
| }; | |
| static_assert(sizeof(AgeTable) == 1 * api_constants::kMB, | |
| "Size of AgeTable is 1MB"); | |
| struct CagedHeapLocalData final { | |
| V8_INLINE static CagedHeapLocalData& Get() { | |
| return *reinterpret_cast<CagedHeapLocalData*>(CagedHeapBase::GetBase()); | |
| } | |
| AgeTable age_table; | |
| }; | |
| } // namespace internal | |
| } // namespace cppgc | |