Lines Matching refs:size
188 static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size) in alloc_chunk() argument
197 if (ftruncate(fd, size)) { in alloc_chunk()
202 retval = (struct chunk_header *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in alloc_chunk()
209 retval->executable = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); in alloc_chunk()
212 munmap((void *)retval, size); in alloc_chunk()
225 static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size) in alloc_chunk() argument
229 retval = (struct chunk_header *)mmap(NULL, size, in alloc_chunk()
236 retval->executable = mremap(retval, size, NULL, size, MAP_REMAPDUP); in alloc_chunk()
238 munmap((void *)retval, size); in alloc_chunk()
242 if (mprotect(retval->executable, size, PROT_READ | PROT_EXEC) == -1) { in alloc_chunk()
243 munmap(retval->executable, size); in alloc_chunk()
244 munmap((void *)retval, size); in alloc_chunk()
252 static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) in free_chunk() argument
256 munmap(header->executable, size); in free_chunk()
257 munmap((void *)header, size); in free_chunk()
267 sljit_uw size; member
276 sljit_uw size; member
284 #define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7) argument
290 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
292 free_block->header.size = 0; in sljit_insert_free_block()
293 free_block->size = size; in sljit_insert_free_block()
315 SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) in sljit_malloc_exec() argument
325 if (size < (64 - sizeof(struct block_header))) in sljit_malloc_exec()
326 size = (64 - sizeof(struct block_header)); in sljit_malloc_exec()
327 size = ALIGN_SIZE(size); in sljit_malloc_exec()
331 if (free_block->size >= size) { in sljit_malloc_exec()
332 chunk_size = free_block->size; in sljit_malloc_exec()
333 if (chunk_size > size + 64) { in sljit_malloc_exec()
335 chunk_size -= size; in sljit_malloc_exec()
336 free_block->size = chunk_size; in sljit_malloc_exec()
340 AS_BLOCK_HEADER(header, size)->prev_size = size; in sljit_malloc_exec()
345 size = chunk_size; in sljit_malloc_exec()
347 allocated_size += size; in sljit_malloc_exec()
348 header->size = size; in sljit_malloc_exec()
356 chunk_size = (chunk_size + size + CHUNK_SIZE - 1) & CHUNK_MASK; in sljit_malloc_exec()
373 if (chunk_size > size + 64) { in sljit_malloc_exec()
375 allocated_size += size; in sljit_malloc_exec()
376 header->size = size; in sljit_malloc_exec()
377 chunk_size -= size; in sljit_malloc_exec()
379 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
380 free_block->header.prev_size = size; in sljit_malloc_exec()
388 header->size = chunk_size; in sljit_malloc_exec()
391 next_header->size = 1; in sljit_malloc_exec()
406 allocated_size -= header->size; in sljit_free_exec()
413 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
414 free_block->size += header->size; in sljit_free_exec()
415 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
416 header->prev_size = free_block->size; in sljit_free_exec()
420 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
423 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
424 if (SLJIT_UNLIKELY(!header->size)) { in sljit_free_exec()
425 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
427 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
428 header->prev_size = free_block->size; in sljit_free_exec()
432 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
434 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
435 total_size -= free_block->size; in sljit_free_exec()
437 free_chunk(free_block, free_block->size + in sljit_free_exec()
457 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
458 total_size -= free_block->size; in sljit_free_unused_memory_exec()
460 free_chunk(free_block, free_block->size + in sljit_free_unused_memory_exec()