Lines Matching refs:free_block
272 struct free_block { struct
274 struct free_block *next; argument
275 struct free_block *prev; argument
282 ((struct free_block*)(((sljit_u8*)base) + offset)) argument
286 static struct free_block* free_blocks;
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()
295 free_block->next = free_blocks; in sljit_insert_free_block()
296 free_block->prev = NULL; in sljit_insert_free_block()
298 free_blocks->prev = free_block; in sljit_insert_free_block()
299 free_blocks = free_block; in sljit_insert_free_block()
302 static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block) in sljit_remove_free_block() argument
304 if (free_block->next) in sljit_remove_free_block()
305 free_block->next->prev = free_block->prev; in sljit_remove_free_block()
307 if (free_block->prev) in sljit_remove_free_block()
308 free_block->prev->next = free_block->next; in sljit_remove_free_block()
310 SLJIT_ASSERT(free_blocks == free_block); in sljit_remove_free_block()
311 free_blocks = free_block->next; in sljit_remove_free_block()
320 struct free_block *free_block; in sljit_malloc_exec() local
329 free_block = free_blocks; in sljit_malloc_exec()
330 while (free_block) { in sljit_malloc_exec()
331 if (free_block->size >= size) { in sljit_malloc_exec()
332 chunk_size = free_block->size; in sljit_malloc_exec()
336 free_block->size = chunk_size; in sljit_malloc_exec()
337 header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
339 header->executable_offset = free_block->header.executable_offset; in sljit_malloc_exec()
343 sljit_remove_free_block(free_block); in sljit_malloc_exec()
344 header = (struct block_header*)free_block; in sljit_malloc_exec()
352 free_block = free_block->next; 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()
381 free_block->header.executable_offset = executable_offset; in sljit_malloc_exec()
382 sljit_insert_free_block(free_block, chunk_size); in sljit_malloc_exec()
383 next_header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
401 struct free_block* free_block; in sljit_free_exec() local
412 free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_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()
419 free_block = (struct free_block*)header; 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()
425 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
426 sljit_remove_free_block((struct free_block*)header); 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()
436 sljit_remove_free_block(free_block); in sljit_free_exec()
437 free_chunk(free_block, free_block->size + in sljit_free_exec()
448 struct free_block* free_block; in sljit_free_unused_memory_exec() local
449 struct free_block* next_free_block; in sljit_free_unused_memory_exec()
453 free_block = free_blocks; in sljit_free_unused_memory_exec()
454 while (free_block) { in sljit_free_unused_memory_exec()
455 next_free_block = free_block->next; in sljit_free_unused_memory_exec()
456 if (!free_block->header.prev_size && in sljit_free_unused_memory_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()
459 sljit_remove_free_block(free_block); in sljit_free_unused_memory_exec()
460 free_chunk(free_block, free_block->size + in sljit_free_unused_memory_exec()
464 free_block = next_free_block; in sljit_free_unused_memory_exec()