factor/native/compiler.c

53 lines
1.1 KiB
C
Raw Normal View History

2004-09-06 02:32:04 -04:00
#include "factor.h"
2005-03-14 11:25:41 -05:00
void init_compiler(CELL size)
{
compiling.base = compiling.here = (CELL)(alloc_bounded_block(size)->start);
2005-05-10 22:30:58 -04:00
if(compiling.base == 0)
fatal_error("Cannot allocate code heap",size);
compiling.limit = compiling.base + size;
2005-03-14 11:25:41 -05:00
last_flush = compiling.base;
}
void primitive_compiled_offset(void)
2004-09-06 02:32:04 -04:00
{
box_unsigned_cell(compiling.here);
2004-09-06 02:32:04 -04:00
}
void primitive_set_compiled_offset(void)
{
CELL offset = unbox_unsigned_cell();
compiling.here = offset;
2006-02-08 22:12:20 -05:00
if(compiling.here > compiling.limit)
{
fprintf(stderr,"Code space exhausted\n");
factorbug();
}
}
void primitive_literal_top(void)
{
box_unsigned_cell(literal_top);
}
void primitive_set_literal_top(void)
{
CELL offset = unbox_unsigned_cell();
2004-12-25 02:55:03 -05:00
if(offset >= literal_max)
critical_error("Too many compiled literals",offset);
literal_top = offset;
}
2005-03-14 11:25:41 -05:00
void primitive_flush_icache(void)
{
flush_icache((void*)last_flush,compiling.here - last_flush);
last_flush = compiling.here;
}
void collect_literals(void)
{
2004-12-24 02:52:02 -05:00
CELL i;
for(i = compiling.base; i < literal_top; i += CELLS)
2005-02-19 23:25:21 -05:00
copy_handle((CELL*)i);
}