v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
spaces-inl.h
Go to the documentation of this file.
1// Copyright 2011 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 V8_HEAP_SPACES_INL_H_
6#define V8_HEAP_SPACES_INL_H_
7
8#include "src/heap/spaces.h"
9// Include the non-inl header before the rest of the headers.
10
12#include "src/common/globals.h"
13#include "src/heap/heap.h"
17#include "src/heap/new-spaces.h"
19
20namespace v8 {
21namespace internal {
22
23template <class PageType>
25 p_ = p_->next_page();
26 return *this;
27}
28
29template <class PageType>
35
42
49
51 Space* from, Space* to,
52 size_t amount) {
53 if (from == to) return;
54
56 &(from->external_backing_store_bytes_[static_cast<int>(type)]), amount);
58 &(to->external_backing_store_bytes_[static_cast<int>(type)]), amount);
59}
60
61PageRange::PageRange(PageMetadata* page) : PageRange(page, page->next_page()) {}
63 : ConstPageRange(page, page->next_page()) {}
64
66 : heap_(heap), state_(kOldSpace), iterator_(heap->old_space()->begin()) {}
67
69 switch (state_) {
70 case kOldSpace: {
71 PageIterator& iterator = std::get<PageIterator>(iterator_);
72 if (iterator != heap_->old_space()->end()) return *(iterator++);
75 [[fallthrough]];
76 }
77 case kCodeSpace: {
78 PageIterator& iterator = std::get<PageIterator>(iterator_);
79 if (iterator != heap_->code_space()->end()) return *(iterator++);
82 [[fallthrough]];
83 }
84 case kLargeObjectSpace: {
85 LargePageIterator& iterator = std::get<LargePageIterator>(iterator_);
86 if (iterator != heap_->lo_space()->end()) return *(iterator++);
89 [[fallthrough]];
90 }
92 LargePageIterator& iterator = std::get<LargePageIterator>(iterator_);
93 if (iterator != heap_->code_lo_space()->end()) return *(iterator++);
96 [[fallthrough]];
97 }
98 case kTrustedSpace: {
99 PageIterator& iterator = std::get<PageIterator>(iterator_);
100 if (iterator != heap_->trusted_space()->end()) return *(iterator++);
103 [[fallthrough]];
104 }
106 LargePageIterator& iterator = std::get<LargePageIterator>(iterator_);
107 if (iterator != heap_->trusted_lo_space()->end()) return *(iterator++);
109 [[fallthrough]];
110 }
111 case kFinished:
112 return nullptr;
113 }
114}
115
117 if (current_chunk_) return true;
118
119 while (space_iterator_.HasNext()) {
120 Space* space = space_iterator_.Next();
121 current_chunk_ = space->first_page();
122 if (current_chunk_) return true;
123 }
124
125 return false;
126}
127
130 current_chunk_ = chunk->list_node().next();
131 return chunk;
132}
133
134} // namespace internal
135} // namespace v8
136
137#endif // V8_HEAP_SPACES_INL_H_
Heap * heap() const
Definition base-space.h:27
ConstPageRange(const PageMetadata *begin, const PageMetadata *end)
Definition spaces.h:204
OldLargeObjectSpace * lo_space() const
Definition heap.h:734
OldSpace * old_space() const
Definition heap.h:730
TrustedSpace * trusted_space() const
Definition heap.h:739
void IncrementExternalBackingStoreBytes(ExternalBackingStoreType type, size_t amount)
Definition heap-inl.h:410
CodeLargeObjectSpace * code_lo_space() const
Definition heap.h:735
TrustedLargeObjectSpace * trusted_lo_space() const
Definition heap.h:743
void DecrementExternalBackingStoreBytes(ExternalBackingStoreType type, size_t amount)
Definition heap-inl.h:418
CodeSpace * code_space() const
Definition heap.h:732
MutablePageMetadata * current_chunk_
Definition spaces.h:251
V8_INLINE MutablePageMetadata * Next()
Definition spaces-inl.h:128
heap::ListNode< MutablePageMetadata > & list_node()
std::variant< PageIterator, LargePageIterator > iterator_
PageIteratorImpl< PageType > & operator++()
Definition spaces-inl.h:24
PageRange(PageMetadata *begin, PageMetadata *end)
Definition spaces.h:189
static void MoveExternalBackingStoreBytes(ExternalBackingStoreType type, Space *from, Space *to, size_t amount)
Definition spaces-inl.h:50
void IncrementExternalBackingStoreBytes(ExternalBackingStoreType type, size_t amount)
Definition spaces-inl.h:36
void DecrementExternalBackingStoreBytes(ExternalBackingStoreType type, size_t amount)
Definition spaces-inl.h:43
std::atomic< size_t > external_backing_store_bytes_[static_cast< int >(ExternalBackingStoreType::kNumValues)]
Definition spaces.h:139
enum v8::internal::@1270::DeoptimizableCodeIterator::@67 state_
Register tmp
void CheckedDecrement(std::atomic< T > *number, T amount, std::memory_order order=std::memory_order_seq_cst)
void CheckedIncrement(std::atomic< T > *number, T amount, std::memory_order order=std::memory_order_seq_cst)
ExternalBackingStoreType
Definition globals.h:1605
V8_INLINE Builtin operator++(Builtin &builtin)
Definition builtins.h:80
Heap * heap_