rm *.o
export CC=gcc34
-export CFLAGS="-pedantic -Wall -Winline -O4 -Os -march=pentium4 -fomit-frame-pointer -falign-functions=8"
+export CFLAGS="-pedantic -Wall -Winline -O3 -march=pentium4 -fomit-frame-pointer"
$CC $CFLAGS -o f native/*.c
: cons-tag BIN: 010 ;
: object-tag BIN: 011 ;
: header-tag BIN: 100 ;
-: xt-tag BIN: 101 ;
: immediate ( x tag -- tagged ) swap tag-bits shift< bitor ;
: >header ( id -- tagged ) header-tag immediate ;
( Words )
-: word, ( -- pointer ) word-tag here-as xt-tag emit ;
+: word, ( -- pointer )
+ word-tag here-as word-tag >header emit 0 emit ;
! This is to handle mutually recursive words
! It is a hack. A recursive word in the cdr of a
r> ( -- plist )
r> ( primitive -- ) emit
r> ( parameter -- ) emit
- ( plist -- ) emit ;
+ ( plist -- ) emit
+ 0 emit ( padding ) ;
: primitive, ( word primitive -- ) f (worddef,) ;
: compound, ( word definition -- ) 1 swap (worddef,) ;
switch(untag_header(get(scan)))
{
+ case WORD_TYPE:
+ collect_word((WORD*)scan);
+ break;
case ARRAY_TYPE:
collect_array((ARRAY*)scan);
break;
gc_debug("collect_next header",get(scan));
switch(TAG(get(scan)))
{
- case XT_TYPE:
- collect_word((WORD*)scan);
- scan += sizeof(WORD);
- break;
case HEADER_TYPE:
collect_object();
break;
CELL primitive_to_xt(CELL primitive)
{
- XT xt;
-
if(primitive < 0 || primitive >= PRIMITIVE_COUNT)
general_error(ERROR_BAD_PRIMITIVE,tag_fixnum(primitive));
- xt = primitives[primitive];
- if((CELL)xt % 8 != 0)
- fatal_error("compile with -falign-functions=8",xt);
-
- return RETAG(xt,XT_TYPE);
+ return primitives[primitive];
}
void primitive_eq(void)
size = untagged_object_size(relocating);
switch(untag_header(get(relocating)))
{
+ case WORD_TYPE:
+ fixup_word((WORD*)relocating);
+ break;
case ARRAY_TYPE:
fixup_array((ARRAY*)relocating);
break;
{
switch(TAG(get(relocating)))
{
- case XT_TYPE:
- fixup_word((WORD*)relocating);
- relocating += sizeof(WORD);
- break;
case HEADER_TYPE:
relocate_object();
break;
void init_environment(void)
{
- /* + CELLS * 2 to skip header and length cell */
env.ds_bot = tag_object(array(STACK_SIZE,empty));
reset_datastack();
env.cs_bot = tag_object(array(STACK_SIZE,empty));
env.cf = env.boot;
}
-#define EXECUTE(w) ((XT)(UNTAG(w->xt)))()
+#define EXECUTE(w) ((XT)(w->xt))()
void run(void)
{
switch(untag_header(get(pointer)))
{
+ case WORD_TYPE:
+ return align8(sizeof(WORD));
case F_TYPE:
case T_TYPE:
case EMPTY_TYPE:
#define CONS_TYPE 2
#define OBJECT_TYPE 3
#define HEADER_TYPE 4
-#define XT_TYPE 5
-#define GC_COLLECTED 6 /* See gc.c */
+#define GC_COLLECTED 5 /* See gc.c */
/*** Header types ***/
typedef void (*XT)(void);
typedef struct {
- /* TAGGED execution token: jump here to execute word */
+ /* TAGGED header */
+ CELL header;
+ /* untagged execution token: jump here to execute word */
CELL xt;
- /* on-disk primitive number */
+ /* untagged on-disk primitive number */
CELL primitive;
/* TAGGED parameter to xt; used for colon definitions */
CELL parameter;