| jmp_buf throw_jmp_buf; |
jmp_buf throw_jmp_buf; |
| #endif |
#endif |
| |
|
| #if defined(DIRECT_THREADED) |
#if defined(DOUBLY_INDIRECT) |
| /*# define CA(n) (symbols[(n)])*/ |
# define CFA(n) ({Cell _n = (n); ((Cell)(((_n & 0x4000) ? symbols : xts)+(_n&~0x4000UL)));}) |
| # define CA(n) (symbols[(n)&~0x4000UL]) |
|
| #elif defined(DOUBLY_INDIRECT) |
|
| # define CA(n) ({Cell _n = (n); ((Cell)(((_n & 0x4000) ? symbols : xts)+(_n&~0x4000UL)));}) |
|
| #else |
#else |
| # define CA(n) ((Cell)(symbols+((n)&~0x4000UL))) |
# define CFA(n) ((Cell)(symbols+((n)&~0x4000UL))) |
| #endif |
#endif |
| |
|
| #define maxaligned(n) (typeof(n))((((Cell)n)+sizeof(Float)-1)&-sizeof(Float)) |
#define maxaligned(n) (typeof(n))((((Cell)n)+sizeof(Float)-1)&-sizeof(Float)) |
| MAKE_DOES_CF(image+i,(Xt *)(image[i+1]+((Cell)start))); |
MAKE_DOES_CF(image+i,(Xt *)(image[i+1]+((Cell)start))); |
| break; |
break; |
| default : |
default : |
| /* printf("Code field generation image[%x]:=CA(%x)\n", |
/* printf("Code field generation image[%x]:=CFA(%x)\n", |
| i, CF(image[i])); */ |
i, CF(image[i])); */ |
| if (CF((token | 0x4000))<max_symbols) { |
if (CF((token | 0x4000))<max_symbols) { |
| image[i]=(Cell)CA(CF(token)); |
image[i]=(Cell)CFA(CF(token)); |
| |
#ifdef DIRECT_THREADED |
| |
if ((token & 0x4000) == 0) /* threade code, no CFA */ |
| |
image[i] = *(Cell *)image[i]; |
| |
#endif |
| } else |
} else |
| fprintf(stderr,"Primitive %d used in this image at $%lx is not implemented by this\n engine (%s); executing this code will crash.\n",CF(token),(long)&image[i],VERSION); |
fprintf(stderr,"Primitive %d used in this image at $%lx is not implemented by this\n engine (%s); executing this code will crash.\n",CF(token),(long)&image[i],VERSION); |
| } |
} |
| return verbose_malloc(size); |
return verbose_malloc(size); |
| } |
} |
| |
|
| #if (defined(mips) && !defined(INDIRECT_THREADED)) |
|
| /* the 256MB jump restriction on the MIPS architecture makes the |
|
| combination of direct threading and mmap unsafe. */ |
|
| #define mips_dict_alloc 1 |
|
| #define dict_alloc(size) verbose_malloc(size) |
|
| #else |
|
| #define dict_alloc(size) my_alloc(size) |
|
| #endif |
|
| |
|
| Address dict_alloc_read(FILE *file, Cell imagesize, Cell dictsize, Cell offset) |
Address dict_alloc_read(FILE *file, Cell imagesize, Cell dictsize, Cell offset) |
| { |
{ |
| Address image = MAP_FAILED; |
Address image = MAP_FAILED; |
| |
|
| #if defined(HAVE_MMAP) && !defined(mips_dict_alloc) |
#if defined(HAVE_MMAP) |
| if (offset==0) { |
if (offset==0) { |
| image=alloc_mmap(dictsize); |
image=alloc_mmap(dictsize); |
| if (debug) |
if (debug) |
| image = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE, fileno(file), 0); |
image = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE, fileno(file), 0); |
| after_alloc(image,dictsize); |
after_alloc(image,dictsize); |
| } |
} |
| #endif /* defined(MAP_ANON) && !defined(mips_dict_alloc) */ |
#endif /* defined(HAVE_MMAP) */ |
| if (image == MAP_FAILED) { |
if (image == MAP_FAILED) { |
| image = dict_alloc(dictsize+offset)+offset; |
image = my_alloc(dictsize+offset)+offset; |
| rewind(file); /* fseek(imagefile,0L,SEEK_SET); */ |
rewind(file); /* fseek(imagefile,0L,SEEK_SET); */ |
| fread(image, 1, imagesize, file); |
fread(image, 1, imagesize, file); |
| } |
} |
| Address old_code_here=code_here; |
Address old_code_here=code_here; |
| static Address last_jump=0; |
static Address last_jump=0; |
| |
|
| |
prim = *(Xt)prim; |
| for (i=0; ; i++) { |
for (i=0; ; i++) { |
| if (i>=npriminfos) { /* not a relocatable prim */ |
if (i>=npriminfos) { /* not a relocatable prim */ |
| if (last_jump) { /* make sure the last sequence is complete */ |
if (last_jump) { /* make sure the last sequence is complete */ |
| last_jump = (priminfos[i].super_end) ? 0 : (prim+priminfos[i].length); |
last_jump = (priminfos[i].super_end) ? 0 : (prim+priminfos[i].length); |
| return (Label)old_code_here; |
return (Label)old_code_here; |
| #else |
#else |
| |
prim = *(Xt)prim; |
| return prim; |
return prim; |
| #endif |
#endif |
| #endif /* !defined(DOUBLY_INDIRECT) */ |
#endif /* !defined(DOUBLY_INDIRECT) */ |
| |
|
| alloc_stacks((ImageHeader *)imp); |
alloc_stacks((ImageHeader *)imp); |
| |
|
| CACHE_FLUSH(imp, header.image_size); |
/* unnecessary, except maybe for CODE words */ |
| |
/* FLUSH_ICACHE(imp, header.image_size);*/ |
| |
|
| return imp; |
return imp; |
| } |
} |
| #endif |
#endif |
| int retvalue; |
int retvalue; |
| |
|
| #if defined(i386) && defined(ALIGNMENT_CHECK) && !defined(DIRECT_THREADED) |
#if defined(i386) && defined(ALIGNMENT_CHECK) |
| /* turn on alignment checks on the 486. |
/* turn on alignment checks on the 486. |
| * on the 386 this should have no effect. */ |
* on the 386 this should have no effect. */ |
| __asm__("pushfl; popl %eax; orl $0x40000, %eax; pushl %eax; popfl;"); |
__asm__("pushfl; popl %eax; orl $0x40000, %eax; pushl %eax; popfl;"); |