v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
weak-object-worklists.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_WEAK_OBJECT_WORKLISTS_H_
6#define V8_HEAP_WEAK_OBJECT_WORKLISTS_H_
7
12
13namespace v8 {
14namespace internal {
15
20
21namespace detail {
22// SlotType will be HeapObjectSlot, which is defined in "globals.h" as an
23// incomplete type. Its definition depends on whether pointer compression
24// is used. It needs to be defined before this type is used.
25template <typename TSlotType>
31} // namespace detail
32
36
41
42class EphemeronHashTable;
43class JSFunction;
45class TransitionArray;
46
47// Weak objects and weak references discovered during incremental/concurrent
48// marking. They are processed in ClearNonLiveReferences after marking.
49// Each entry in this list specifies:
50// 1) Type of the worklist entry.
51// 2) Lower-case name of the worklsit.
52// 3) Capitalized name of the worklist.
53#define WEAK_OBJECT_WORKLISTS_GENERIC(F) \
54 F(Tagged<TransitionArray>, transition_arrays, TransitionArrays) \
55 /* Keep track of all EphemeronHashTables in the heap to process \
56 them in the atomic pause. */ \
57 F(Tagged<EphemeronHashTable>, ephemeron_hash_tables, EphemeronHashTables) \
58 /* Keep track of all ephemerons for concurrent marking tasks. Only store \
59 ephemerons in these worklists if both (key, value) are unreachable at \
60 the moment. \
61 MarkCompactCollector::MarkTransitiveClosureUntilFixpoint drains/fills \
62 these worklists. current_ephemerons is used as draining worklist in \
63 the current fixpoint iteration. */ \
64 F(Ephemeron, current_ephemerons, CurrentEphemerons) \
65 /* Stores ephemerons to visit in the next fixpoint iteration. */ \
66 F(Ephemeron, next_ephemerons, NextEphemerons) \
67 /* TODO(marja): For old space, we only need the slot, not the host object. \
68 Optimize this by adding a different storage for old space. */ \
69 F(HeapObjectAndSlot, weak_references_trivial, WeakReferencesTrivial) \
70 F(HeapObjectAndSlot, weak_references_non_trivial, WeakReferencesNonTrivial) \
71 F(HeapObjectAndSlot, weak_references_non_trivial_unmarked, \
72 WeakReferencesNonTrivialUnmarked) \
73 F(TrustedObjectAndSlot, weak_references_trusted, WeakReferencesTrusted) \
74 F(HeapObjectAndCode, weak_objects_in_code, WeakObjectsInCode) \
75 F(Tagged<JSWeakRef>, js_weak_refs, JSWeakRefs) \
76 F(Tagged<WeakCell>, weak_cells, WeakCells) \
77 F(Tagged<SharedFunctionInfo>, code_flushing_candidates, \
78 CodeFlushingCandidates) \
79 F(Tagged<JSFunction>, flushed_js_functions, FlushedJSFunctions)
80
81#ifdef V8_ENABLE_LEAPTIERING
82// Baseline code flushing for JSFunctions with leaptiering works by sweeping the
83// JSDispatchTable and does not need any additional tracking.
84#define WEAK_OBJECT_WORKLISTS(F) WEAK_OBJECT_WORKLISTS_GENERIC(F)
85#else
86#define WEAK_OBJECT_WORKLISTS(F) \
87 WEAK_OBJECT_WORKLISTS_GENERIC(F) \
88 F(Tagged<JSFunction>, baseline_flushing_candidates, \
89 BaselineFlushingCandidates)
90#endif // V8_ENABLE_LEAPTIERING
92class WeakObjects final {
93 private:
94 class UnusedBase {}; // Base class to allow using macro in initializer list.
95
96 public:
97 template <typename Type>
100 class Local final : public UnusedBase {
101 public:
102 explicit Local(WeakObjects* weak_objects);
103
105
106#define DECLARE_WORKLIST(Type, name, _) \
107 WeakObjectWorklist<Type>::Local name##_local;
109#undef DECLARE_WORKLIST
110 };
111
112#define DECLARE_WORKLIST(Type, name, _) WeakObjectWorklist<Type> name;
114#undef DECLARE_WORKLIST
115
116 void Clear();
117};
118
119} // namespace internal
120} // namespace v8
121
122#endif // V8_HEAP_WEAK_OBJECT_WORKLISTS_H_
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define WEAK_OBJECT_WORKLISTS(F)
#define DECLARE_WORKLIST(Type, name, _)