v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
traced-handles-marking-visitor.cc
Go to the documentation of this file.
1// Copyright 2022 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 <algorithm>
8#include <iterator>
9
12#include "src/heap/marking.h"
13
14namespace v8 {
15namespace internal {
16
19 Heap& heap, MarkingWorklists::Local& local_marking_worklist,
20 cppgc::internal::CollectionType collection_type)
21 : heap_(heap),
22 marking_state_(*heap_.marking_state()),
23 local_marking_worklist_(local_marking_worklist),
24 traced_node_bounds_(heap.isolate()->traced_handles()->GetNodeBounds()),
25 mark_mode_(collection_type == cppgc::internal::CollectionType::kMinor
26 ? TracedHandles::MarkMode::kOnlyYoung
27 : TracedHandles::MarkMode::kAll) {}
28
30 const void* address) {
31 const auto upper_it = std::upper_bound(
32 traced_node_bounds_.begin(), traced_node_bounds_.end(), address,
33 [](const void* needle, const auto& pair) { return needle < pair.first; });
34 // Also checks emptiness as begin() == end() on empty bounds.
35 if (upper_it == traced_node_bounds_.begin()) return;
36
37 const auto bounds = std::next(upper_it, -1);
38 if (address < bounds->second) {
40 const_cast<Address*>(reinterpret_cast<const Address*>(address)),
41 const_cast<Address*>(reinterpret_cast<const Address*>(bounds->first)),
43 if (!IsHeapObject(object)) {
44 // The embedder is not aware of whether numbers are materialized as heap
45 // objects are just passed around as Smis. This branch also filters out
46 // intentionally passed `Smi::zero()` that indicate that there's no
47 // object to mark.
48 return;
49 }
50 Tagged<HeapObject> heap_object = Cast<HeapObject>(object);
51 const auto target_worklist =
53 if (target_worklist) {
55 &marking_state_, target_worklist.value(),
56 heap_object);
57 }
58 }
59}
60
61} // namespace internal
62} // namespace v8
ConservativeTracedHandlesMarkingVisitor(Heap &, MarkingWorklists::Local &, cppgc::internal::CollectionType)
static Tagged< Object > MarkConservatively(Address *inner_location, Address *traced_node_block_base, MarkMode mark_mode)
double second
NonAtomicMarkingState * marking_state_
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
static V8_INLINE bool TryMarkAndPush(Heap *heap, MarkingWorklists::Local *marking_worklist, MarkingState *marking_state, WorklistTarget target_worklis, Tagged< HeapObject > object)
static V8_INLINE std::optional< WorklistTarget > ShouldMarkObject(Heap *heap, Tagged< HeapObject > object)
Heap * heap_