25 fEnd = fCursor = fDtorCursor =
nullptr;
28 if (fCursor !=
nullptr) {
35 RunDtorsOnBlock(fDtorCursor);
38void SkArenaAlloc::installFooter(FooterAction*
action, uint32_t padding) {
39 assert(SkTFitsIn<uint8_t>(padding));
41 this->installRaw((uint8_t)padding);
42 fDtorCursor = fCursor;
45char* SkArenaAlloc::SkipPod(
char* footerEnd) {
46 char* objEnd = footerEnd - (
sizeof(Footer) +
sizeof(uint32_t));
48 memmove(&
skip, objEnd,
sizeof(uint32_t));
49 return objEnd - (ptrdiff_t)
skip;
52void SkArenaAlloc::RunDtorsOnBlock(
char* footerEnd) {
53 while (footerEnd !=
nullptr) {
57 memcpy(&
action, footerEnd -
sizeof( Footer),
sizeof(
action));
58 memcpy(&padding, footerEnd -
sizeof(padding),
sizeof(padding));
60 footerEnd =
action(footerEnd) - (ptrdiff_t)padding;
64char* SkArenaAlloc::NextBlock(
char* footerEnd) {
65 char* objEnd = footerEnd - (
sizeof(
char*) +
sizeof(Footer));
67 memmove(&
next, objEnd,
sizeof(
char*));
68 RunDtorsOnBlock(
next);
73void SkArenaAlloc::ensureSpace(uint32_t
size, uint32_t alignment) {
74 constexpr uint32_t headerSize =
sizeof(Footer) +
sizeof(ptrdiff_t);
76 constexpr uint32_t overhead = headerSize +
sizeof(Footer);
77 AssertRelease(
size <= maxSize - overhead);
78 uint32_t objSizeAndOverhead =
size + overhead;
80 const uint32_t alignmentOverhead = alignment - 1;
81 AssertRelease(objSizeAndOverhead <= maxSize - alignmentOverhead);
82 objSizeAndOverhead += alignmentOverhead;
84 uint32_t minAllocationSize = fFibonacciProgression.
nextBlockSize();
85 uint32_t allocationSize =
std::max(objSizeAndOverhead, minAllocationSize);
90 uint32_t mask = allocationSize > (1 << 15) ? (1 << 12) - 1 : 16 - 1;
91 AssertRelease(allocationSize <= maxSize - mask);
92 allocationSize = (allocationSize + mask) & ~mask;
97 auto previousDtor = fDtorCursor;
99 fDtorCursor = newBlock;
100 fEnd = fCursor + allocationSize;
105 this->installRaw(previousDtor);
106 this->installFooter(NextBlock, 0);
109char* SkArenaAlloc::allocObjectWithFooter(uint32_t sizeIncludingFooter, uint32_t alignment) {
110 uintptr_t mask = alignment - 1;
113 uint32_t skipOverhead = 0;
114 const bool needsSkipFooter = fCursor != fDtorCursor;
115 if (needsSkipFooter) {
116 skipOverhead =
sizeof(Footer) +
sizeof(uint32_t);
118 const uint32_t totalSize = sizeIncludingFooter + skipOverhead;
122 this->ensureSpace(totalSize, alignment);
128 char* objStart = (
char*)((uintptr_t)(fCursor + skipOverhead + mask) & ~mask);
129 if ((ptrdiff_t)totalSize > fEnd - objStart) {
130 this->ensureSpace(totalSize, alignment);
134 AssertRelease((ptrdiff_t)totalSize <= fEnd - objStart);
138 if (needsSkipFooter) {
139 this->installRaw(
SkToU32(fCursor - fDtorCursor));
140 this->installFooter(SkipPod, 0);
148 size_t firstHeapAllocation)
152 , fFirstHeapAllocationSize{
SkToU32(firstHeapAllocation)} {}
155 char*
const firstBlock = fFirstBlock;
156 const uint32_t firstSize = fFirstSize;
157 const uint32_t firstHeapAllocationSize = fFirstHeapAllocationSize;
163 return this->
cursor() ==
nullptr ||
171 13, 21, 34, 55, 89, 144,
172 233, 377, 610, 987, 1597, 2584,
173 4181, 6765, 10946, 17711, 28657, 46368,
174 75025, 121393, 196418, 317811, 514229, 832040,
175 1346269, 2178309, 3524578, 5702887, 9227465, 14930352,
176 24157817, 39088169, 63245986, 102334155, 165580141, 267914296,
177 433494437, 701408733, 1134903170, 1836311903, 2971215073,
static float next(float f)
static void sk_asan_poison_memory_region(void const volatile *addr, size_t size)
std::array< const uint32_t, 47 > SkFibonacci47
static char * end_chain(char *)
static bool skip(SkStream *stream, size_t amount)
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
constexpr uint32_t SkToU32(S x)
SkArenaAllocWithReset(char *block, size_t blockSize, size_t firstHeapAllocation)
SkArenaAlloc(char *block, size_t blockSize, size_t firstHeapAllocation)
char *(char *) FooterAction
static float max(float r, float g, float b)
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