vm: ignore 'declare' calls in non-optimizing compiler
parent
602776c885
commit
b14c683b32
|
@ -163,6 +163,7 @@ USERENV: jit-3dip 40
|
||||||
USERENV: jit-execute-word 41
|
USERENV: jit-execute-word 41
|
||||||
USERENV: jit-execute-jump 42
|
USERENV: jit-execute-jump 42
|
||||||
USERENV: jit-execute-call 43
|
USERENV: jit-execute-call 43
|
||||||
|
USERENV: jit-declare-word 44
|
||||||
|
|
||||||
! PIC stubs
|
! PIC stubs
|
||||||
USERENV: pic-load 47
|
USERENV: pic-load 47
|
||||||
|
@ -493,6 +494,7 @@ M: quotation '
|
||||||
\ inline-cache-miss-tail \ pic-miss-tail-word set
|
\ inline-cache-miss-tail \ pic-miss-tail-word set
|
||||||
\ mega-cache-lookup \ mega-lookup-word set
|
\ mega-cache-lookup \ mega-lookup-word set
|
||||||
\ mega-cache-miss \ mega-miss-word set
|
\ mega-cache-miss \ mega-miss-word set
|
||||||
|
\ declare jit-declare-word set
|
||||||
[ undefined ] undefined-quot set ;
|
[ undefined ] undefined-quot set ;
|
||||||
|
|
||||||
: emit-userenvs ( -- )
|
: emit-userenvs ( -- )
|
||||||
|
|
|
@ -36,51 +36,47 @@ includes stack shufflers, some fixnum arithmetic words, and words such as tag,
|
||||||
slot and eq?. A primitive call is relatively expensive (two subroutine calls)
|
slot and eq?. A primitive call is relatively expensive (two subroutine calls)
|
||||||
so this results in a big speedup for relatively little effort. */
|
so this results in a big speedup for relatively little effort. */
|
||||||
|
|
||||||
bool quotation_jit::primitive_call_p(cell i)
|
bool quotation_jit::primitive_call_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 2) == array_capacity(elements.untagged())
|
return (i + 2) == length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_PRIMITIVE_WORD];
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(FIXNUM_TYPE)
|
|
||||||
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_PRIMITIVE_WORD];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool quotation_jit::fast_if_p(cell i)
|
bool quotation_jit::fast_if_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 3) == array_capacity(elements.untagged())
|
return (i + 3) == length
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
|
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(QUOTATION_TYPE)
|
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(QUOTATION_TYPE)
|
||||||
&& array_nth(elements.untagged(),i + 2) == parent_vm->userenv[JIT_IF_WORD];
|
&& array_nth(elements.untagged(),i + 2) == parent_vm->userenv[JIT_IF_WORD];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool quotation_jit::fast_dip_p(cell i)
|
bool quotation_jit::fast_dip_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 2) <= array_capacity(elements.untagged())
|
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DIP_WORD];
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
|
|
||||||
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DIP_WORD];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool quotation_jit::fast_2dip_p(cell i)
|
bool quotation_jit::fast_2dip_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 2) <= array_capacity(elements.untagged())
|
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_2DIP_WORD];
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
|
|
||||||
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_2DIP_WORD];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool quotation_jit::fast_3dip_p(cell i)
|
bool quotation_jit::fast_3dip_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 2) <= array_capacity(elements.untagged())
|
return (i + 2) <= length && array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_3DIP_WORD];
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(QUOTATION_TYPE)
|
|
||||||
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_3DIP_WORD];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool quotation_jit::mega_lookup_p(cell i)
|
bool quotation_jit::mega_lookup_p(cell i, cell length)
|
||||||
{
|
{
|
||||||
return (i + 3) < array_capacity(elements.untagged())
|
return (i + 4) <= length
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i)).type_p(ARRAY_TYPE)
|
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(FIXNUM_TYPE)
|
&& tagged<object>(array_nth(elements.untagged(),i + 1)).type_p(FIXNUM_TYPE)
|
||||||
&& tagged<object>(array_nth(elements.untagged(),i + 2)).type_p(ARRAY_TYPE)
|
&& tagged<object>(array_nth(elements.untagged(),i + 2)).type_p(ARRAY_TYPE)
|
||||||
&& array_nth(elements.untagged(),i + 3) == parent_vm->userenv[MEGA_LOOKUP_WORD];
|
&& array_nth(elements.untagged(),i + 3) == parent_vm->userenv[MEGA_LOOKUP_WORD];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool quotation_jit::declare_p(cell i, cell length)
|
||||||
|
{
|
||||||
|
return (i + 2) <= length
|
||||||
|
&& array_nth(elements.untagged(),i + 1) == parent_vm->userenv[JIT_DECLARE_WORD];
|
||||||
|
}
|
||||||
|
|
||||||
bool quotation_jit::stack_frame_p()
|
bool quotation_jit::stack_frame_p()
|
||||||
{
|
{
|
||||||
fixnum length = array_capacity(elements.untagged());
|
fixnum length = array_capacity(elements.untagged());
|
||||||
|
@ -96,7 +92,7 @@ bool quotation_jit::stack_frame_p()
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case QUOTATION_TYPE:
|
case QUOTATION_TYPE:
|
||||||
if(fast_dip_p(i) || fast_2dip_p(i) || fast_3dip_p(i))
|
if(fast_dip_p(i,length) || fast_2dip_p(i,length) || fast_3dip_p(i,length))
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -179,19 +175,21 @@ void quotation_jit::iterate_quotation()
|
||||||
break;
|
break;
|
||||||
case FIXNUM_TYPE:
|
case FIXNUM_TYPE:
|
||||||
/* Primitive calls */
|
/* Primitive calls */
|
||||||
if(primitive_call_p(i))
|
if(primitive_call_p(i,length))
|
||||||
{
|
{
|
||||||
emit_with(parent_vm->userenv[JIT_PRIMITIVE],obj.value());
|
emit_with(parent_vm->userenv[JIT_PRIMITIVE],obj.value());
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
tail_call = true;
|
tail_call = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
push(obj.value());
|
||||||
|
break;
|
||||||
case QUOTATION_TYPE:
|
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) */
|
mutually recursive in the library, but both still work) */
|
||||||
if(fast_if_p(i))
|
if(fast_if_p(i,length))
|
||||||
{
|
{
|
||||||
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
|
if(stack_frame) emit(parent_vm->userenv[JIT_EPILOG]);
|
||||||
tail_call = true;
|
tail_call = true;
|
||||||
|
@ -207,39 +205,37 @@ void quotation_jit::iterate_quotation()
|
||||||
emit(parent_vm->userenv[JIT_IF]);
|
emit(parent_vm->userenv[JIT_IF]);
|
||||||
|
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* dip */
|
/* dip */
|
||||||
else if(fast_dip_p(i))
|
else if(fast_dip_p(i,length))
|
||||||
{
|
{
|
||||||
if(compiling)
|
if(compiling)
|
||||||
parent_vm->jit_compile(obj.value(),relocate);
|
parent_vm->jit_compile(obj.value(),relocate);
|
||||||
emit_with(parent_vm->userenv[JIT_DIP],obj.value());
|
emit_with(parent_vm->userenv[JIT_DIP],obj.value());
|
||||||
i++;
|
i++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* 2dip */
|
/* 2dip */
|
||||||
else if(fast_2dip_p(i))
|
else if(fast_2dip_p(i,length))
|
||||||
{
|
{
|
||||||
if(compiling)
|
if(compiling)
|
||||||
parent_vm->jit_compile(obj.value(),relocate);
|
parent_vm->jit_compile(obj.value(),relocate);
|
||||||
emit_with(parent_vm->userenv[JIT_2DIP],obj.value());
|
emit_with(parent_vm->userenv[JIT_2DIP],obj.value());
|
||||||
i++;
|
i++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* 3dip */
|
/* 3dip */
|
||||||
else if(fast_3dip_p(i))
|
else if(fast_3dip_p(i,length))
|
||||||
{
|
{
|
||||||
if(compiling)
|
if(compiling)
|
||||||
parent_vm->jit_compile(obj.value(),relocate);
|
parent_vm->jit_compile(obj.value(),relocate);
|
||||||
emit_with(parent_vm->userenv[JIT_3DIP],obj.value());
|
emit_with(parent_vm->userenv[JIT_3DIP],obj.value());
|
||||||
i++;
|
i++;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
push(obj.value());
|
||||||
|
break;
|
||||||
case ARRAY_TYPE:
|
case ARRAY_TYPE:
|
||||||
/* Method dispatch */
|
/* Method dispatch */
|
||||||
if(mega_lookup_p(i))
|
if(mega_lookup_p(i,length))
|
||||||
{
|
{
|
||||||
emit_mega_cache_lookup(
|
emit_mega_cache_lookup(
|
||||||
array_nth(elements.untagged(),i),
|
array_nth(elements.untagged(),i),
|
||||||
|
@ -247,8 +243,13 @@ void quotation_jit::iterate_quotation()
|
||||||
array_nth(elements.untagged(),i + 2));
|
array_nth(elements.untagged(),i + 2));
|
||||||
i += 3;
|
i += 3;
|
||||||
tail_call = true;
|
tail_call = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
/* Non-optimizing compiler ignores declarations */
|
||||||
|
else if(declare_p(i,length))
|
||||||
|
i++;
|
||||||
|
else
|
||||||
|
push(obj.value());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
push(obj.value());
|
push(obj.value());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,12 +12,13 @@ struct quotation_jit : public jit {
|
||||||
relocate(relocate_){};
|
relocate(relocate_){};
|
||||||
|
|
||||||
void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
|
void emit_mega_cache_lookup(cell methods, fixnum index, cell cache);
|
||||||
bool primitive_call_p(cell i);
|
bool primitive_call_p(cell i, cell length);
|
||||||
bool fast_if_p(cell i);
|
bool fast_if_p(cell i, cell length);
|
||||||
bool fast_dip_p(cell i);
|
bool fast_dip_p(cell i, cell length);
|
||||||
bool fast_2dip_p(cell i);
|
bool fast_2dip_p(cell i, cell length);
|
||||||
bool fast_3dip_p(cell i);
|
bool fast_3dip_p(cell i, cell length);
|
||||||
bool mega_lookup_p(cell i);
|
bool mega_lookup_p(cell i, cell length);
|
||||||
|
bool declare_p(cell i, cell length);
|
||||||
bool stack_frame_p();
|
bool stack_frame_p();
|
||||||
void iterate_quotation();
|
void iterate_quotation();
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@ enum special_object {
|
||||||
JIT_EXECUTE_WORD,
|
JIT_EXECUTE_WORD,
|
||||||
JIT_EXECUTE_JUMP,
|
JIT_EXECUTE_JUMP,
|
||||||
JIT_EXECUTE_CALL,
|
JIT_EXECUTE_CALL,
|
||||||
|
JIT_DECLARE_WORD,
|
||||||
|
|
||||||
/* Polymorphic inline cache generation in inline_cache.c */
|
/* Polymorphic inline cache generation in inline_cache.c */
|
||||||
PIC_LOAD = 47,
|
PIC_LOAD = 47,
|
||||||
|
|
Loading…
Reference in New Issue