v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
unified-heap-marking-state-inl.h
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
5#ifndef V8_HEAP_CPPGC_JS_UNIFIED_HEAP_MARKING_STATE_INL_H_
6#define V8_HEAP_CPPGC_JS_UNIFIED_HEAP_MARKING_STATE_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include <atomic>
12
14#include "src/base/logging.h"
16#include "src/heap/heap.h"
22
23namespace v8 {
24namespace internal {
25
27 public:
29 return const_cast<Address*>(ref.GetSlotThreadSafe());
30 }
31};
32
34 const TracedReferenceBase& reference) {
35 // The following code will crash with null pointer derefs when finding a
36 // non-empty `TracedReferenceBase` when `CppHeap` is in detached mode.
37 Address* traced_handle_location =
39 // We cannot assume that the reference is non-null as we may get here by
40 // tracing an ephemeron which doesn't have early bailouts, see
41 // `cppgc::Visitor::TraceEphemeron()` for non-Member values.
42 if (!traced_handle_location) {
43 return;
44 }
45 Tagged<Object> object =
46 TracedHandles::Mark(traced_handle_location, mark_mode_);
47 if (!IsHeapObject(object)) {
48 // The embedder is not aware of whether numbers are materialized as heap
49 // objects are just passed around as Smis.
50 return;
51 }
52 Tagged<HeapObject> heap_object = Cast<HeapObject>(object);
53 const auto worklist_target =
55 if (worklist_target) {
57 marking_state_, worklist_target.value(),
58 heap_object);
59 }
60}
61
62} // namespace internal
63} // namespace v8
64
65#endif // V8_HEAP_CPPGC_JS_UNIFIED_HEAP_MARKING_STATE_INL_H_
const internal::Address * GetSlotThreadSafe() const
static Address * GetObjectSlotForMarking(const TracedReferenceBase &ref)
static Tagged< Object > Mark(Address *location, MarkMode mark_mode)
V8_INLINE void MarkAndPush(const TracedReferenceBase &)
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)