Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::ObjectGraphCopier Class Reference
Inheritance diagram for dart::ObjectGraphCopier:
dart::StackResource

Public Member Functions

 ObjectGraphCopier (Thread *thread)
 
ObjectPtr CopyObjectGraph (const Object &root)
 
intptr_t allocated_bytes ()
 
intptr_t copied_objects ()
 
- Public Member Functions inherited from dart::StackResource
 StackResource (ThreadState *thread)
 
virtual ~StackResource ()
 
ThreadStatethread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::StackResource
static void Unwind (ThreadState *thread)
 
static void UnwindAbove (ThreadState *thread, StackResource *new_top)
 

Detailed Description

Definition at line 2420 of file object_graph_copy.cc.

Constructor & Destructor Documentation

◆ ObjectGraphCopier()

dart::ObjectGraphCopier::ObjectGraphCopier ( Thread thread)
inlineexplicit

Definition at line 2422 of file object_graph_copy.cc.

2424 thread_(thread),
2425 zone_(thread->zone()),
2426 map_(thread),
2427 fast_object_copy_(thread_, &map_),
2428 slow_object_copy_(thread_, &map_) {}
ThreadState * thread() const
Definition: allocation.h:33
StackResource(ThreadState *thread)
Definition: allocation.h:25
Zone * zone() const
Definition: thread_state.h:37

Member Function Documentation

◆ allocated_bytes()

intptr_t dart::ObjectGraphCopier::allocated_bytes ( )
inline

Definition at line 2485 of file object_graph_copy.cc.

2485{ return allocated_bytes_; }

◆ copied_objects()

intptr_t dart::ObjectGraphCopier::copied_objects ( )
inline

Definition at line 2487 of file object_graph_copy.cc.

2487{ return copied_objects_; }

◆ CopyObjectGraph()

ObjectPtr dart::ObjectGraphCopier::CopyObjectGraph ( const Object root)
inline

Definition at line 2436 of file object_graph_copy.cc.

2436 {
2437 const char* volatile exception_msg = nullptr;
2438 auto& result = Object::Handle(zone_);
2439
2440 {
2441 LongJumpScope jump; // e.g. for OOMs.
2442 if (setjmp(*jump.Set()) == 0) {
2443 result = CopyObjectGraphInternal(root, &exception_msg);
2444 // Any allocated external typed data must have finalizers attached so
2445 // memory will get free()ed.
2446 slow_object_copy_.slow_forward_map_.FinalizeExternalTypedData();
2447 } else {
2448 // Any allocated external typed data must have finalizers attached so
2449 // memory will get free()ed.
2450 slow_object_copy_.slow_forward_map_.FinalizeExternalTypedData();
2451
2452 // The copy failed due to non-application error (e.g. OOM error),
2453 // propagate this error.
2454 result = thread_->StealStickyError();
2455 RELEASE_ASSERT(result.IsError());
2456 }
2457 }
2458
2459 if (result.IsError()) {
2460 Exceptions::PropagateError(Error::Cast(result));
2461 UNREACHABLE();
2462 }
2463 ASSERT(result.IsArray());
2464 auto& result_array = Array::Cast(result);
2465 if (result_array.At(0) == Marker()) {
2466 ASSERT(exception_msg != nullptr);
2467 auto& unexpected_object_ = Object::Handle(zone_, result_array.At(1));
2468 if (!unexpected_object_.IsNull()) {
2469 exception_msg =
2470 OS::SCreate(zone_, "%s\n%s", exception_msg,
2472 zone_, thread_->isolate(), root, unexpected_object_,
2474 }
2475 ThrowException(exception_msg);
2476 UNREACHABLE();
2477 }
2478
2479 // The copy was successful, then detach transferable data from the sender
2480 // and attach to the copied graph.
2481 slow_object_copy_.slow_forward_map_.FinalizeTransferables();
2482 return result.ptr();
2483 }
#define UNREACHABLE()
Definition: assert.h:248
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
static DART_NORETURN void PropagateError(const Error &error)
Definition: exceptions.cc:1003
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
static Object & Handle()
Definition: object.h:407
DART_WARN_UNUSED_RESULT ErrorPtr StealStickyError()
Definition: thread.cc:245
Isolate * isolate() const
Definition: thread.h:534
#define ASSERT(E)
GAsyncResult * result
@ kInternalToIsolateGroup
const char * FindRetainingPath(Zone *zone_, Isolate *isolate, const Object &from, const Object &to, TraversalRules traversal_rules)
static DART_FORCE_INLINE ObjectPtr Marker()
string root
Definition: scale_cpu.py:20

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