Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr > Class Template Reference

#include <handles.h>

Public Member Functions

 Handles ()
 
 ~Handles ()
 
void VisitObjectPointers (ObjectPointerVisitor *visitor)
 
void VisitScopedHandles (ObjectPointerVisitor *visitor)
 
void VisitUnvisitedScopedHandles (ObjectPointerVisitor *visitor)
 
void Visit (HandleVisitor *visitor)
 
void Reset ()
 
uword AllocateScopedHandle ()
 
bool IsEmpty () const
 
intptr_t ZoneHandlesCapacityInBytes () const
 
intptr_t ScopedHandlesCapacityInBytes () const
 

Static Public Member Functions

static uword AllocateHandle (Zone *zone)
 
static uword AllocateZoneHandle (Zone *zone)
 

Protected Member Functions

int CountScopedHandles () const
 
int CountZoneHandles () const
 
bool IsValidScopedHandle (uword handle) const
 
bool IsValidZoneHandle (uword handle) const
 

Friends

class HandleScope
 
class Dart
 
class IsolateObjectStore
 
class ObjectStore
 
class ThreadState
 

Detailed Description

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
class dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >

Definition at line 54 of file handles.h.

Constructor & Destructor Documentation

◆ Handles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::Handles ( )
inline

Definition at line 56 of file handles.h.

57 : zone_blocks_(nullptr),
58 first_scoped_block_(nullptr),
59 scoped_blocks_(&first_scoped_block_) {}

◆ ~Handles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::~Handles ( )
inline

Definition at line 60 of file handles.h.

60{ DeleteAll(); }

Member Function Documentation

◆ AllocateHandle()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
uword dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::AllocateHandle ( Zone zone)
static

Definition at line 80 of file handles_impl.h.

81 {
82#if defined(DEBUG)
83 Thread* thread = Thread::Current();
84 ASSERT(thread->MayAllocateHandles());
85#endif // DEBUG
86 Handles* handles = zone->handles();
87 ASSERT(handles != nullptr);
88 return handles->AllocateScopedHandle();
89}
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)

◆ AllocateScopedHandle()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
uword dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::AllocateScopedHandle ( )
inline

Definition at line 96 of file handles.h.

96 {
97 if (scoped_blocks_->IsFull()) {
98 SetupNextScopeBlock();
99 }
100 return scoped_blocks_->AllocateHandle();
101 }

◆ AllocateZoneHandle()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
uword dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::AllocateZoneHandle ( Zone zone)
static

Definition at line 94 of file handles_impl.h.

95 {
96#if defined(DEBUG)
97 Thread* thread = Thread::Current();
98 ASSERT(zone->ContainsNestedZone(thread->zone()));
99 ASSERT(thread->MayAllocateHandles());
100#endif // DEBUG
101 Handles* handles = zone->handles();
102 ASSERT(handles != nullptr);
103 uword address = handles->AllocateHandleInZone();
104 return address;
105}
uintptr_t uword
Definition: globals.h:501

◆ CountScopedHandles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
int dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::CountScopedHandles
protected

Definition at line 211 of file handles_impl.h.

212 {
213 int count = 0;
214 const HandlesBlock* block = &first_scoped_block_;
215 do {
216 count += block->HandleCount();
217 if (block == scoped_blocks_) {
218 return count;
219 }
220 block = block->next_block();
221 } while (block != nullptr);
222 UNREACHABLE();
223 return 0;
224}
int count
Definition: FontMgrTest.cpp:50
#define UNREACHABLE()
Definition: assert.h:248

◆ CountZoneHandles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
int dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::CountZoneHandles
protected

Definition at line 227 of file handles_impl.h.

228 {
229 int count = 0;
230 const HandlesBlock* block = zone_blocks_;
231 while (block != nullptr) {
232 count += block->HandleCount();
233 block = block->next_block();
234 }
235 return count;
236}

◆ IsEmpty()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
bool dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::IsEmpty ( ) const
inline

Definition at line 103 of file handles.h.

103 {
104 if (zone_blocks_ != nullptr) return false;
105 if (first_scoped_block_.HandleCount() != 0) return false;
106 if (scoped_blocks_ != &first_scoped_block_) return false;
107 return true;
108 }

◆ IsValidScopedHandle()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
bool dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::IsValidScopedHandle ( uword  handle) const
protected

Definition at line 174 of file handles_impl.h.

175 {
176 const HandlesBlock* iterator = &first_scoped_block_;
177 while (iterator != nullptr) {
178 if (iterator->IsValidHandle(handle)) {
179 return true;
180 }
181 iterator = iterator->next_block();
182 }
183 return false;
184}

◆ IsValidZoneHandle()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
bool dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::IsValidZoneHandle ( uword  handle) const
protected

Definition at line 187 of file handles_impl.h.

188 {
189 const HandlesBlock* iterator = zone_blocks_;
190 while (iterator != nullptr) {
191 if (iterator->IsValidHandle(handle)) {
192 return true;
193 }
194 iterator = iterator->next_block();
195 }
196 return false;
197}

◆ Reset()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
void dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::Reset

Definition at line 61 of file handles_impl.h.

61 {
62 // Delete all the extra zone handle blocks allocated and reinit the first
63 // zone block.
64 if (zone_blocks_ != nullptr) {
65 DeleteHandleBlocks(zone_blocks_->next_block());
66 zone_blocks_->ReInit();
67 }
68
69 // Delete all the extra scoped handle blocks allocated and reinit the first
70 // scoped block.
71 DeleteHandleBlocks(first_scoped_block_.next_block());
72 first_scoped_block_.ReInit();
73 scoped_blocks_ = &first_scoped_block_;
74}

◆ ScopedHandlesCapacityInBytes()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
intptr_t dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::ScopedHandlesCapacityInBytes ( ) const
inline

Definition at line 119 of file handles.h.

119 {
120 intptr_t capacity = 0;
121 for (HandlesBlock* block = scoped_blocks_; block != nullptr;
122 block = block->next_block()) {
123 capacity += sizeof(*block);
124 }
125 return capacity;
126 }

◆ Visit()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
void dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::Visit ( HandleVisitor visitor)

Definition at line 43 of file handles_impl.h.

44 {
45 // Visit all zone handles.
46 HandlesBlock* block = zone_blocks_;
47 while (block != nullptr) {
48 block->Visit(visitor);
49 block = block->next_block();
50 }
51
52 // Visit all scoped handles.
53 block = &first_scoped_block_;
54 do {
55 block->Visit(visitor);
56 block = block->next_block();
57 } while (block != nullptr);
58}

◆ VisitObjectPointers()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
void dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::VisitObjectPointers ( ObjectPointerVisitor visitor)

Definition at line 15 of file handles_impl.h.

16 {
17 // Visit all zone handles.
18 HandlesBlock* block = zone_blocks_;
19 while (block != nullptr) {
20 block->VisitObjectPointers(visitor);
21 block = block->next_block();
22 }
23
24 // Visit all scoped handles.
25 VisitScopedHandles(visitor);
26}
void VisitScopedHandles(ObjectPointerVisitor *visitor)
Definition: handles_impl.h:30

◆ VisitScopedHandles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
void dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::VisitScopedHandles ( ObjectPointerVisitor visitor)

Definition at line 29 of file handles_impl.h.

30 {
31 HandlesBlock* block = &first_scoped_block_;
32 do {
33 block->VisitObjectPointers(visitor);
34 if (block == scoped_blocks_) {
35 return;
36 }
37 block = block->next_block();
38 } while (block != nullptr);
40}

◆ VisitUnvisitedScopedHandles()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
void dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::VisitUnvisitedScopedHandles ( ObjectPointerVisitor visitor)

◆ ZoneHandlesCapacityInBytes()

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
intptr_t dart::Handles< kHandleSizeInWords, kHandlesPerChunk, kOffsetOfRawPtr >::ZoneHandlesCapacityInBytes ( ) const
inline

Definition at line 110 of file handles.h.

110 {
111 intptr_t capacity = 0;
112 for (HandlesBlock* block = zone_blocks_; block != nullptr;
113 block = block->next_block()) {
114 capacity += sizeof(*block);
115 }
116 return capacity;
117 }

Friends And Related Function Documentation

◆ Dart

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
friend class Dart
friend

Definition at line 226 of file handles.h.

◆ HandleScope

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
friend class HandleScope
friend

Definition at line 225 of file handles.h.

◆ IsolateObjectStore

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
friend class IsolateObjectStore
friend

Definition at line 227 of file handles.h.

◆ ObjectStore

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
friend class ObjectStore
friend

Definition at line 228 of file handles.h.

◆ ThreadState

template<int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
friend class ThreadState
friend

Definition at line 229 of file handles.h.


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