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

Public Member Functions

 ProgramWalker (Zone *zone, Heap *heap, ClassVisitor *visitor)
 
 ~ProgramWalker ()
 
void AddToWorklist (const Object &object)
 
void VisitWorklist ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 80 of file program_visitor.cc.

Constructor & Destructor Documentation

◆ ProgramWalker()

dart::ProgramWalker::ProgramWalker ( Zone zone,
Heap heap,
ClassVisitor visitor 
)
inline

Definition at line 82 of file program_visitor.cc.

83 : heap_(heap),
84 visitor_(visitor),
85 worklist_(zone),
86 class_object_(Object::Handle(zone)),
87 class_fields_(Array::Handle(zone)),
88 class_field_(Field::Handle(zone)),
89 class_functions_(Array::Handle(zone)),
90 class_function_(Function::Handle(zone)),
91 class_code_(Code::Handle(zone)),
92 function_code_(Code::Handle(zone)),
93 static_calls_array_(Array::Handle(zone)),
94 static_calls_table_entry_(Object::Handle(zone)),
95 worklist_entry_(Object::Handle(zone)) {}
static Object & Handle()
Definition: object.h:407

◆ ~ProgramWalker()

dart::ProgramWalker::~ProgramWalker ( )
inline

Definition at line 97 of file program_visitor.cc.

97{ heap_->ResetObjectIdTable(); }
void ResetObjectIdTable()
Definition: heap.cc:899

Member Function Documentation

◆ AddToWorklist()

void dart::ProgramWalker::AddToWorklist ( const Object object)
inline

Definition at line 101 of file program_visitor.cc.

101 {
102 // We don't visit null, non-heap objects, or objects in the VM heap.
103 if (object.IsNull() || object.IsSmi() || object.InVMIsolateHeap()) return;
104 // Check and set visited, even if we don't end up adding this to the list.
105 if (heap_->GetObjectId(object.ptr()) != 0) return;
106 heap_->SetObjectId(object.ptr(), 1);
107 if (object.IsClass() ||
108 (object.IsFunction() && visitor_->IsFunctionVisitor()) ||
109 (object.IsCode() && visitor_->IsCodeVisitor())) {
110 worklist_.Add(object);
111 }
112 }
virtual bool IsCodeVisitor() const
virtual bool IsFunctionVisitor() const
intptr_t GetObjectId(ObjectPtr raw_obj) const
Definition: heap.h:197
void SetObjectId(ObjectPtr raw_obj, intptr_t object_id)
Definition: heap.h:193
void Add(const Object &value)
bool IsSmi(int64_t v)
Definition: runtime_api.cc:31
DART_EXPORT bool IsNull(Dart_Handle object)

◆ VisitWorklist()

void dart::ProgramWalker::VisitWorklist ( )
inline

Definition at line 114 of file program_visitor.cc.

114 {
115 while (!worklist_.IsEmpty()) {
116 worklist_entry_ = worklist_.Remove();
117 if (worklist_entry_.IsClass()) {
118 VisitClass(Class::Cast(worklist_entry_));
119 } else if (worklist_entry_.IsFunction()) {
120 VisitFunction(Function::Cast(worklist_entry_));
121 } else if (worklist_entry_.IsCode()) {
122 VisitCode(Code::Cast(worklist_entry_));
123 } else {
124 FATAL("Got unexpected object %s", worklist_entry_.ToCString());
125 }
126 }
127 }
virtual const char * ToCString() const
Definition: object.h:366
ObjectPtr Remove()
bool IsEmpty() const
#define FATAL(error)

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