8#ifndef SkArenaAlloc_DEFINED
9#define SkArenaAlloc_DEFINED
32template<u
int32_t kMaxSize>
40 SkFibBlockSizes(uint32_t staticBlockSize, uint32_t firstAllocationSize) : fIndex{0} {
41 fBlockUnitSize = firstAllocationSize > 0 ? firstAllocationSize :
42 staticBlockSize > 0 ? staticBlockSize : 1024;
62 uint32_t fBlockUnitSize : 26;
107 SkArenaAlloc(
char* block,
size_t blockSize,
size_t firstHeapAllocation);
119 template <
typename Ctor>
120 auto make(Ctor&& ctor) ->
decltype(ctor(
nullptr)) {
121 using T = std::remove_pointer_t<
decltype(ctor(
nullptr))>;
124 uint32_t alignment =
SkToU32(
alignof(
T));
127 objStart = this->allocObject(
size, alignment);
128 fCursor = objStart +
size;
131 objStart = this->allocObjectWithFooter(
size +
sizeof(
Footer), alignment);
133 uint32_t padding =
SkToU32(objStart - fCursor);
136 fCursor = objStart +
size;
139 char* objStart = objEnd - (
sizeof(
T) +
sizeof(
Footer));
140 ((
T*)objStart)->~T();
143 this->installFooter(releaser, padding);
147 return ctor(objStart);
150 template <
typename T,
typename... Args>
152 return this->
make([&](
void* objStart) {
153 return new(objStart)
T(std::forward<Args>(
args)...);
157 template <
typename T>
164 return this->
make([&](
void* objStart) {
165 return new(objStart)
T();
170 template <
typename T>
172 T* array = this->allocUninitializedArray<T>(
count);
173 for (
size_t i = 0;
i <
count;
i++) {
180 template <
typename T>
182 T* array = this->allocUninitializedArray<T>(
count);
183 for (
size_t i = 0;
i <
count;
i++) {
190 template <
typename T,
typename Initializer>
192 T* array = this->allocUninitializedArray<T>(
count);
193 for (
size_t i = 0;
i <
count;
i++) {
201 AssertRelease(SkTFitsIn<uint32_t>(
size));
203 fCursor = objStart +
size;
216 char*
end() {
return fEnd; }
219 static void AssertRelease(
bool cond) {
if (!cond) { ::abort(); } }
221 static char* SkipPod(
char* footerEnd);
222 static void RunDtorsOnBlock(
char* footerEnd);
223 static char* NextBlock(
char* footerEnd);
225 template <
typename T>
226 void installRaw(
const T& val) {
228 memcpy(fCursor, &val,
sizeof(val));
229 fCursor +=
sizeof(val);
231 void installFooter(
FooterAction* releaser, uint32_t padding);
233 void ensureSpace(uint32_t
size, uint32_t alignment);
235 char* allocObject(uint32_t
size, uint32_t alignment) {
236 uintptr_t mask = alignment - 1;
237 uintptr_t alignedOffset = (~reinterpret_cast<uintptr_t>(fCursor) + 1) & mask;
238 uintptr_t totalSize =
size + alignedOffset;
239 AssertRelease(totalSize >=
size);
240 if (totalSize >
static_cast<uintptr_t
>(fEnd - fCursor)) {
241 this->ensureSpace(
size, alignment);
242 alignedOffset = (~reinterpret_cast<uintptr_t>(fCursor) + 1) & mask;
245 char*
object = fCursor + alignedOffset;
247 SkASSERT((
reinterpret_cast<uintptr_t
>(
object) & (alignment - 1)) == 0);
253 char* allocObjectWithFooter(uint32_t sizeIncludingFooter, uint32_t alignment);
255 template <
typename T>
256 T* allocUninitializedArray(
size_t countZ) {
257 AssertRelease(SkTFitsIn<uint32_t>(countZ));
263 uint32_t alignment =
SkToU32(
alignof(
T));
266 objStart = this->allocObject(arraySize, alignment);
267 fCursor = objStart + arraySize;
270 constexpr uint32_t overhead =
sizeof(Footer) +
sizeof(uint32_t);
272 uint32_t totalSize = arraySize + overhead;
273 objStart = this->allocObjectWithFooter(totalSize, alignment);
276 uint32_t padding =
SkToU32(objStart - fCursor);
279 fCursor = objStart + arraySize;
283 [](
char* footerEnd) {
284 char* objEnd = footerEnd - (
sizeof(Footer) +
sizeof(uint32_t));
286 memmove(&
count, objEnd,
sizeof(uint32_t));
287 char* objStart = objEnd -
count *
sizeof(
T);
288 T* array = (
T*) objStart;
289 for (uint32_t
i = 0;
i <
count;
i++) {
321 char*
const fFirstBlock;
322 const uint32_t fFirstSize;
323 const uint32_t fFirstHeapAllocationSize;
331template <
size_t InlineStorageSize>
343template <
size_t InlineStorageSize>
static struct Initializer initializer
static void sk_asan_unpoison_memory_region(void const volatile *addr, size_t size)
std::array< const uint32_t, 47 > SkFibonacci47
#define SkASSERT_RELEASE(cond)
constexpr uint32_t SkToU32(S x)
SkArenaAllocWithReset(size_t firstHeapAllocation)
SkArenaAllocWithReset(char *block, size_t blockSize, size_t firstHeapAllocation)
void * makeBytesAlignedTo(size_t size, size_t align)
T * makeArrayDefault(size_t count)
SkArenaAlloc(size_t firstHeapAllocation)
SkArenaAlloc & operator=(SkArenaAlloc &&)=delete
T * makeInitializedArray(size_t count, Initializer initializer)
SkArenaAlloc(char *block, size_t blockSize, size_t firstHeapAllocation)
char *(char *) FooterAction
T * makeArray(size_t count)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
SkArenaAlloc & operator=(const SkArenaAlloc &)=delete
SkArenaAlloc(const SkArenaAlloc &)=delete
SkArenaAlloc(SkArenaAlloc &&)=delete
T * make(Args &&... args)
SkFibBlockSizes(uint32_t staticBlockSize, uint32_t firstAllocationSize)
~SkSTArenaAllocWithReset()
SkSTArenaAllocWithReset(size_t firstHeapAllocation=InlineStorageSize)
SkSTArenaAlloc(size_t firstHeapAllocation=InlineStorageSize)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static float max(float r, float g, float b)
static float min(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
std::shared_ptr< const fml::Mapping > data