v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
page-metadata.cc
Go to the documentation of this file.
1// Copyright 2023 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
6
7#include "src/heap/heap-inl.h"
10
11namespace v8 {
12namespace internal {
13
15 Address area_start, Address area_end,
16 VirtualMemory reservation)
17 : MutablePageMetadata(heap, space, size, area_start, area_end,
18 std::move(reservation), PageSize::kRegular) {
20}
21
32
39
41 if (categories_ != nullptr) {
42 for (int i = kFirstCategory; i <= owner()->free_list()->last_category();
43 i++) {
44 if (categories_[i] != nullptr) {
45 delete categories_[i];
46 categories_[i] = nullptr;
47 }
48 }
49 delete[] categories_;
50 categories_ = nullptr;
51 }
52}
53
55 FreeMode free_mode) {
56 DCHECK(old_page);
57 MemoryChunk* chunk = old_page->Chunk();
58 DCHECK(chunk->InNewSpace());
59 old_page->ResetAgeInNewSpace();
60 OldSpace* old_space = old_page->heap()->old_space();
61 old_page->set_owner(old_space);
63 DCHECK_NE(old_space->identity(), SHARED_SPACE);
66 PageMetadata* new_page = old_space->InitializePage(old_page);
67 old_space->AddPromotedPage(new_page, free_mode);
68 return new_page;
69}
70
72 size_t sum = 0;
74 [&sum](FreeListCategory* category) { sum += category->available(); });
75 return sum;
76}
77
79 MemoryChunk* chunk = Chunk();
84 reinterpret_cast<PagedSpace*>(owner())->free_list()->EvictFreeListItems(this);
85}
86
101
116
117} // namespace internal
118} // namespace v8
uint32_t available() const
Definition free-list.h:80
void Initialize(FreeListCategoryType type)
Definition free-list.h:47
FreeListCategoryType last_category()
Definition free-list.h:196
IncrementalMarking * incremental_marking() const
Definition heap.h:1062
OldSpace * old_space() const
Definition heap.h:730
static V8_INLINE constexpr MarkBitIndex LimitAddressToIndex(Address address)
void ClearRange(MarkBitIndex start_index, MarkBitIndex end_index)
static V8_INLINE constexpr MarkBitIndex AddressToIndex(Address address)
void SetRange(MarkBitIndex start_index, MarkBitIndex end_index)
Definition marking-inl.h:91
static constexpr MainThreadFlags kAllFlagsMask
void SetOldGenerationPageFlags(MarkingMode marking_mode, AllocationSpace space)
V8_INLINE bool IsFlagSet(Flag flag) const
void SetFlagSlow(Flag flag)
V8_INLINE void ClearFlagsNonExecutable(MainThreadFlags flags)
void AddPromotedPage(PageMetadata *page, FreeMode free_mode)
V8_EXPORT_PRIVATE size_t AvailableInFreeList()
void ForAllFreeListCategories(Callback callback)
static PageMetadata * ConvertNewToOld(PageMetadata *old_page, FreeMode free_mode)
PageMetadata(Heap *heap, BaseSpace *space, size_t size, Address area_start, Address area_end, VirtualMemory reservation)
V8_EXPORT_PRIVATE void MarkNeverAllocateForTesting()
static V8_INLINE PageMetadata * FromAddress(Address addr)
void DestroyBlackArea(Address start, Address end)
V8_EXPORT_PRIVATE void CreateBlackArea(Address start, Address end)
PageMetadata * InitializePage(MutablePageMetadata *chunk) override
FreeList * free_list()
Definition spaces.h:123
virtual void NotifyBlackAreaDestroyed(size_t size)
Definition spaces.h:121
virtual void NotifyBlackAreaCreated(size_t size)
Definition spaces.h:120
int start
int end
STL namespace.
static constexpr FreeListCategoryType kFirstCategory
Definition free-list.h:39
int32_t FreeListCategoryType
Definition free-list.h:37
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK_NULL(val)
Definition logging.h:491
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485