src/runtime/alloc.c
// `size` should include a word for the header
`size` should include a word for the header
` size ` should include a word for the header
void* immix_alloc(uint64_t size, uint32_t* header, uint64_t* rsp, uint64_t* rbp) {
    while (true) {
        if (local_alloc.ptr && local_alloc.ptr - size >= local_alloc.end) {
            void* next_ptr = local_alloc.ptr - size;
            *(uint32_t**)next_ptr = header;
            local_alloc.ptr = next_ptr;
            if ((uint64_t)next_ptr & 1)
                panic("Unaligned pointer in immix_alloc()");
            return next_ptr;
        } else if (next_line()) {
            continue;
        } else if (next_block()) {
            continue;
        } else {
            push_extra_root(header);
            run_gc(rsp, rbp);
            header = pop_extra_root();
            continue;
        }
    }
}
void * immix_alloc ( uint64_t size , uint32_t * header , uint64_t * rsp , uint64_t * rbp ) { while ( true ) { if ( local_alloc . ptr && local_alloc . ptr - size >= local_alloc . end ) { void * next_ptr = local_alloc . ptr - size ; * ( uint32_t * * ) next_ptr = header ; local_alloc . ptr = next_ptr ; if ( ( uint64_t ) next_ptr & 1 ) panic ( " " ) ; return next_ptr ; } else if ( next_line ( ) ) { continue ; } else if ( next_block ( ) ) { continue ; } else { push_extra_root ( header ) ; run_gc ( rsp , rbp ) ; header = pop_extra_root ( ) ; continue ; } } }
`size` should include a word for the header
` size ` should include a word for the header
// printf("Calling immix_alloc of %ld bytes\n", size); // Try this line // Try this block // Request a new block // There's no more free space, run the GC! // But make sure it can see the RTTI pointer is live