Lines Matching refs:size
84 static SLJIT_INLINE void* alloc_chunk(sljit_uw size) in alloc_chunk() argument
86 return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); in alloc_chunk()
89 static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) in free_chunk() argument
91 SLJIT_UNUSED_ARG(size); in free_chunk()
166 static SLJIT_INLINE void* alloc_chunk(sljit_uw size) in alloc_chunk() argument
186 retval = mmap(NULL, size, prot, flags, fd, 0); in alloc_chunk()
192 if (mprotect(retval, size, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) { in alloc_chunk()
193 munmap(retval, size); in alloc_chunk()
198 SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0); in alloc_chunk()
203 static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) in free_chunk() argument
205 munmap(chunk, size); in free_chunk()
217 sljit_uw size; member
225 sljit_uw size; member
233 #define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7) argument
239 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
241 free_block->header.size = 0; in sljit_insert_free_block()
242 free_block->size = size; in sljit_insert_free_block()
264 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) in sljit_malloc_exec() argument
272 if (size < (64 - sizeof(struct block_header))) in sljit_malloc_exec()
273 size = (64 - sizeof(struct block_header)); in sljit_malloc_exec()
274 size = ALIGN_SIZE(size); in sljit_malloc_exec()
278 if (free_block->size >= size) { in sljit_malloc_exec()
279 chunk_size = free_block->size; in sljit_malloc_exec()
281 if (chunk_size > size + 64) { in sljit_malloc_exec()
283 chunk_size -= size; in sljit_malloc_exec()
284 free_block->size = chunk_size; in sljit_malloc_exec()
287 AS_BLOCK_HEADER(header, size)->prev_size = size; in sljit_malloc_exec()
292 size = chunk_size; in sljit_malloc_exec()
294 allocated_size += size; in sljit_malloc_exec()
295 header->size = size; in sljit_malloc_exec()
302 chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK; in sljit_malloc_exec()
313 if (chunk_size > size + 64) { in sljit_malloc_exec()
315 allocated_size += size; in sljit_malloc_exec()
316 header->size = size; in sljit_malloc_exec()
317 chunk_size -= size; in sljit_malloc_exec()
319 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
320 free_block->header.prev_size = size; in sljit_malloc_exec()
327 header->size = chunk_size; in sljit_malloc_exec()
330 next_header->size = 1; in sljit_malloc_exec()
343 allocated_size -= header->size; in sljit_free_exec()
351 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
352 free_block->size += header->size; in sljit_free_exec()
353 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
354 header->prev_size = free_block->size; in sljit_free_exec()
358 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
361 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
362 if (SLJIT_UNLIKELY(!header->size)) { in sljit_free_exec()
363 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
365 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
366 header->prev_size = free_block->size; in sljit_free_exec()
370 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
372 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
373 total_size -= free_block->size; in sljit_free_exec()
375 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_exec()
395 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
396 total_size -= free_block->size; in sljit_free_unused_memory_exec()
398 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_unused_memory_exec()