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()
97 static SLJIT_INLINE void* alloc_chunk(sljit_uw size) in alloc_chunk() argument
102 retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); in alloc_chunk()
108 retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0); in alloc_chunk()
114 static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) in free_chunk() argument
116 munmap(chunk, size); in free_chunk()
128 sljit_uw size; member
136 sljit_uw size; member
144 #define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7) argument
150 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
152 free_block->header.size = 0; in sljit_insert_free_block()
153 free_block->size = size; in sljit_insert_free_block()
175 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) in sljit_malloc_exec() argument
183 if (size < (64 - sizeof(struct block_header))) in sljit_malloc_exec()
184 size = (64 - sizeof(struct block_header)); in sljit_malloc_exec()
185 size = ALIGN_SIZE(size); in sljit_malloc_exec()
189 if (free_block->size >= size) { in sljit_malloc_exec()
190 chunk_size = free_block->size; in sljit_malloc_exec()
191 if (chunk_size > size + 64) { in sljit_malloc_exec()
193 chunk_size -= size; in sljit_malloc_exec()
194 free_block->size = chunk_size; in sljit_malloc_exec()
197 AS_BLOCK_HEADER(header, size)->prev_size = size; in sljit_malloc_exec()
202 size = chunk_size; in sljit_malloc_exec()
204 allocated_size += size; in sljit_malloc_exec()
205 header->size = size; in sljit_malloc_exec()
212 chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK; in sljit_malloc_exec()
223 if (chunk_size > size + 64) { in sljit_malloc_exec()
225 allocated_size += size; in sljit_malloc_exec()
226 header->size = size; in sljit_malloc_exec()
227 chunk_size -= size; in sljit_malloc_exec()
229 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
230 free_block->header.prev_size = size; in sljit_malloc_exec()
237 header->size = chunk_size; in sljit_malloc_exec()
240 next_header->size = 1; in sljit_malloc_exec()
253 allocated_size -= header->size; in sljit_free_exec()
260 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
261 free_block->size += header->size; in sljit_free_exec()
262 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
263 header->prev_size = free_block->size; in sljit_free_exec()
267 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
270 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
271 if (SLJIT_UNLIKELY(!header->size)) { in sljit_free_exec()
272 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
274 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
275 header->prev_size = free_block->size; in sljit_free_exec()
279 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
281 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
282 total_size -= free_block->size; in sljit_free_exec()
284 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_exec()
302 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
303 total_size -= free_block->size; in sljit_free_unused_memory_exec()
305 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_unused_memory_exec()