v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
new-spaces-inl.h
Go to the documentation of this file.
1// Copyright 2020 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_NEW_SPACES_INL_H_
6#define V8_HEAP_NEW_SPACES_INL_H_
7
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"
15#include "src/heap/spaces-inl.h"
18#include "src/objects/tagged.h"
19
20namespace v8 {
21namespace internal {
22
23// -----------------------------------------------------------------------------
24// SemiSpace
25
28 if (memory_chunk->IsLargePage()) return false;
29 return id_ == kToSpace ? memory_chunk->IsToPage()
30 : memory_chunk->IsFromPage();
31}
32
36
37template <typename T>
38inline bool SemiSpace::Contains(Tagged<T> o) const {
39 static_assert(kTaggedCanConvertToRawObjects);
40 return Contains(*o);
41}
42
44 for (const PageMetadata* p : *this) {
45 if (p == MemoryChunkMetadata::FromAddress(a)) return true;
46 }
47 return false;
48}
49
50// --------------------------------------------------------------------------
51// NewSpace
52
56
60
61// -----------------------------------------------------------------------------
62// SemiSpaceObjectIterator
63
65 : current_(space->first_allocatable_address()) {}
66
68 if (!current_) return {};
69
70 while (true) {
73 page = page->next_page();
74 if (page == nullptr) return {};
75 current_ = page->area_start();
76 }
78 current_ += ALIGN_TO_ALLOCATION_ALIGNMENT(object->Size());
79 if (!IsFreeSpaceOrFiller(object)) return object;
80 }
81}
82
89
96
98 // Note that we use MemoryChunk here on purpose to avoid the page metadata
99 // table lookup for performance reasons.
100 MemoryChunk* chunk = MemoryChunk::FromAddress(address);
101
102 // This method is only ever used on non-large pages in the young generation.
103 // However, on page promotion (new to old) during a full GC the page flags are
104 // already updated to old space before using this method.
105 DCHECK(chunk->InYoungGeneration() ||
107 DCHECK(!chunk->IsLargePage());
108
110 return false;
111 }
112
113 const Address age_mark = age_mark_;
114 const bool on_age_mark_page =
115 chunk->address() < age_mark &&
117 DCHECK_EQ(chunk->Metadata()->ContainsLimit(age_mark), on_age_mark_page);
118 return !on_age_mark_page || address < age_mark;
119}
120
122 return IsAddressBelowAgeMark(object);
123}
124
125} // namespace internal
126} // namespace v8
127
128#endif // V8_HEAP_NEW_SPACES_INL_H_
static Tagged< HeapObject > FromAddress(Address address)
static V8_INLINE MemoryChunkMetadata * FromAddress(Address a)
V8_INLINE bool IsFlagSet(Flag flag) const
V8_INLINE Address address() const
V8_INLINE MemoryChunkMetadata * Metadata()
static V8_INLINE MemoryChunk * FromAddress(Address addr)
V8_INLINE bool InYoungGeneration() const
static V8_INLINE MemoryChunk * FromHeapObject(Tagged< HeapObject > object)
bool Contains(Tagged< Object > o) const
static V8_INLINE PageMetadata * FromAllocationAreaAddress(Address address)
static bool IsAlignedToPageSize(Address addr)
V8_INLINE void IncrementAllocationTop(Address new_top)
V8_INLINE void DecrementAllocationTop(Address new_top)
V8_INLINE bool IsAddressBelowAgeMark(Address address) const
V8_INLINE bool ShouldBePromoted(Address object) const
SemiSpaceObjectIterator(const SemiSpaceNewSpace *space)
Tagged< HeapObject > Next() final
bool Contains(Tagged< HeapObject > o) const
bool ContainsSlow(Address a) const
#define ALIGN_TO_ALLOCATION_ALIGNMENT(value)
Definition globals.h:1796
static constexpr bool kTaggedCanConvertToRawObjects
Definition tagged.h:329
V8_INLINE constexpr bool IsHeapObject(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:669
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
base::uc32 current_
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485