1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-26 11:52:25 +00:00

Begin to modernize optimized dispatch. (#271)

This feature was controlled by the compilation flag `OPDISP`
which would enable some bits of assembler on the x86 (ISC or DOS)
or some other specialized code on SPARC. On SPARC hardware, there
was a special compilation process that would preprocess the code
and generate dispatch tables.

We do this now when this feature is enabled using gcc's computed
gotos feature. This is available in clang and some other compilers.
Notably, it isn't present in Visual Studio.

This doesn't decrease our portability at all as this feature is
optional and it replaces specialized assembler code with C using
compiler extensions (making it cross-platform).

In doing this, we've removed a bunch of related code, however,
it is likely that other pieces yet remain and will be removed
in subsequent commits as we clean things up and refine them.

This feature remains disabled by default for now.
This commit is contained in:
Bruce Mitchener
2021-01-23 03:28:16 +07:00
committed by GitHub
parent 61a0c02681
commit b7e9529322
18 changed files with 514 additions and 1607 deletions

View File

@@ -119,29 +119,6 @@
.end
.inline fast0_dispatcher,0
leal -1(%edi),%eax
xorb $3,%al
movzbl (%eax),%eax
jmp *optable(,%eax,4)
.end
.inline fast1_dispatcher,0
movl %edi,%eax
xorb $3,%al
movzbl (%eax),%eax
incl %edi
jmp *optable(,%eax,4)
.end
.inline fast2_dispatcher,0
leal 1(%edi),%eax
xorb $3,%al
addl $2,%edi
movzbl (%eax),%eax
jmp *optable(,%eax,4)
.end
.inline plus_err_label,0
plus_err:
.end

View File

@@ -78,59 +78,6 @@ done: ! else done;
.end
/* inline dispatching support */
/* Thanks to Russ Atkinson, December 29, 1987 */
/* To use in compiling XXX, cc -O2 XXX.c dispatch.il */
/* The qdisp* routines depend on pc being in %o0 and table being in %o1 */
.inline _qdisp0,8
! qdisp0 - %o0: pc, %o1: table
ldub [%o0+0],%o2 ! temp = *pc
sll %o2,2,%o2 ! temp = temp * 4
ld [%o2+%o1],%o2 ! temp = table[temp]
jmp %o2 ! dispatch
nop
.end
.inline _qdisp1,8
! qdisp1 - %o0: pc, %o1: table
ldub [%o0+1],%o2 ! temp = *pc
sll %o2,2,%o2 ! temp = temp * 4
ld [%o2+%o1],%o2 ! temp = table[temp]
jmp %o2 ! dispatch
add %o0,1,%o0 ! update the pc
.end
.inline _qdisp2,8
! qdisp2 - %o0: pc, %o1: table
ldub [%o0+2],%o2 ! temp = *pc
sll %o2,2,%o2 ! temp = temp * 4
ld [%o2+%o1],%o2 ! temp = table[temp]
jmp %o2 ! dispatch
add %o0,2,%o0 ! update the pc
.end
.inline _qdisp3,8
! qdisp3 - %o0: pc, %o1: table
ldub [%o0+3],%o2 ! temp = *pc
sll %o2,2,%o2 ! temp = temp * 4
ld [%o2+%o1],%o2 ! temp = table[temp]
jmp %o2 ! dispatch
add %o0,3,%o0 ! update the pc
.end
.inline _fast_dispatcher,8
! - %o0: table, %o1: pc
ldub [%o1+0],%o1 ! fetch inst byte
sll %o1,2,%o1
ld [%o1+%o0],%o1
jmp %o1 ! dispatch
nop
.end
/*
***************************************************************
Inline Assembly help for dispatcher.

View File

@@ -1,62 +0,0 @@
/* @(#) disphack.lex Version 1.5 (11/2/88). copyright envos & Fuji Xerox */
REG "%"[oilg][0-9]
LABEL L[0-9]+
COMPUTE "\tcall\t_compute_dispatch_table,0\n nop\n\tmov\t%o0,"
DISPATCH "\tmov\t"{REG}",%o0\n\tcall\t_fast_dispatcher,2\n\tnop\n"
HEXD 0x[0-3]
ADDX "\tadd\t"{REG}","{HEXD}","{REG}
LDUB "\tldub\t["{REG}"],"{REG}
LDUBm1 "\tldub\t["{REG}"+-0x1],%o1"
MOV "\tmov\t"{REG}",%o1"
%%
extern char *dispatch_label;
{COMPUTE} printf(" set %s,", dispatch_label);
{ADDX}\n{LDUBm1}\n{DISPATCH} {
if ( memcmp(yytext + 5, yytext + 13, 3)
|| memcmp(yytext + 5, yytext + 24, 3)) {REJECT};
printf(" ldub [%.3s+%.3s+-0x1],%%o1\n",yytext+5, yytext+9);
printf(" sll %%o1,2,%%o1\n");
printf(" ld [%%o1+%.3s],%%o1\n",yytext+43);
printf(" jmp %%o1\n");
printf("%.16s\n", yytext);
}
{DISPATCH} {
printf(" sll %%o1,2,%%o1\n");
printf(" ld [%%o1+%%%.2s],%%o1\n",yytext + 6);
printf(" jmp %%o1\n");
printf(" nop\n");
}
{ADDX}\n{LDUB} {
if ( !memcmp(yytext + 5, yytext + 13, 3)
&& !memcmp(yytext + 5, yytext + 24, 3)
&& memcmp(yytext + 5, yytext + 29, 3)) {
printf(" ldub [%.3s+%.3s],%.3s\n%.16s\n",
yytext+5,yytext+9,yytext+29,yytext);
} else
printf("%s", yytext);
}
{LDUB}\n\tcmp\t{REG}",255\n\tbgu\t"{LABEL}\n\t\sll\t{REG}",2,"{REG}\n\tset\t{LABEL}"," {
if (memcmp(yytext+yyleng-strlen(dispatch_label)-1,
dispatch_label,
strlen(dispatch_label))) {
fprintf(stderr, "Label in dispatch changed. Edit disphack.lex");
fprintf(stderr, " and change '%s' to label", dispatch_label);
fprintf(stderr, " in last line of \n\n%s\n\n and retry!\n", yytext);
exit(-1);
} else if (memcmp(yytext + 12, yytext + 21, 3)) {
fprintf(stderr, "Odd sequence %s\n", yytext);
};
REJECT;
};

View File

@@ -1,17 +0,0 @@
/* @(#) find-dispatch.lex Version 1.2 (4/7/89). copyright envos & Fuji Xerox */
REG "%"[oilg][0-9]
REGOFF "%"[oilg][0-9]\+\-0x[0-9]
LABEL L[0-9]+
LDUB "\tldub\t["{REG}"],"{REG}
LDUB2 "\tldub\t["{REGOFF}"],"{REG}
%%
{LDUB2}\n\tcmp\t{REG}",255\n\tbgu\t"{LABEL}\n\t\sll\t{REG}",2,"{REG}\n\tset\t { char x;
printf("char *dispatch_label = \"");
loop: x=input();
if(x == ','){ printf("\";\n"); return;}
output(x); goto loop;}
.*\n {}

1079
src/xc.c

File diff suppressed because it is too large Load Diff