#ifndef V8_HEAP_WEAK_OBJECT_WORKLISTS_H_
#define V8_HEAP_WEAK_OBJECT_WORKLISTS_H_
#include "src/common/globals.h"
#include "src/heap/base/worklist.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-weak-refs.h"
namespace v8 {
namespace internal {
struct Ephemeron {
Tagged<HeapObject> key;
Tagged<HeapObject> value;
};
namespace detail {
template <typename TSlotType>
struct HeapObjectAndSlotPOD {
using SlotType = TSlotType;
Tagged<HeapObject> heap_object;
SlotType slot;
};
}
using HeapObjectAndSlot = detail::HeapObjectAndSlotPOD<HeapObjectSlot>;
using TrustedObjectAndSlot =
detail::HeapObjectAndSlotPOD<ProtectedMaybeObjectSlot>;
struct HeapObjectAndCode {
Tagged<HeapObject> heap_object;
Tagged<Code> code;
};
struct DispatchHandleAndCode {
JSDispatchHandle dispatch_handle;
Tagged<Code> code;
};
class EphemeronHashTable;
class JSFunction;
class SharedFunctionInfo;
class TransitionArray;
#define WEAK_OBJECT_WORKLISTS(F) \
F(Tagged<TransitionArray>, transition_arrays, TransitionArrays) \
them in the atomic pause. */ \
F(Tagged<EphemeronHashTable>, ephemeron_hash_tables, EphemeronHashTables) \
ephemerons in these worklists if both (key, value) are unreachable at \
the moment. \
MarkCompactCollector::MarkTransitiveClosureUntilFixpoint drains/fills \
these worklists. current_ephemerons is used as draining worklist in \
the current fixpoint iteration. */ \
F(Ephemeron, current_ephemerons, CurrentEphemerons) \
\
F(Ephemeron, next_ephemerons, NextEphemerons) \
Optimize this by adding a different storage for old space. */ \
F(HeapObjectAndSlot, weak_references_trivial, WeakReferencesTrivial) \
F(HeapObjectAndSlot, weak_references_non_trivial, WeakReferencesNonTrivial) \
F(HeapObjectAndSlot, weak_references_non_trivial_unmarked, \
WeakReferencesNonTrivialUnmarked) \
F(TrustedObjectAndSlot, weak_references_trusted, WeakReferencesTrusted) \
F(HeapObjectAndCode, weak_objects_in_code, WeakObjectsInCode) \
F(DispatchHandleAndCode, weak_dispatch_handles_in_code, \
WeakDispatchHandlesInCode) \
F(Tagged<JSWeakRef>, js_weak_refs, JSWeakRefs) \
F(Tagged<WeakCell>, weak_cells, WeakCells) \
F(Tagged<SharedFunctionInfo>, code_flushing_candidates, \
CodeFlushingCandidates) \
F(Tagged<JSFunction>, flushed_js_functions, FlushedJSFunctions)
class WeakObjects final {
private:
class UnusedBase {};
public:
template <typename Type>
using WeakObjectWorklist = ::heap::base::Worklist<Type, 64>;
class Local final : public UnusedBase {
public:
explicit Local(WeakObjects* weak_objects);
V8_EXPORT_PRIVATE void Publish();
#define DECLARE_WORKLIST(Type, name, _) \
WeakObjectWorklist<Type>::Local name##_local;
WEAK_OBJECT_WORKLISTS(DECLARE_WORKLIST)
#undef DECLARE_WORKLIST
};
#define DECLARE_WORKLIST(Type, name, _) WeakObjectWorklist<Type> name;
WEAK_OBJECT_WORKLISTS(DECLARE_WORKLIST)
#undef DECLARE_WORKLIST
void Clear();
};
}
}
#endif