Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
dart::Become Class Reference

#include <become.h>

Public Member Functions

 Become ()
 
 ~Become ()
 
void Add (const Object &before, const Object &after)
 
void Forward ()
 
void Exchange ()
 
void VisitObjectPointers (ObjectPointerVisitor *visitor)
 

Static Public Member Functions

static void MakeDummyObject (const Instance &instance)
 
static void FollowForwardingPointers (Thread *thread)
 

Detailed Description

Definition at line 96 of file become.h.

Constructor & Destructor Documentation

◆ Become()

dart::Become::Become ( )

Definition at line 221 of file become.cc.

221 {
222 IsolateGroup* group = Thread::Current()->isolate_group();
223 ASSERT(group->become() == nullptr); // Only one outstanding become at a time.
224 group->set_become(this);
225}
static Thread * Current()
Definition: thread.h:362
IsolateGroup * isolate_group() const
Definition: thread.h:541
#define ASSERT(E)

◆ ~Become()

dart::Become::~Become ( )

Definition at line 227 of file become.cc.

227 {
229}
void set_become(Become *become)
Definition: isolate.h:678

Member Function Documentation

◆ Add()

void dart::Become::Add ( const Object before,
const Object after 
)

Definition at line 231 of file become.cc.

231 {
232 pointers_.Add(before.ptr());
233 pointers_.Add(after.ptr());
234}

◆ Exchange()

void dart::Become::Exchange ( )
inline

Definition at line 103 of file become.h.

103{ UNIMPLEMENTED(); }
#define UNIMPLEMENTED

◆ FollowForwardingPointers()

void dart::Become::FollowForwardingPointers ( Thread thread)
static

Definition at line 330 of file become.cc.

330 {
331 // N.B.: We forward the heap before forwarding the stack. This limits the
332 // amount of following of forwarding pointers needed to get at stack maps.
333 auto isolate_group = thread->isolate_group();
334 Heap* heap = isolate_group->heap();
335
336 // Clear the store buffer; will be rebuilt as we forward the heap.
337 isolate_group->ReleaseStoreBuffers();
338 isolate_group->store_buffer()->Reset();
339
340 ForwardPointersVisitor pointer_visitor(thread);
341
342 {
343 // Heap pointers.
344 WritableCodeLiteralsScope writable_code(heap);
345 ForwardHeapPointersVisitor object_visitor(&pointer_visitor);
346 heap->VisitObjects(&object_visitor);
347 pointer_visitor.VisitingObject(nullptr);
348 }
349
350 // C++ pointers.
351 isolate_group->VisitObjectPointers(&pointer_visitor,
353#ifndef PRODUCT
354 isolate_group->ForEachIsolate(
355 [&](Isolate* isolate) {
356 ObjectIdRing* ring = isolate->object_id_ring();
357 if (ring != nullptr) {
358 ring->VisitPointers(&pointer_visitor);
359 }
360 },
361 /*at_safepoint=*/true);
362#endif // !PRODUCT
363
364 // Weak persistent handles.
365 ForwardHeapPointersHandleVisitor handle_visitor(thread);
366 isolate_group->VisitWeakPersistentHandles(&handle_visitor);
367}

◆ Forward()

void dart::Become::Forward ( )

Definition at line 275 of file become.cc.

275 {
276 if (pointers_.length() == 0) {
277 return;
278 }
279
280 Thread* thread = Thread::Current();
281 auto heap = thread->isolate_group()->heap();
282
283 TIMELINE_FUNCTION_GC_DURATION(thread, "Become::ElementsForwardIdentity");
284 HeapIterationScope his(thread);
285
286 // Setup forwarding pointers.
287 for (intptr_t i = 0; i < pointers_.length(); i += 2) {
288 ObjectPtr before = pointers_[i];
289 ObjectPtr after = pointers_[i + 1];
290
291 if (before == after) {
292 InvalidForwarding(before, after, "Cannot self-forward");
293 }
294 if (before->IsImmediateObject()) {
295 InvalidForwarding(before, after, "Cannot forward immediates");
296 }
297 if (after->IsImmediateObject()) {
298 InvalidForwarding(before, after, "Cannot target immediates");
299 }
300 if (before->untag()->InVMIsolateHeap()) {
301 InvalidForwarding(before, after, "Cannot forward VM heap objects");
302 }
303 if (before->IsForwardingCorpse() && !IsDummyObject(before)) {
304 InvalidForwarding(before, after, "Cannot forward to multiple targets");
305 }
306 if (after->IsForwardingCorpse()) {
307 // The Smalltalk become does allow this, and for very special cases
308 // it is important (shape changes to Class or Mixin), but as these
309 // cases do not arise in Dart, better to prohibit it.
310 InvalidForwarding(before, after, "No indirect chains of forwarding");
311 }
312
313 ForwardObjectTo(before, after);
314 heap->ForwardWeakEntries(before, after);
315#if defined(HASH_IN_OBJECT_HEADER)
316 Object::SetCachedHashIfNotSet(after, Object::GetCachedHash(before));
317#endif
318 }
319
321
322#if defined(DEBUG)
323 for (intptr_t i = 0; i < pointers_.length(); i += 2) {
324 ASSERT(pointers_[i] == pointers_[i + 1]);
325 }
326#endif
327 pointers_.Clear();
328}
static void FollowForwardingPointers(Thread *thread)
Definition: become.cc:330
DART_NOINLINE static DART_NORETURN void InvalidForwarding(ObjectPtr before, ObjectPtr after, const char *message)
Definition: become.cc:255
static void ForwardObjectTo(ObjectPtr before_obj, ObjectPtr after_obj)
Definition: become.cc:61
static bool IsDummyObject(ObjectPtr object)
Definition: become.cc:248
#define TIMELINE_FUNCTION_GC_DURATION(thread, name)
Definition: timeline.h:41

◆ MakeDummyObject()

void dart::Become::MakeDummyObject ( const Instance instance)
static

Definition at line 242 of file become.cc.

242 {
243 // Make the forward pointer point to itself.
244 // This is needed to distinguish it from a real forward object.
245 ForwardObjectTo(instance.ptr(), instance.ptr());
246}
VkInstance instance
Definition: main.cc:48

◆ VisitObjectPointers()

void dart::Become::VisitObjectPointers ( ObjectPointerVisitor visitor)

Definition at line 236 of file become.cc.

236 {
237 if (pointers_.length() != 0) {
238 visitor->VisitPointers(&pointers_[0], pointers_.length());
239 }
240}

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