Remove compiled slot from quotations since its not needed

Slava Pestov 2009-05-12 03:09:15 -05:00
parent cc67f8312b
commit 05146c6907
13 changed files with 27 additions and 21 deletions

View File

@ -448,7 +448,6 @@ M: quotation '
array>> ' array>> '
quotation [ quotation [
emit ! array emit ! array
f ' emit ! compiled
f ' emit ! cached-effect f ' emit ! cached-effect
f ' emit ! cache-counter f ' emit ! cache-counter
0 emit ! xt 0 emit ! xt

View File

@ -20,7 +20,7 @@ CONSTANT: deck-bits 18
: underlying-alien-offset ( -- n ) bootstrap-cell alien tag-number - ; inline : underlying-alien-offset ( -- n ) bootstrap-cell alien tag-number - ; inline
: tuple-class-offset ( -- n ) bootstrap-cell tuple tag-number - ; inline : tuple-class-offset ( -- n ) bootstrap-cell tuple tag-number - ; inline
: word-xt-offset ( -- n ) 10 bootstrap-cells \ word tag-number - ; inline : word-xt-offset ( -- n ) 10 bootstrap-cells \ word tag-number - ; inline
: quot-xt-offset ( -- n ) 5 bootstrap-cells quotation tag-number - ; inline : quot-xt-offset ( -- n ) 4 bootstrap-cells quotation tag-number - ; inline
: word-code-offset ( -- n ) 11 bootstrap-cells \ word tag-number - ; inline : word-code-offset ( -- n ) 11 bootstrap-cells \ word tag-number - ; inline
: array-start-offset ( -- n ) 2 bootstrap-cells array tag-number - ; inline : array-start-offset ( -- n ) 2 bootstrap-cells array tag-number - ; inline
: compiled-header-size ( -- n ) 4 bootstrap-cells ; inline : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline

View File

@ -211,7 +211,6 @@ bi
"quotation" "quotations" create { "quotation" "quotations" create {
{ "array" { "array" "arrays" } read-only } { "array" { "array" "arrays" } read-only }
{ "compiled" read-only }
"cached-effect" "cached-effect"
"cache-counter" "cache-counter"
} define-builtin } define-builtin
@ -514,6 +513,7 @@ tuple
{ "reset-inline-cache-stats" "generic.single" (( -- )) } { "reset-inline-cache-stats" "generic.single" (( -- )) }
{ "inline-cache-stats" "generic.single" (( -- stats )) } { "inline-cache-stats" "generic.single" (( -- stats )) }
{ "optimized?" "words" (( word -- ? )) } { "optimized?" "words" (( word -- ? )) }
{ "quot-compiled?" "quotations" (( quot -- ? )) }
} [ [ first3 ] dip swap make-primitive ] each-index } [ [ first3 ] dip swap make-primitive ] each-index
! Bump build number ! Bump build number

View File

@ -68,10 +68,10 @@ static void *xt_pic(word *w, cell tagged_quot)
else else
{ {
quotation *quot = untag<quotation>(tagged_quot); quotation *quot = untag<quotation>(tagged_quot);
if(quot->compiledp == F) if(quot->code)
return w->xt;
else
return quot->xt; return quot->xt;
else
return w->xt;
} }
} }
@ -409,7 +409,7 @@ void mark_object_code_block(object *object)
case QUOTATION_TYPE: case QUOTATION_TYPE:
{ {
quotation *q = (quotation *)object; quotation *q = (quotation *)object;
if(q->compiledp != F) if(q->code)
mark_code_block(q->code); mark_code_block(q->code);
break; break;
} }

View File

@ -158,7 +158,7 @@ void forward_object_xts()
{ {
quotation *quot = untag<quotation>(obj); quotation *quot = untag<quotation>(obj);
if(quot->compiledp != F) if(quot->code)
quot->code = forward_xt(quot->code); quot->code = forward_xt(quot->code);
} }
break; break;
@ -194,7 +194,7 @@ void fixup_object_xts()
case QUOTATION_TYPE: case QUOTATION_TYPE:
{ {
quotation *quot = untag<quotation>(obj); quotation *quot = untag<quotation>(obj);
if(quot->compiledp != F) if(quot->code)
set_quot_xt(quot,quot->code); set_quot_xt(quot,quot->code);
break; break;
} }

View File

@ -45,7 +45,7 @@ multiply_overflow:
/* Note that the XT is passed to the quotation in r11 */ /* Note that the XT is passed to the quotation in r11 */
#define CALL_OR_JUMP_QUOT \ #define CALL_OR_JUMP_QUOT \
lwz r11,16(r3) /* load quotation-xt slot */ XX \ lwz r11,12(r3) /* load quotation-xt slot */ XX \
#define CALL_QUOT \ #define CALL_QUOT \
CALL_OR_JUMP_QUOT XX \ CALL_OR_JUMP_QUOT XX \

View File

@ -25,7 +25,7 @@
pop %ebp ; \ pop %ebp ; \
pop %ebx pop %ebx
#define QUOT_XT_OFFSET 16 #define QUOT_XT_OFFSET 12
/* We pass a function pointer to memcpy to work around a Mac OS X /* We pass a function pointer to memcpy to work around a Mac OS X
ABI limitation which would otherwise require us to do a bizzaro PC-relative ABI limitation which would otherwise require us to do a bizzaro PC-relative

View File

@ -61,7 +61,7 @@
#endif #endif
#define QUOT_XT_OFFSET 36 #define QUOT_XT_OFFSET 28
/* We pass a function pointer to memcpy to work around a Mac OS X /* We pass a function pointer to memcpy to work around a Mac OS X
ABI limitation which would otherwise require us to do a bizzaro PC-relative ABI limitation which would otherwise require us to do a bizzaro PC-relative

View File

@ -187,13 +187,13 @@ static void fixup_word(word *word)
static void fixup_quotation(quotation *quot) static void fixup_quotation(quotation *quot)
{ {
if(quot->compiledp == F) if(quot->code)
quot->xt = (void *)lazy_jit_compile;
else
{ {
code_fixup(&quot->xt); code_fixup(&quot->xt);
code_fixup(&quot->code); code_fixup(&quot->code);
} }
else
quot->xt = (void *)lazy_jit_compile;
} }
static void fixup_alien(alien *d) static void fixup_alien(alien *d)

View File

@ -269,8 +269,6 @@ struct quotation : public object {
/* tagged */ /* tagged */
cell array; cell array;
/* tagged */ /* tagged */
cell compiledp;
/* tagged */
cell cached_effect; cell cached_effect;
/* tagged */ /* tagged */
cell cache_counter; cell cache_counter;

View File

@ -155,6 +155,7 @@ const primitive_type primitives[] = {
primitive_reset_inline_cache_stats, primitive_reset_inline_cache_stats,
primitive_inline_cache_stats, primitive_inline_cache_stats,
primitive_optimized_p, primitive_optimized_p,
primitive_quot_compiled_p,
}; };
} }

View File

@ -272,14 +272,13 @@ void set_quot_xt(quotation *quot, code_block *code)
quot->code = code; quot->code = code;
quot->xt = code->xt(); quot->xt = code->xt();
quot->compiledp = T;
} }
/* Allocates memory */ /* Allocates memory */
void jit_compile(cell quot_, bool relocating) void jit_compile(cell quot_, bool relocating)
{ {
gc_root<quotation> quot(quot_); gc_root<quotation> quot(quot_);
if(quot->compiledp != F) return; if(quot->code) return;
quotation_jit compiler(quot.value(),true,relocating); quotation_jit compiler(quot.value(),true,relocating);
compiler.iterate_quotation(); compiler.iterate_quotation();
@ -300,10 +299,10 @@ PRIMITIVE(array_to_quotation)
{ {
quotation *quot = allot<quotation>(sizeof(quotation)); quotation *quot = allot<quotation>(sizeof(quotation));
quot->array = dpeek(); quot->array = dpeek();
quot->xt = (void *)lazy_jit_compile;
quot->compiledp = F;
quot->cached_effect = F; quot->cached_effect = F;
quot->cache_counter = F; quot->cache_counter = F;
quot->xt = (void *)lazy_jit_compile;
quot->code = NULL;
drepl(tag<quotation>(quot)); drepl(tag<quotation>(quot));
} }
@ -354,4 +353,11 @@ VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack)
return quot.value(); return quot.value();
} }
PRIMITIVE(quot_compiled_p)
{
tagged<quotation> quot(dpop());
quot.untag_check();
dpush(tag_boolean(quot->code != NULL));
}
} }

View File

@ -35,4 +35,6 @@ PRIMITIVE(quotation_xt);
VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack); VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack);
PRIMITIVE(quot_compiled_p);
} }