Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::Zone Class Reference

#include <unit_test_custom_zone.h>

Classes

class  Segment
 

Public Member Functions

 Zone ()
 
 ~Zone ()
 
template<class ElementType >
ElementType * Alloc (intptr_t length)
 
template<class ElementType >
ElementType * Realloc (ElementType *old_array, intptr_t old_length, intptr_t new_length)
 
template<class ElementType >
void Free (ElementType *old_array, intptr_t len)
 
void * AllocUnsafe (intptr_t size)
 
template<class ElementType >
ElementType * Alloc (intptr_t len)
 
template<class ElementType >
ElementType * Realloc (ElementType *old_array, intptr_t old_len, intptr_t new_len)
 
uword AllocUnsafe (intptr_t size)
 
char * MakeCopyOfString (const char *str)
 
char * MakeCopyOfStringN (const char *str, intptr_t len)
 
char * ConcatStrings (const char *a, const char *b, char join=',')
 
char * PrintToString (const char *format,...) PRINTF_ATTRIBUTE(2
 
char char * VPrint (const char *format, va_list args)
 
uintptr_t SizeInBytes () const
 
uintptr_t CapacityInBytes () const
 
void Print () const
 
VMHandleshandles ()
 
void VisitObjectPointers (ObjectPointerVisitor *visitor)
 
Zoneprevious () const
 
bool ContainsNestedZone (Zone *other) const
 

Static Public Member Functions

static void Init ()
 
static void Cleanup ()
 
static void ClearCache ()
 
static intptr_t Size ()
 

Static Public Attributes

static constexpr intptr_t kAlignment = kDoubleSize
 

Friends

class StackZone
 
class ApiZone
 
class AllocOnlyStackZone
 
template<typename T , typename B , typename Allocator >
class BaseGrowableArray
 
template<typename T , typename B , typename Allocator >
class BaseDirectChainedHashMap
 

Detailed Description

Definition at line 19 of file unit_test_custom_zone.h.

Constructor & Destructor Documentation

◆ Zone()

dart::Zone::Zone ( )
inline

Definition at line 21 of file unit_test_custom_zone.h.

21{}

◆ ~Zone()

dart::Zone::~Zone ( )

Definition at line 22 of file unit_test_custom_zone.cc.

22 {
23 while (buffers_.size() > 0) {
24 free(buffers_.back());
25 buffers_.pop_back();
26 }
27}

Member Function Documentation

◆ Alloc() [1/2]

template<class ElementType >
ElementType * dart::Zone::Alloc ( intptr_t  len)
inline

◆ Alloc() [2/2]

template<class ElementType >
ElementType * dart::Zone::Alloc ( intptr_t  length)
inline

Definition at line 25 of file unit_test_custom_zone.h.

25 {
26 return static_cast<ElementType*>(AllocUnsafe(sizeof(ElementType) * length));
27 }
void * AllocUnsafe(intptr_t size)
size_t length

◆ AllocUnsafe() [1/2]

uword dart::Zone::AllocUnsafe ( intptr_t  size)
inline

Definition at line 29 of file unit_test_custom_zone.cc.

29 {
30 void* memory = malloc(size);
31 buffers_.push_back(memory);
32 return memory;
33}
void * malloc(size_t size)
Definition allocation.cc:19

◆ AllocUnsafe() [2/2]

uword dart::Zone::AllocUnsafe ( intptr_t  size)
inline

◆ CapacityInBytes()

uintptr_t dart::Zone::CapacityInBytes ( ) const

Definition at line 186 of file zone.cc.

186 {
187 uintptr_t size = kInitialChunkSize;
188 for (Segment* s = segments_; s != nullptr; s = s->next()) {
189 size += s->size();
190 }
191 return size;
192}
struct MyStruct s
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ Cleanup()

void dart::Zone::Cleanup ( )
static

Definition at line 63 of file zone.cc.

63 {
64 ClearCache();
66 segment_cache_mutex = nullptr;
67}
static void ClearCache()
Definition zone.cc:69
static Mutex * segment_cache_mutex
Definition zone.cc:54

◆ ClearCache()

void dart::Zone::ClearCache ( )
static

Definition at line 69 of file zone.cc.

69 {
70 MutexLocker ml(segment_cache_mutex);
73 while (segment_cache_size > 0) {
75 }
76}
#define ASSERT(E)
static intptr_t segment_cache_size
Definition zone.cc:56
static VirtualMemory * segment_cache[kSegmentCacheCapacity]
Definition zone.cc:55
static constexpr intptr_t kSegmentCacheCapacity
Definition zone.cc:53

◆ ConcatStrings()

char * dart::Zone::ConcatStrings ( const char *  a,
const char *  b,
char  join = ',' 
)

Definition at line 291 of file zone.cc.

291 {
292 intptr_t a_len = (a == nullptr) ? 0 : strlen(a);
293 const intptr_t b_len = strlen(b) + 1; // '\0'-terminated.
294 const intptr_t len = a_len + b_len;
295 char* copy = Alloc<char>(len);
296 if (a_len > 0) {
297 strncpy(copy, a, a_len);
298 // Insert join character.
299 copy[a_len++] = join;
300 }
301 strncpy(&copy[a_len], b, b_len);
302 return copy;
303}
static bool b
struct MyStruct a[10]
Definition copy.py:1
SINT Vec< 2 *N, T > join(const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:242

◆ ContainsNestedZone()

bool dart::Zone::ContainsNestedZone ( Zone other) const
inline

Definition at line 79 of file zone.h.

79 {
80 while (other != nullptr) {
81 if (this == other) return true;
82 other = other->previous_;
83 }
84 return false;
85 }

◆ Free()

template<class ElementType >
void dart::Zone::Free ( ElementType *  old_array,
intptr_t  len 
)
inline

Definition at line 39 of file unit_test_custom_zone.h.

39{}

◆ handles()

VMHandles * dart::Zone::handles ( )
inline

Definition at line 73 of file zone.h.

73{ return &handles_; }

◆ Init()

void dart::Zone::Init ( )
static

Definition at line 58 of file zone.cc.

58 {
59 ASSERT(segment_cache_mutex == nullptr);
60 segment_cache_mutex = new Mutex(NOT_IN_PRODUCT("segment_cache_mutex"));
61}
#define NOT_IN_PRODUCT(code)
Definition globals.h:84

◆ MakeCopyOfString()

char * dart::Zone::MakeCopyOfString ( const char *  str)

Definition at line 270 of file zone.cc.

270 {
271 intptr_t len = strlen(str) + 1; // '\0'-terminated.
272 char* copy = Alloc<char>(len);
273 strncpy(copy, str, len);
274 return copy;
275}

◆ MakeCopyOfStringN()

char * dart::Zone::MakeCopyOfStringN ( const char *  str,
intptr_t  len 
)

Definition at line 277 of file zone.cc.

277 {
278 ASSERT(len >= 0);
279 for (intptr_t i = 0; i < len; i++) {
280 if (str[i] == '\0') {
281 len = i;
282 break;
283 }
284 }
285 char* copy = Alloc<char>(len + 1); // +1 for '\0'
286 strncpy(copy, str, len);
287 copy[len] = '\0';
288 return copy;
289}

◆ previous()

Zone * dart::Zone::previous ( ) const
inline

Definition at line 77 of file zone.h.

77{ return previous_; }

◆ Print()

void dart::Zone::Print ( ) const

Definition at line 194 of file zone.cc.

194 {
195 intptr_t segment_size = CapacityInBytes();
196 intptr_t scoped_handle_size = handles_.ScopedHandlesCapacityInBytes();
197 intptr_t zone_handle_size = handles_.ZoneHandlesCapacityInBytes();
198 intptr_t total_size = segment_size + scoped_handle_size + zone_handle_size;
199 OS::PrintErr("Zone(%p, segments: %" Pd ", scoped_handles: %" Pd
200 ", zone_handles: %" Pd ", total: %" Pd ")\n",
201 this, segment_size, scoped_handle_size, zone_handle_size,
202 total_size);
203}
static size_t total_size(SkSBlockAllocator< N > &pool)
intptr_t ZoneHandlesCapacityInBytes() const
Definition handles.h:110
intptr_t ScopedHandlesCapacityInBytes() const
Definition handles.h:119
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
uintptr_t CapacityInBytes() const
Definition zone.cc:186
#define Pd
Definition globals.h:408

◆ PrintToString()

char * dart::Zone::PrintToString ( const char *  format,
  ... 
)

Definition at line 313 of file zone.cc.

313 {
314 va_list args;
316 char* buffer = OS::VSCreate(this, format, args);
317 va_end(args);
318 return buffer;
319}
static char static char * VSCreate(Zone *zone, const char *format, va_list args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static const uint8_t buffer[]
uint32_t uint32_t * format
va_start(args, format)
va_end(args)

◆ Realloc() [1/2]

template<class ElementType >
ElementType * dart::Zone::Realloc ( ElementType *  old_array,
intptr_t  old_len,
intptr_t  new_len 
)
inline

◆ Realloc() [2/2]

template<class ElementType >
ElementType * dart::Zone::Realloc ( ElementType *  old_array,
intptr_t  old_length,
intptr_t  new_length 
)
inline

Definition at line 30 of file unit_test_custom_zone.h.

32 {
33 void* memory = AllocUnsafe(sizeof(ElementType) * new_length);
34 memmove(memory, old_array, sizeof(ElementType) * old_length);
35 return static_cast<ElementType*>(memory);
36 }

◆ Size()

static intptr_t dart::Zone::Size ( )
inlinestatic

Definition at line 94 of file zone.h.

94{ return total_size_; }

◆ SizeInBytes()

uintptr_t dart::Zone::SizeInBytes ( ) const

Definition at line 182 of file zone.cc.

182 {
183 return size_;
184}

◆ VisitObjectPointers()

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

Definition at line 305 of file zone.cc.

305 {
306 Zone* zone = this;
307 while (zone != nullptr) {
308 zone->handles()->VisitObjectPointers(visitor);
309 zone = zone->previous_;
310 }
311}

◆ VPrint()

char * dart::Zone::VPrint ( const char *  format,
va_list  args 
)

Definition at line 321 of file zone.cc.

321 {
322 return OS::VSCreate(this, format, args);
323}

Friends And Related Symbol Documentation

◆ AllocOnlyStackZone

friend class AllocOnlyStackZone
friend

Definition at line 179 of file zone.h.

◆ ApiZone

friend class ApiZone
friend

Definition at line 178 of file zone.h.

◆ BaseDirectChainedHashMap

template<typename T , typename B , typename Allocator >
friend class BaseDirectChainedHashMap
friend

Definition at line 183 of file zone.h.

◆ BaseGrowableArray

template<typename T , typename B , typename Allocator >
friend class BaseGrowableArray
friend

Definition at line 181 of file zone.h.

◆ StackZone

friend class StackZone
friend

Definition at line 177 of file zone.h.

Member Data Documentation

◆ kAlignment

constexpr intptr_t dart::Zone::kAlignment = kDoubleSize
staticconstexpr

Definition at line 88 of file zone.h.


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