v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
live-object-range.h
Go to the documentation of this file.
1// Copyright 2024 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_LIVE_OBJECT_RANGE_H_
6#define V8_HEAP_LIVE_OBJECT_RANGE_H_
7
8#include <utility>
9
10#include "src/heap/marking.h"
12
13namespace v8::internal {
14
15class PageMetadata;
16
17class LiveObjectRange final {
18 public:
19 class iterator final {
20 public:
21 using value_type = std::pair<Tagged<HeapObject>, int /* size */>;
22 using pointer = const value_type*;
23 using reference = const value_type&;
24 using iterator_category = std::forward_iterator_tag;
25
26 inline iterator();
27 explicit inline iterator(const PageMetadata* page);
28
29 inline iterator& operator++();
30 inline iterator operator++(int);
31
32 bool operator==(iterator other) const {
33 return current_object_ == other.current_object_;
34 }
35 bool operator!=(iterator other) const { return !(*this == other); }
36
38 return std::make_pair(current_object_, current_size_);
39 }
40
41 private:
42 inline bool AdvanceToNextMarkedObject();
43 inline void AdvanceToNextValidObject();
44
45 const PageMetadata* const page_ = nullptr;
46 const MarkBit::CellType* const cells_ = nullptr;
53 };
54
55 explicit LiveObjectRange(const PageMetadata* page) : page_(page) {}
56
57 inline iterator begin();
58 inline iterator end();
59
60 private:
61 const PageMetadata* const page_;
62};
63
64} // namespace v8::internal
65
66#endif // V8_HEAP_LIVE_OBJECT_RANGE_H_
std::pair< Tagged< HeapObject >, int > value_type
const MarkBit::CellType *const cells_
MarkingBitmap::CellIndex current_cell_index_
std::forward_iterator_tag iterator_category
LiveObjectRange(const PageMetadata *page)
const PageMetadata *const page_
uintptr_t CellType
Definition marking.h:21
MarkBit::CellType CellType
Definition marking.h:94