VM: merge of fixup_data & fixup_code into a new method fixup_heaps

locals-and-roots
Björn Lindqvist 2016-04-23 01:07:25 +02:00
parent fb99c0ac84
commit 28b5378196
2 changed files with 4 additions and 13 deletions

View File

@ -67,7 +67,7 @@ struct startup_fixup {
cell size(code_block* compiled) { return compiled->size(*this); }
};
void factor_vm::fixup_data(cell data_offset, cell code_offset) {
void factor_vm::fixup_heaps(cell data_offset, cell code_offset) {
startup_fixup fixup(data_offset, code_offset);
slot_visitor<startup_fixup> visitor(this, fixup);
visitor.visit_all_roots();
@ -77,9 +77,7 @@ void factor_vm::fixup_data(cell data_offset, cell code_offset) {
visitor.visit_slots(obj);
switch (obj->type()) {
case ALIEN_TYPE: {
alien* ptr = (alien*)obj;
if (to_boolean(ptr->base))
ptr->update_address();
else
@ -97,12 +95,8 @@ void factor_vm::fixup_data(cell data_offset, cell code_offset) {
}
};
data->tenured->iterate(start_object_updater, fixup);
}
void factor_vm::fixup_code(cell data_offset, cell code_offset) {
startup_fixup fixup(data_offset, code_offset);
auto updater = [&](code_block* compiled, cell size) {
slot_visitor<startup_fixup> visitor(this, fixup);
visitor.visit_code_block_objects(compiled);
cell rel_base = compiled->entry_point() - fixup.code_offset;
visitor.visit_instruction_operands(compiled, rel_base);
@ -178,9 +172,7 @@ void factor_vm::load_image(vm_parameters* p) {
cell data_offset = data->tenured->start - h.data_relocation_base;
cell code_offset = code->allocator->start - h.code_relocation_base;
fixup_data(data_offset, code_offset);
fixup_code(data_offset, code_offset);
fixup_heaps(data_offset, code_offset);
/* Store image path name */
special_objects[OBJ_IMAGE] = allot_alien(false_object, (cell)p->image_path);

View File

@ -107,7 +107,7 @@ struct factor_vm {
/* Set if we're in the jit */
volatile fixnum current_jit_count;
/* Mark stack */
/* Mark stack used for mark & sweep GC */
std::vector<cell> mark_stack;
/* If not NULL, we push GC events here */
@ -604,8 +604,7 @@ struct factor_vm {
void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
bool save_image(const vm_char* saving_filename, const vm_char* filename);
void primitive_save_image();
void fixup_data(cell data_offset, cell code_offset);
void fixup_code(cell data_offset, cell code_offset);
void fixup_heaps(cell data_offset, cell code_offset);
FILE* open_image(vm_parameters* p);
void load_image(vm_parameters* p);
bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);