Fix O(n^2) icache flush
parent
2196f3721b
commit
003d7cc91b
|
@ -5,6 +5,7 @@
|
||||||
- code GC:
|
- code GC:
|
||||||
- discard the free block at the end of the code heap on save
|
- discard the free block at the end of the code heap on save
|
||||||
- minor GC takes too long now
|
- minor GC takes too long now
|
||||||
|
- icache slowdown
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,16 @@ void init_compiler(CELL size)
|
||||||
new_heap(&compiling,size);
|
new_heap(&compiling,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE void iterate_code_heap_step(F_COMPILED *compiled, CODE_HEAP_ITERATOR iter)
|
||||||
|
{
|
||||||
|
CELL code_start = (CELL)(compiled + 1);
|
||||||
|
CELL reloc_start = code_start + compiled->code_length;
|
||||||
|
CELL literal_start = reloc_start + compiled->reloc_length;
|
||||||
|
CELL words_start = literal_start + compiled->literal_length;
|
||||||
|
|
||||||
|
iter(compiled,code_start,reloc_start,literal_start,words_start);
|
||||||
|
}
|
||||||
|
|
||||||
void iterate_code_heap(CODE_HEAP_ITERATOR iter)
|
void iterate_code_heap(CODE_HEAP_ITERATOR iter)
|
||||||
{
|
{
|
||||||
F_BLOCK *scan = (F_BLOCK *)compiling.base;
|
F_BLOCK *scan = (F_BLOCK *)compiling.base;
|
||||||
|
@ -12,19 +22,7 @@ void iterate_code_heap(CODE_HEAP_ITERATOR iter)
|
||||||
while(scan)
|
while(scan)
|
||||||
{
|
{
|
||||||
if(scan->status != B_FREE)
|
if(scan->status != B_FREE)
|
||||||
{
|
iterate_code_heap_step((F_COMPILED *)(scan + 1),iter);
|
||||||
F_COMPILED *compiled = (F_COMPILED *)(scan + 1);
|
|
||||||
|
|
||||||
CELL code_start = (CELL)(compiled + 1);
|
|
||||||
CELL reloc_start = code_start + compiled->code_length;
|
|
||||||
CELL literal_start = reloc_start + compiled->reloc_length;
|
|
||||||
CELL words_start = literal_start + compiled->literal_length;
|
|
||||||
|
|
||||||
iter(compiled,
|
|
||||||
code_start,reloc_start,
|
|
||||||
literal_start,words_start);
|
|
||||||
}
|
|
||||||
|
|
||||||
scan = next_block(&compiling,scan);
|
scan = next_block(&compiling,scan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,8 +154,6 @@ void finalize_code_block(F_COMPILED *relocating, CELL code_start,
|
||||||
{
|
{
|
||||||
CELL words_end = words_start + relocating->words_length;
|
CELL words_end = words_start + relocating->words_length;
|
||||||
|
|
||||||
if(!relocating->finalized)
|
|
||||||
{
|
|
||||||
CELL scan;
|
CELL scan;
|
||||||
|
|
||||||
for(scan = words_start; scan < words_end; scan += CELLS)
|
for(scan = words_start; scan < words_end; scan += CELLS)
|
||||||
|
@ -167,7 +163,8 @@ void finalize_code_block(F_COMPILED *relocating, CELL code_start,
|
||||||
|
|
||||||
relocate_code_block(relocating,code_start,reloc_start,
|
relocate_code_block(relocating,code_start,reloc_start,
|
||||||
literal_start,words_start);
|
literal_start,words_start);
|
||||||
}
|
|
||||||
|
flush_icache(code_start,reloc_start - code_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_literals_step(F_COMPILED *relocating, CELL code_start,
|
void collect_literals_step(F_COMPILED *relocating, CELL code_start,
|
||||||
|
@ -278,6 +275,8 @@ void primitive_add_compiled_block(void)
|
||||||
void primitive_finalize_compile(void)
|
void primitive_finalize_compile(void)
|
||||||
{
|
{
|
||||||
F_ARRAY *array = untag_array(dpop());
|
F_ARRAY *array = untag_array(dpop());
|
||||||
|
|
||||||
|
/* set word XT's */
|
||||||
CELL count = untag_fixnum_fast(array->capacity);
|
CELL count = untag_fixnum_fast(array->capacity);
|
||||||
CELL i;
|
CELL i;
|
||||||
for(i = 0; i < count; i++)
|
for(i = 0; i < count; i++)
|
||||||
|
@ -287,8 +286,13 @@ void primitive_finalize_compile(void)
|
||||||
word->xt = to_cell(get(AREF(pair,1)));
|
word->xt = to_cell(get(AREF(pair,1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_code_heap(finalize_code_block);
|
/* perform relocation */
|
||||||
flush_icache(compiling.base,compiling.limit - compiling.base);
|
for(i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
F_ARRAY *pair = untag_array(get(AREF(array,i)));
|
||||||
|
CELL xt = to_cell(get(AREF(pair,1)));
|
||||||
|
iterate_code_heap_step((F_COMPILED*)xt - 1,finalize_code_block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void primitive_code_room(void)
|
void primitive_code_room(void)
|
||||||
|
|
|
@ -58,8 +58,6 @@ typedef struct {
|
||||||
|
|
||||||
void relocate_code_block(F_COMPILED *relocating, CELL code_start,
|
void relocate_code_block(F_COMPILED *relocating, CELL code_start,
|
||||||
CELL reloc_start, CELL literal_start, CELL words_start);
|
CELL reloc_start, CELL literal_start, CELL words_start);
|
||||||
void finalize_code_block(F_COMPILED *relocating, CELL code_start,
|
|
||||||
CELL reloc_start, CELL literal_start, CELL words_start);
|
|
||||||
void collect_literals(void);
|
void collect_literals(void);
|
||||||
void init_compiler(CELL size);
|
void init_compiler(CELL size);
|
||||||
void primitive_add_compiled_block(void);
|
void primitive_add_compiled_block(void);
|
||||||
|
|
Loading…
Reference in New Issue