Non-optimizing compiler doesn't need to optimize 'dispatch' primitive anymore since its rarely used

db4
Slava Pestov 2009-04-30 19:42:08 -05:00
parent 7be231f6f8
commit 742d574162
5 changed files with 9 additions and 82 deletions

View File

@ -144,8 +144,6 @@ SYMBOL: jit-push-immediate
SYMBOL: jit-if-word
SYMBOL: jit-if-1
SYMBOL: jit-if-2
SYMBOL: jit-dispatch-word
SYMBOL: jit-dispatch
SYMBOL: jit-dip-word
SYMBOL: jit-dip
SYMBOL: jit-2dip-word
@ -158,7 +156,6 @@ SYMBOL: jit-execute-call
SYMBOL: jit-epilog
SYMBOL: jit-return
SYMBOL: jit-profiling
SYMBOL: jit-declare-word
SYMBOL: jit-save-stack
! PIC stubs
@ -192,13 +189,10 @@ SYMBOL: undefined-quot
{ jit-if-word 28 }
{ jit-if-1 29 }
{ jit-if-2 30 }
{ jit-dispatch-word 31 }
{ jit-dispatch 32 }
{ jit-epilog 33 }
{ jit-return 34 }
{ jit-profiling 35 }
{ jit-push-immediate 36 }
{ jit-declare-word 37 }
{ jit-save-stack 38 }
{ jit-dip-word 39 }
{ jit-dip 40 }
@ -524,9 +518,7 @@ M: quotation '
: emit-jit-data ( -- )
\ if jit-if-word set
\ dispatch jit-dispatch-word set
\ do-primitive jit-primitive-word set
\ declare jit-declare-word set
\ dip jit-dip-word set
\ 2dip jit-2dip-word set
\ 3dip jit-3dip-word set
@ -545,8 +537,6 @@ M: quotation '
jit-if-word
jit-if-1
jit-if-2
jit-dispatch-word
jit-dispatch
jit-dip-word
jit-dip
jit-2dip-word
@ -559,7 +549,6 @@ M: quotation '
jit-epilog
jit-return
jit-profiling
jit-declare-word
jit-save-stack
pic-load
pic-tag

View File

@ -74,21 +74,6 @@ CONSTANT: rs-reg 30
0 B rc-relative-ppc-3 rt-xt jit-rel
] jit-if-2 jit-define
: jit-jump-quot ( -- )
4 3 quot-xt-offset LWZ
4 MTCTR
BCTR ;
[
0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel
6 ds-reg 0 LWZ
6 6 1 SRAWI
3 3 6 ADD
3 3 array-start-offset LWZ
ds-reg dup 4 SUBI
jit-jump-quot
] jit-dispatch jit-define
: jit->r ( -- )
4 ds-reg 0 LWZ
ds-reg dup 4 SUBI
@ -167,7 +152,9 @@ CONSTANT: rs-reg 30
[
3 ds-reg 0 LWZ
ds-reg dup 4 SUBI
jit-jump-quot
4 3 quot-xt-offset LWZ
4 MTCTR
BCTR
] \ (call) define-sub-primitive
[

View File

@ -65,24 +65,6 @@ big-endian off
f JMP rc-relative rt-xt jit-rel
] jit-if-2 jit-define
[
! load dispatch table
temp1 0 MOV rc-absolute-cell rt-immediate jit-rel
! load index
temp0 ds-reg [] MOV
! turn it into an array offset
fixnum>slot@
! pop index
ds-reg bootstrap-cell SUB
! compute quotation location
temp0 temp1 ADD
! load quotation
arg temp0 array-start-offset [+] MOV
! execute branch. the quot must be in arg, since it might
! not be compiled yet
arg quot-xt-offset [+] JMP
] jit-dispatch jit-define
: jit->r ( -- )
rs-reg bootstrap-cell ADD
temp0 ds-reg [] MOV

View File

@ -53,13 +53,6 @@ static bool jit_fast_if_p(F_ARRAY *array, CELL i)
&& array_nth(array,i + 2) == userenv[JIT_IF_WORD];
}
static bool jit_fast_dispatch_p(F_ARRAY *array, CELL i)
{
return (i + 2) == array_capacity(array)
&& type_of(array_nth(array,i)) == ARRAY_TYPE
&& array_nth(array,i + 1) == userenv[JIT_DISPATCH_WORD];
}
static bool jit_fast_dip_p(F_ARRAY *array, CELL i)
{
return (i + 2) <= array_capacity(array)
@ -81,13 +74,6 @@ static bool jit_fast_3dip_p(F_ARRAY *array, CELL i)
&& array_nth(array,i + 1) == userenv[JIT_3DIP_WORD];
}
static bool jit_ignore_declare_p(F_ARRAY *array, CELL i)
{
return (i + 1) < array_capacity(array)
&& type_of(array_nth(array,i)) == ARRAY_TYPE
&& array_nth(array,i + 1) == userenv[JIT_DECLARE_WORD];
}
static bool jit_mega_lookup_p(F_ARRAY *array, CELL i)
{
return (i + 3) < array_capacity(array)
@ -108,7 +94,7 @@ static bool jit_stack_frame_p(F_ARRAY *array)
if(type_of(obj) == WORD_TYPE)
{
F_WORD *word = untag_object(obj);
if(word->subprimitive == F && obj != userenv[JIT_DECLARE_WORD])
if(word->subprimitive == F)
return true;
}
else if(type_of(obj) == QUOTATION_TYPE)
@ -190,6 +176,7 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
jit_push(jit,wrapper->object);
break;
case FIXNUM_TYPE:
/* Primitive calls */
if(jit_primitive_call_p(untag_object(array),i))
{
jit_emit(jit,userenv[JIT_SAVE_STACK]);
@ -201,7 +188,7 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
break;
}
case QUOTATION_TYPE:
/* if preceeded by two literal quotations (this is why if and ? are
/* 'if' preceeded by two literal quotations (this is why if and ? are
mutually recursive in the library, but both still work) */
if(jit_fast_if_p(untag_object(array),i))
{
@ -248,23 +235,8 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
break;
}
case ARRAY_TYPE:
/* Jump tables */
if(jit_fast_dispatch_p(untag_object(array),i))
{
TAIL_CALL;
jit_emit_with(jit,userenv[JIT_DISPATCH],obj);
i++;
break;
}
/* Non-optimizing compiler ignores declarations */
else if(jit_ignore_declare_p(untag_object(array),i))
{
i++;
break;
}
/* Method dispatch */
else if(jit_mega_lookup_p(untag_object(array),i))
if(jit_mega_lookup_p(untag_object(array),i))
{
jit_emit_mega_cache_lookup(jit,
array_nth(untag_object(array),i),

View File

@ -41,14 +41,11 @@ typedef enum {
JIT_IF_WORD,
JIT_IF_1,
JIT_IF_2,
JIT_DISPATCH_WORD,
JIT_DISPATCH,
JIT_EPILOG,
JIT_EPILOG = 33,
JIT_RETURN,
JIT_PROFILING,
JIT_PUSH_IMMEDIATE,
JIT_DECLARE_WORD,
JIT_SAVE_STACK,
JIT_SAVE_STACK = 38,
JIT_DIP_WORD,
JIT_DIP,
JIT_2DIP_WORD,