Flutter Engine
The Flutter Engine
Friends | List of all members
dart::UntaggedFinalizerBase Class Reference

#include <raw_object.h>

Inheritance diagram for dart::UntaggedFinalizerBase:
dart::UntaggedInstance dart::UntaggedObject dart::UntaggedFinalizer dart::UntaggedNativeFinalizer

Friends

template<bool >
class MarkingVisitorBase
 
template<bool >
class ScavengerVisitorBase
 
class ObjectGraph
 
template<typename GCVisitorType >
void MournFinalizerEntry (GCVisitorType *, FinalizerEntryPtr)
 

Additional Inherited Members

- Public Types inherited from dart::UntaggedObject
enum  TagBits {
  kCardRememberedBit = 0 , kCanonicalBit = 1 , kNotMarkedBit = 2 , kNewOrEvacuationCandidateBit = 3 ,
  kAlwaysSetBit = 4 , kOldAndNotRememberedBit = 5 , kImmutableBit = 6 , kReservedBit = 7 ,
  kSizeTagPos = kReservedBit + 1 , kSizeTagSize = 4 , kClassIdTagPos = kSizeTagPos + kSizeTagSize , kClassIdTagSize = 20 ,
  kHashTagPos = kClassIdTagPos + kClassIdTagSize , kHashTagSize = 32
}
 
- Public Member Functions inherited from dart::UntaggedObject
 COMPILE_ASSERT (kNotMarkedBit+kBarrierOverlapShift==kAlwaysSetBit)
 
 COMPILE_ASSERT (kNewOrEvacuationCandidateBit+kBarrierOverlapShift==kOldAndNotRememberedBit)
 
 COMPILE_ASSERT (kCardRememberedBit==0)
 
 COMPILE_ASSERT (kBitsPerByte *sizeof(ClassIdTagType) >=kClassIdTagSize)
 
 COMPILE_ASSERT (kClassIdTagMax==(1<< kClassIdTagSize) - 1)
 
bool IsNewObject () const
 
bool IsOldObject () const
 
uword tags () const
 
uword tags_ignore_race () const
 
bool IsMarked () const
 
void SetMarkBit ()
 
void SetMarkBitUnsynchronized ()
 
void SetMarkBitRelease ()
 
void ClearMarkBit ()
 
void ClearMarkBitUnsynchronized ()
 
DART_WARN_UNUSED_RESULT bool TryAcquireMarkBit ()
 
bool IsEvacuationCandidate ()
 
void SetIsEvacuationCandidate ()
 
void SetIsEvacuationCandidateUnsynchronized ()
 
void ClearIsEvacuationCandidateUnsynchronized ()
 
bool IsCanonical () const
 
void SetCanonical ()
 
void ClearCanonical ()
 
bool IsImmutable () const
 
void SetImmutable ()
 
void ClearImmutable ()
 
bool InVMIsolateHeap () const
 
bool IsRemembered () const
 
bool TryAcquireRememberedBit ()
 
void ClearRememberedBit ()
 
void ClearRememberedBitUnsynchronized ()
 
DART_FORCE_INLINE void EnsureInRememberedSet (Thread *thread)
 
bool IsCardRemembered () const
 
void SetCardRememberedBitUnsynchronized ()
 
intptr_t GetClassId () const
 
intptr_t HeapSize () const
 
intptr_t HeapSize (uword tags) const
 
bool Contains (uword addr) const
 
void Validate (IsolateGroup *isolate_group) const
 
intptr_t VisitPointers (ObjectPointerVisitor *visitor)
 
template<class V >
DART_FORCE_INLINE intptr_t VisitPointersNonvirtual (V *visitor)
 
void VisitPointersPrecise (ObjectPointerVisitor *visitor)
 
- Static Public Member Functions inherited from dart::UntaggedObject
static bool IsMarked (uword tags)
 
static bool IsEvacuationCandidate (uword tags)
 
static ObjectPtr FromAddr (uword addr)
 
static uword ToAddr (const UntaggedObject *raw_obj)
 
static uword ToAddr (const ObjectPtr raw_obj)
 
static bool IsCanonical (intptr_t value)
 
- Static Public Attributes inherited from dart::UntaggedInstance
static constexpr bool kContainsCompressedPointers = false
 
- Static Public Attributes inherited from dart::UntaggedObject
static constexpr intptr_t kGenerationalBarrierMask
 
static constexpr intptr_t kIncrementalBarrierMask = 1 << kNotMarkedBit
 
static constexpr intptr_t kBarrierOverlapShift = 2
 
- Protected Member Functions inherited from dart::UntaggedObject
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type LoadCompressedPointer (compressed_type const *addr) const
 
uword heap_base () const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value)
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value)
 
template<typename type >
void StorePointer (type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type >
void StoreCompressedPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread)
 
template<typename type , std::memory_order order = std::memory_order_relaxed, typename value_type = type>
void StoreArrayPointer (type const *addr, value_type value)
 
template<typename type , typename value_type = type>
void StoreArrayPointer (type const *addr, value_type value, Thread *thread)
 
template<typename type , typename compressed_type , std::memory_order order>
void StoreCompressedArrayPointer (compressed_type const *addr, type value)
 
template<typename type , typename compressed_type , std::memory_order order>
void StoreCompressedArrayPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type >
void StoreCompressedArrayPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type ExchangeCompressedPointer (compressed_type const *addr, type value)
 
template<std::memory_order order = std::memory_order_relaxed>
SmiPtr LoadSmi (SmiPtr const *addr) const
 
template<std::memory_order order = std::memory_order_relaxed>
SmiPtr LoadCompressedSmi (CompressedSmiPtr const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StoreSmi (type const *addr, type value)
 
template<std::memory_order order = std::memory_order_relaxed>
void StoreCompressedSmi (CompressedSmiPtr const *addr, SmiPtr value)
 
- Static Protected Member Functions inherited from dart::UntaggedObject
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
template<>
DART_FORCE_INLINE uword from_offset ()
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 
- Static Protected Attributes inherited from dart::UntaggedObject
static constexpr bool kContainsCompressedPointers = false
 
static constexpr bool kContainsPointerFields = false
 

Detailed Description

Definition at line 3626 of file raw_object.h.

Friends And Related Function Documentation

◆ MarkingVisitorBase

template<bool >
friend class MarkingVisitorBase
friend

Definition at line 3652 of file raw_object.h.

◆ MournFinalizerEntry

template<typename GCVisitorType >
void MournFinalizerEntry ( GCVisitorType *  visitor,
FinalizerEntryPtr  current_entry 
)
friend

Definition at line 162 of file gc_shared.h.

163 {
164 TRACE_FINALIZER("Processing Entry %p", current_entry->untag());
165
166 const Heap::Space before_gc_space = SpaceForExternal(current_entry);
167 const bool value_collected_this_gc =
168 GCVisitorType::ForwardOrSetNullIfCollected(
169 current_entry, &current_entry->untag()->value_);
170 if (!value_collected_this_gc && before_gc_space == Heap::kNew) {
171 const Heap::Space after_gc_space = SpaceForExternal(current_entry);
172 if (after_gc_space == Heap::kOld) {
173 const intptr_t external_size = current_entry->untag()->external_size_;
174 TRACE_FINALIZER("Promoting external size %" Pd
175 " bytes from new to old space",
176 external_size);
177 visitor->isolate_group()->heap()->PromotedExternal(external_size);
178 }
179 }
180 GCVisitorType::ForwardOrSetNullIfCollected(current_entry,
181 &current_entry->untag()->detach_);
182 GCVisitorType::ForwardOrSetNullIfCollected(
183 current_entry, &current_entry->untag()->finalizer_);
184
185 ObjectPtr token_object = current_entry->untag()->token();
186 // See sdk/lib/_internal/vm/lib/internal_patch.dart FinalizerBase.detach.
187 const bool is_detached = token_object == current_entry;
188
189 if (!value_collected_this_gc) return;
190 if (is_detached) return;
191
192 FinalizerBasePtr finalizer = current_entry->untag()->finalizer();
193
194 if (finalizer.IsRawNull()) {
195 TRACE_FINALIZER("Value collected entry %p finalizer null",
196 current_entry->untag());
197
198 // Do nothing, the finalizer has been GCed.
199 return;
200 }
201
202 TRACE_FINALIZER("Value collected entry %p finalizer %p",
203 current_entry->untag(), finalizer->untag());
204
205 FinalizerPtr finalizer_dart = static_cast<FinalizerPtr>(finalizer);
206 // Move entry to entries collected and current head of that list as
207 // the next element. Using a atomic exchange satisfies concurrency
208 // between the parallel GC tasks.
209 // We rely on the fact that the mutator thread is not running to avoid
210 // races between GC and mutator modifying Finalizer.entries_collected.
211 //
212 // We only run in serial marker or in the finalize step in the marker,
213 // both are in safepoint.
214 // The main scavenger worker is at safepoint, the other scavenger
215 // workers are not, but they bypass safepoint because the main
216 // worker is at a safepoint already.
217 ASSERT(Thread::Current()->OwnsGCSafepoint() ||
218 Thread::Current()->BypassSafepoints());
219
220 if (finalizer.IsNativeFinalizer()) {
221 NativeFinalizerPtr native_finalizer =
222 static_cast<NativeFinalizerPtr>(finalizer);
223
224 // Immediately call native callback.
225 RunNativeFinalizerCallback(native_finalizer, current_entry, before_gc_space,
226 visitor);
227
228 // Fall-through sending a message to clear the entries and remove
229 // from detachments.
230 }
231
232 FinalizerEntryPtr previous_head =
233 finalizer_dart->untag()->exchange_entries_collected(current_entry);
234 current_entry->untag()->set_next(previous_head);
235 const bool first_entry = previous_head.IsRawNull();
236
237 // If we're in the marker, we need to ensure that we release the store
238 // buffer afterwards.
239 // If we're in the scavenger and have the finalizer in old space and
240 // a new space entry, we don't need to release the store buffer.
241 if (!first_entry && previous_head->IsNewObject() &&
242 current_entry->IsOldObject()) {
243 TRACE_FINALIZER("Entry %p (old) next is %p (new)", current_entry->untag(),
244 previous_head->untag());
245 // We must release the thread's store buffer block.
246 }
247
248 // Schedule calling Dart finalizer.
249 if (first_entry) {
250 Isolate* isolate = finalizer->untag()->isolate_;
251 if (isolate == nullptr) {
252 TRACE_FINALIZER("Not scheduling finalizer %p callback on isolate null",
253 finalizer->untag());
254 } else {
255 TRACE_FINALIZER("Scheduling finalizer %p callback on isolate %p",
256 finalizer->untag(), isolate);
257
258 PersistentHandle* handle =
259 isolate->group()->api_state()->AllocatePersistentHandle();
260 handle->set_ptr(finalizer);
261 MessageHandler* message_handler = isolate->message_handler();
262 message_handler->PostMessage(
264 /*before_events*/ false);
265 }
266 }
267}
@ kNew
Definition: heap.h:38
@ kOld
Definition: heap.h:39
static std::unique_ptr< Message > New(Args &&... args)
Definition: message.h:72
@ kNormalPriority
Definition: message.h:28
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)
#define TRACE_FINALIZER(format,...)
Definition: gc_shared.h:96
Heap::Space SpaceForExternal(FinalizerEntryPtr raw_entry)
Definition: gc_shared.cc:42
void RunNativeFinalizerCallback(NativeFinalizerPtr raw_finalizer, FinalizerEntryPtr raw_entry, Heap::Space before_gc_space, GCVisitorType *visitor)
Definition: gc_shared.h:107
std::function< void(const T &message, const MessageReply< T > &reply)> MessageHandler
#define Pd
Definition: globals.h:408

◆ ObjectGraph

friend class ObjectGraph
friend

Definition at line 3655 of file raw_object.h.

◆ ScavengerVisitorBase

template<bool >
friend class ScavengerVisitorBase
friend

Definition at line 3654 of file raw_object.h.


The documentation for this class was generated from the following file: