Converted some callback fns to use member-fn pointers

db4
Phil Dawes 2009-09-28 19:45:10 +01:00
parent 791d654f92
commit b6718641dc
11 changed files with 16 additions and 31 deletions

View File

@ -199,7 +199,7 @@ void factor_vm::iterate_relocations(code_block *compiled, relocation_iterator it
for(cell i = 0; i < length; i++)
{
relocation_entry rel = relocation->data<relocation_entry>()[i];
iter(rel,index,compiled,this);
(this->*iter)(rel,index,compiled);
index += number_of_parameters(relocation_type_of(rel));
}
}
@ -290,7 +290,7 @@ void factor_vm::update_literal_references(code_block *compiled)
{
if(!compiled->needs_fixup)
{
iterate_relocations(compiled,factor::update_literal_references_step);
iterate_relocations(compiled,&factor_vm::update_literal_references_step);
flush_icache_for(compiled);
}
}
@ -320,11 +320,6 @@ void factor_vm::copy_literal_references(code_block *compiled)
}
}
void copy_literal_references(code_block *compiled, factor_vm *myvm)
{
return myvm->copy_literal_references(compiled);
}
/* Compute an address to store at a relocation */
void factor_vm::relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled)
{
@ -374,7 +369,7 @@ void factor_vm::update_word_references(code_block *compiled)
code->heap_free(compiled);
else
{
iterate_relocations(compiled,factor::update_word_references_step);
iterate_relocations(compiled,&factor_vm::update_word_references_step);
flush_icache_for(compiled);
}
}
@ -473,7 +468,7 @@ void factor_vm::relocate_code_block(code_block *compiled)
{
compiled->last_scan = data->nursery();
compiled->needs_fixup = false;
iterate_relocations(compiled,factor::relocate_code_block_step);
iterate_relocations(compiled,&factor_vm::relocate_code_block_step);
flush_icache_for(compiled);
}

View File

@ -62,14 +62,4 @@ static const cell rel_relative_arm_3_mask = 0xffffff;
/* code relocation table consists of a table of entries for each fixup */
typedef u32 relocation_entry;
struct factor_vm;
typedef void (*relocation_iterator)(relocation_entry rel, cell index, code_block *compiled, factor_vm *vm);
// callback functions
void relocate_code_block(code_block *compiled, factor_vm *myvm);
void copy_literal_references(code_block *compiled, factor_vm *myvm);
void update_word_references(code_block *compiled, factor_vm *myvm);
void update_literal_and_word_references(code_block *compiled, factor_vm *myvm);
}

View File

@ -36,7 +36,7 @@ void factor_vm::iterate_code_heap(code_heap_iterator iter)
while(scan)
{
if(scan->status != B_FREE)
iter((code_block *)scan,this);
(this->*iter)((code_block *)scan);
scan = code->next_block(scan);
}
}
@ -45,14 +45,14 @@ void factor_vm::iterate_code_heap(code_heap_iterator iter)
aging and nursery collections */
void factor_vm::copy_code_heap_roots()
{
iterate_code_heap(factor::copy_literal_references);
iterate_code_heap(&factor_vm::copy_literal_references);
}
/* Update pointers to words referenced from all code blocks. Only after
defining a new word. */
void factor_vm::update_code_heap_words()
{
iterate_code_heap(factor::update_word_references);
iterate_code_heap(&factor_vm::update_word_references);
}
void factor_vm::primitive_modify_code_heap()

View File

@ -1,7 +1,4 @@
namespace factor
{
struct factor_vm;
typedef void (*code_heap_iterator)(code_block *compiled, factor_vm *myvm);
}

View File

@ -546,7 +546,7 @@ void factor_vm::garbage_collection(cell gen,bool growing_data_heap_,cell request
code_heap_scans++;
if(collecting_gen == data->tenured())
code->free_unmarked((heap_iterator)factor::update_literal_and_word_references);
code->free_unmarked((heap_iterator)&factor_vm::update_literal_and_word_references);
else
copy_code_heap_roots();

View File

@ -244,7 +244,7 @@ void heap::free_unmarked(heap_iterator iter)
add_to_free_list((free_heap_block *)prev);
scan->status = B_ALLOCATED;
prev = scan;
iter(scan,myvm);
(myvm->*iter)(scan);
break;
default:
myvm->critical_error("Invalid scan->status",(cell)scan);

View File

@ -9,7 +9,7 @@ struct heap_free_list {
free_heap_block *large_blocks;
};
typedef void (*heap_iterator)(heap_block *compiled, factor_vm *vm);
typedef void (factor_vm::*heap_iterator)(heap_block *compiled);
struct heap {
factor_vm *myvm;

View File

@ -303,7 +303,7 @@ void fixup_code_block(code_block *compiled, factor_vm *myvm)
void factor_vm::relocate_code()
{
iterate_code_heap(factor::fixup_code_block);
iterate_code_heap(&factor_vm::fixup_code_block);
}
/* Read an image file from disk, only done once during startup */

View File

@ -44,7 +44,7 @@ void factor_vm::set_profiling(bool profiling)
}
/* Update XTs in code heap */
iterate_code_heap(factor::relocate_code_block);
iterate_code_heap(&factor_vm::relocate_code_block);
}
void factor_vm::primitive_profiling()

View File

@ -330,7 +330,7 @@ void factor_vm::compile_all_words()
}
iterate_code_heap(factor::relocate_code_block);
iterate_code_heap(&factor_vm::relocate_code_block);
}
/* Allocates memory */

View File

@ -484,6 +484,8 @@ struct factor_vm
void primitive_fclose();
//code_block
typedef void (factor_vm::*relocation_iterator)(relocation_entry rel, cell index, code_block *compiled);
relocation_type relocation_type_of(relocation_entry r);
relocation_class relocation_class_of(relocation_entry r);
cell relocation_offset_of(relocation_entry r);
@ -524,6 +526,7 @@ struct factor_vm
//code_heap
heap *code;
unordered_map<heap_block *, char *> forwarding;
typedef void (factor_vm::*code_heap_iterator)(code_block *compiled);
void init_code_heap(cell size);
bool in_code_heap_p(cell ptr);