From 05146c6907da480c1f64767b87171ad5af5a69bd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 12 May 2009 03:09:15 -0500 Subject: [PATCH] Remove compiled slot from quotations since its not needed --- basis/bootstrap/image/image.factor | 1 - basis/compiler/constants/constants.factor | 2 +- core/bootstrap/primitives.factor | 2 +- vm/code_block.cpp | 8 ++++---- vm/code_heap.cpp | 4 ++-- vm/cpu-ppc.S | 2 +- vm/cpu-x86.32.S | 2 +- vm/cpu-x86.64.S | 2 +- vm/image.cpp | 6 +++--- vm/layouts.hpp | 2 -- vm/primitives.cpp | 1 + vm/quotations.cpp | 14 ++++++++++---- vm/quotations.hpp | 2 ++ 13 files changed, 27 insertions(+), 21 deletions(-) diff --git a/basis/bootstrap/image/image.factor b/basis/bootstrap/image/image.factor index 92d75604e0..4a7a558703 100644 --- a/basis/bootstrap/image/image.factor +++ b/basis/bootstrap/image/image.factor @@ -448,7 +448,6 @@ M: quotation ' array>> ' quotation [ emit ! array - f ' emit ! compiled f ' emit ! cached-effect f ' emit ! cache-counter 0 emit ! xt diff --git a/basis/compiler/constants/constants.factor b/basis/compiler/constants/constants.factor index 6b383388ef..b795862970 100644 --- a/basis/compiler/constants/constants.factor +++ b/basis/compiler/constants/constants.factor @@ -20,7 +20,7 @@ CONSTANT: deck-bits 18 : underlying-alien-offset ( -- n ) bootstrap-cell alien tag-number - ; inline : tuple-class-offset ( -- n ) bootstrap-cell tuple 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 : array-start-offset ( -- n ) 2 bootstrap-cells array tag-number - ; inline : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 57bc61a005..d94cd45c3d 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -211,7 +211,6 @@ bi "quotation" "quotations" create { { "array" { "array" "arrays" } read-only } - { "compiled" read-only } "cached-effect" "cache-counter" } define-builtin @@ -514,6 +513,7 @@ tuple { "reset-inline-cache-stats" "generic.single" (( -- )) } { "inline-cache-stats" "generic.single" (( -- stats )) } { "optimized?" "words" (( word -- ? )) } + { "quot-compiled?" "quotations" (( quot -- ? )) } } [ [ first3 ] dip swap make-primitive ] each-index ! Bump build number diff --git a/vm/code_block.cpp b/vm/code_block.cpp index c34f651750..2ce69ebfde 100755 --- a/vm/code_block.cpp +++ b/vm/code_block.cpp @@ -68,10 +68,10 @@ static void *xt_pic(word *w, cell tagged_quot) else { quotation *quot = untag(tagged_quot); - if(quot->compiledp == F) - return w->xt; - else + if(quot->code) return quot->xt; + else + return w->xt; } } @@ -409,7 +409,7 @@ void mark_object_code_block(object *object) case QUOTATION_TYPE: { quotation *q = (quotation *)object; - if(q->compiledp != F) + if(q->code) mark_code_block(q->code); break; } diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index c8c7639930..2260d133fc 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -158,7 +158,7 @@ void forward_object_xts() { quotation *quot = untag(obj); - if(quot->compiledp != F) + if(quot->code) quot->code = forward_xt(quot->code); } break; @@ -194,7 +194,7 @@ void fixup_object_xts() case QUOTATION_TYPE: { quotation *quot = untag(obj); - if(quot->compiledp != F) + if(quot->code) set_quot_xt(quot,quot->code); break; } diff --git a/vm/cpu-ppc.S b/vm/cpu-ppc.S index a372b2b1f5..964882c8ae 100755 --- a/vm/cpu-ppc.S +++ b/vm/cpu-ppc.S @@ -45,7 +45,7 @@ multiply_overflow: /* Note that the XT is passed to the quotation in r11 */ #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 \ CALL_OR_JUMP_QUOT XX \ diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S index ff45f48066..afda9d31cd 100755 --- a/vm/cpu-x86.32.S +++ b/vm/cpu-x86.32.S @@ -25,7 +25,7 @@ pop %ebp ; \ 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 ABI limitation which would otherwise require us to do a bizzaro PC-relative diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S index 6b2faa1c0b..8cf7423239 100644 --- a/vm/cpu-x86.64.S +++ b/vm/cpu-x86.64.S @@ -61,7 +61,7 @@ #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 ABI limitation which would otherwise require us to do a bizzaro PC-relative diff --git a/vm/image.cpp b/vm/image.cpp index 9205aad260..f8aa07ded9 100755 --- a/vm/image.cpp +++ b/vm/image.cpp @@ -187,13 +187,13 @@ static void fixup_word(word *word) static void fixup_quotation(quotation *quot) { - if(quot->compiledp == F) - quot->xt = (void *)lazy_jit_compile; - else + if(quot->code) { code_fixup("->xt); code_fixup("->code); } + else + quot->xt = (void *)lazy_jit_compile; } static void fixup_alien(alien *d) diff --git a/vm/layouts.hpp b/vm/layouts.hpp index 40fd699e18..f8672e4522 100755 --- a/vm/layouts.hpp +++ b/vm/layouts.hpp @@ -269,8 +269,6 @@ struct quotation : public object { /* tagged */ cell array; /* tagged */ - cell compiledp; - /* tagged */ cell cached_effect; /* tagged */ cell cache_counter; diff --git a/vm/primitives.cpp b/vm/primitives.cpp index bd761625d8..2359173d9b 100755 --- a/vm/primitives.cpp +++ b/vm/primitives.cpp @@ -155,6 +155,7 @@ const primitive_type primitives[] = { primitive_reset_inline_cache_stats, primitive_inline_cache_stats, primitive_optimized_p, + primitive_quot_compiled_p, }; } diff --git a/vm/quotations.cpp b/vm/quotations.cpp index b049f528e4..e96af39766 100755 --- a/vm/quotations.cpp +++ b/vm/quotations.cpp @@ -272,14 +272,13 @@ void set_quot_xt(quotation *quot, code_block *code) quot->code = code; quot->xt = code->xt(); - quot->compiledp = T; } /* Allocates memory */ void jit_compile(cell quot_, bool relocating) { gc_root quot(quot_); - if(quot->compiledp != F) return; + if(quot->code) return; quotation_jit compiler(quot.value(),true,relocating); compiler.iterate_quotation(); @@ -300,10 +299,10 @@ PRIMITIVE(array_to_quotation) { quotation *quot = allot(sizeof(quotation)); quot->array = dpeek(); - quot->xt = (void *)lazy_jit_compile; - quot->compiledp = F; quot->cached_effect = F; quot->cache_counter = F; + quot->xt = (void *)lazy_jit_compile; + quot->code = NULL; drepl(tag(quot)); } @@ -354,4 +353,11 @@ VM_ASM_API cell lazy_jit_compile_impl(cell quot_, stack_frame *stack) return quot.value(); } +PRIMITIVE(quot_compiled_p) +{ + tagged quot(dpop()); + quot.untag_check(); + dpush(tag_boolean(quot->code != NULL)); +} + } diff --git a/vm/quotations.hpp b/vm/quotations.hpp index 719a94176e..c1a2a92bd1 100755 --- a/vm/quotations.hpp +++ b/vm/quotations.hpp @@ -35,4 +35,6 @@ PRIMITIVE(quotation_xt); VM_ASM_API cell lazy_jit_compile_impl(cell quot, stack_frame *stack); +PRIMITIVE(quot_compiled_p); + }