示例#1
0
文件: compile.c 项目: Hmaal/slash
NODE(sl_node_interp_string_t, interp_string)
{
    size_t base_reg = reg_alloc_block(cs, node->components_count);
    for(size_t i = 0; i < node->components_count; i++) {
        compile_node(cs, node->components[i], base_reg + i);
    }
    op_build_string(cs, base_reg, node->components_count, dest);
    reg_free_block(cs, base_reg, node->components_count);
}
示例#2
0
void seg_pool::malloc_block()
{
    if(!_empty_blocks.empty()){
       pool_block* ba=get_block(_empty_blocks.next());
       ba->erase_from_list();
       reg_free_block(ba);
    }
    else{
        size_t new_size=_total_block_size;
        if(new_size < _min_block_size)
            new_size = _min_block_size;
        else if(new_size > block_size_max)
            new_size = block_size_max;
        size_t new_size1 = new_size-get_heap_header_size();
        void* newblock=mmalloc(new_size1);
        pool_block* ba=new (newblock) pool_block(_chunk_size, new_size1, this);
        if(ba){
            reg_free_block(ba);
            _total_block_size+=new_size;
        }
    }
}
示例#3
0
void seg_pool::free_chunk(chunk_header* ch)
{
    pool_block* ba=ch->parent;
    // ASSERT ba->parent()==this
    bool f=ba->full();
    ba->free_chunk(ch);
    if(ba->empty()){
        ba->erase_from_list();
        reg_empty_block(ba);
    }
    else if(f){
        ba->erase_from_list();
        reg_free_block(ba);
    }
}