Clean up some duplication
parent
32bb531621
commit
670d0106d1
33
vm/code_gc.c
33
vm/code_gc.c
|
@ -256,30 +256,21 @@ void iterate_code_heap(CODE_HEAP_ITERATOR iter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_literal_references_step(F_REL *rel, F_COMPILED *compiled)
|
||||||
|
{
|
||||||
|
if(REL_TYPE(rel) == RT_IMMEDIATE)
|
||||||
|
{
|
||||||
|
CELL offset = rel->offset + (CELL)(compiled + 1);
|
||||||
|
F_ARRAY *literals = untag_object(compiled->literals);
|
||||||
|
F_FIXNUM absolute_value = array_nth(literals,REL_ARGUMENT(rel));
|
||||||
|
apply_relocation(REL_CLASS(rel),offset,absolute_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Update pointers to literals from compiled code. */
|
/* Update pointers to literals from compiled code. */
|
||||||
void update_literal_references(F_COMPILED *compiled)
|
void update_literal_references(F_COMPILED *compiled)
|
||||||
{
|
{
|
||||||
if(compiled->relocation != F)
|
iterate_relocations(compiled,update_literal_references_step);
|
||||||
{
|
|
||||||
F_ARRAY *literals = untag_object(compiled->literals);
|
|
||||||
F_BYTE_ARRAY *relocation = untag_object(compiled->relocation);
|
|
||||||
|
|
||||||
F_REL *rel = (F_REL *)(relocation + 1);
|
|
||||||
F_REL *rel_end = (F_REL *)((char *)rel + byte_array_capacity(relocation));
|
|
||||||
|
|
||||||
while(rel < rel_end)
|
|
||||||
{
|
|
||||||
if(REL_TYPE(rel) == RT_IMMEDIATE)
|
|
||||||
{
|
|
||||||
CELL offset = rel->offset + (CELL)(compiled + 1);
|
|
||||||
F_FIXNUM absolute_value = array_nth(literals,REL_ARGUMENT(rel));
|
|
||||||
apply_relocation(REL_CLASS(rel),offset,absolute_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
rel++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flush_icache_for(compiled);
|
flush_icache_for(compiled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,8 @@ void apply_relocation(CELL class, CELL offset, F_FIXNUM absolute_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform all fixups on a code block */
|
void iterate_relocations(F_COMPILED *compiled, RELOCATION_ITERATOR iter)
|
||||||
void relocate_code_block(F_COMPILED *compiled)
|
|
||||||
{
|
{
|
||||||
compiled->last_scan = NURSERY;
|
|
||||||
|
|
||||||
if(compiled->relocation != F)
|
if(compiled->relocation != F)
|
||||||
{
|
{
|
||||||
F_BYTE_ARRAY *relocation = untag_object(compiled->relocation);
|
F_BYTE_ARRAY *relocation = untag_object(compiled->relocation);
|
||||||
|
@ -154,16 +151,24 @@ void relocate_code_block(F_COMPILED *compiled)
|
||||||
|
|
||||||
while(rel < rel_end)
|
while(rel < rel_end)
|
||||||
{
|
{
|
||||||
CELL offset = rel->offset + (CELL)(compiled + 1);
|
iter(rel,compiled);
|
||||||
|
|
||||||
F_FIXNUM absolute_value = compute_code_rel(rel,compiled);
|
|
||||||
|
|
||||||
apply_relocation(REL_CLASS(rel),offset,absolute_value);
|
|
||||||
|
|
||||||
rel++;
|
rel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void relocate_code_block_step(F_REL *rel, F_COMPILED *compiled)
|
||||||
|
{
|
||||||
|
CELL offset = rel->offset + (CELL)(compiled + 1);
|
||||||
|
F_FIXNUM absolute_value = compute_code_rel(rel,compiled);
|
||||||
|
apply_relocation(REL_CLASS(rel),offset,absolute_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform all fixups on a code block */
|
||||||
|
void relocate_code_block(F_COMPILED *compiled)
|
||||||
|
{
|
||||||
|
compiled->last_scan = NURSERY;
|
||||||
|
iterate_relocations(compiled,relocate_code_block_step);
|
||||||
flush_icache_for(compiled);
|
flush_icache_for(compiled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,3 +79,7 @@ bool stack_traces_p(void);
|
||||||
void primitive_modify_code_heap(void);
|
void primitive_modify_code_heap(void);
|
||||||
|
|
||||||
void flush_icache_for(F_COMPILED *compiled);
|
void flush_icache_for(F_COMPILED *compiled);
|
||||||
|
|
||||||
|
typedef void (*RELOCATION_ITERATOR)(F_REL *rel, F_COMPILED *compiled);
|
||||||
|
|
||||||
|
void iterate_relocations(F_COMPILED *compiled, RELOCATION_ITERATOR iter);
|
||||||
|
|
Loading…
Reference in New Issue