vm: initialize all_blocks map from image

um, code blocks from the image need to go in the set too
db4
Joe Groff 2011-11-17 17:13:18 -08:00
parent 2705fc67cb
commit 81911b9f87
4 changed files with 23 additions and 6 deletions

View File

@ -84,19 +84,34 @@ code_block *code_heap::code_block_for_address(cell address)
return found_block;
}
void code_heap::update_all_blocks_map(mark_bits<code_block> *code_forwarding_map)
struct all_blocks_set_inserter {
code_heap *code;
all_blocks_set_inserter(code_heap *code) : code(code) {}
void operator()(code_block *block, cell size)
{
code->all_blocks.insert(block);
}
};
void code_heap::initialize_all_blocks_set()
{
all_blocks.clear();
all_blocks_set_inserter inserter(this);
allocator->iterate(inserter);
}
void code_heap::update_all_blocks_set(mark_bits<code_block> *code_forwarding_map)
{
std::cout << "updating block map" << std::endl;
std::set<code_block *> new_all_blocks;
for (std::set<code_block *>::const_iterator oldi = all_blocks.begin();
oldi != all_blocks.end();
++oldi)
{
code_block *new_block = code_forwarding_map->forward_block(*oldi);
std::cout << "compact " << (void*)*oldi << " -> " << (void*)new_block << std::endl;
new_all_blocks.insert(new_block);
}
std::cout << "updated" << std::endl;
all_blocks.swap(new_all_blocks);
}

View File

@ -47,7 +47,8 @@ struct code_heap {
void flush_icache();
void guard_safepoint();
void unguard_safepoint();
void update_all_blocks_map(mark_bits<code_block> *code_forwarding_map);
void initialize_all_blocks_set();
void update_all_blocks_set(mark_bits<code_block> *code_forwarding_map);
code_block *code_block_for_address(cell address);

View File

@ -186,7 +186,7 @@ void factor_vm::update_code_roots_for_compaction()
root->valid = false;
}
code->update_all_blocks_map(state);
code->update_all_blocks_set(state);
}
/* Compact data and code heaps */

View File

@ -53,6 +53,7 @@ void factor_vm::load_code_heap(FILE *file, image_header *h, vm_parameters *p)
}
code->allocator->initial_free_list(h->code_size);
code->initialize_all_blocks_set();
}
struct startup_fixup {