]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: ensure that non-optimized calls to generic words which have not yet been compiled...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 6 Jan 2010 10:49:14 +0000 (23:49 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 6 Jan 2010 10:49:14 +0000 (23:49 +1300)
core/compiler/units/units-tests.factor
vm/code_blocks.cpp
vm/quotations.cpp
vm/vm.hpp

index eccc292f26b94155a9b89b87d9b31ce7efa5b2fe..4d308ff5453ff177ca40ddbaf5a84e930323a447 100644 (file)
@@ -1,5 +1,5 @@
 USING: compiler definitions compiler.units tools.test arrays sequences words kernel
-accessors namespaces fry eval ;
+accessors namespaces fry eval quotations math ;
 IN: compiler.units.tests
 
 [ [ [ ] define-temp ] with-compilation-unit ] must-infer
@@ -56,3 +56,16 @@ DEFER: nesting-test
 [ ] [ "IN: compiler.units.tests << : nesting-test ( -- ) ; >>" eval( -- ) ] unit-test
 
 observer remove-definition-observer
+
+! Make sure that non-optimized calls to a generic word which
+! hasn't been compiled yet work properly
+GENERIC: uncompiled-generic-test ( a -- b )
+
+M: integer uncompiled-generic-test 1 + ;
+
+<< [ uncompiled-generic-test ] [ jit-compile ] [ suffix! ] bi >>
+"q" set
+
+[ 4 ] [ 3 "q" get call ] unit-test
+
+FORGET: uncompiled-generic-test
index ec7a0e8998e74066f2bed3e4e9c6413c2522a615..d72d30cc962c18a08a2869799084c609198571f1 100755 (executable)
@@ -24,7 +24,7 @@ cell factor_vm::compute_xt_pic_address(word *w, cell tagged_quot)
        else
        {
                quotation *quot = untag<quotation>(tagged_quot);
-               if(quot->code)
+               if(quot_compiled_p(quot))
                        return (cell)quot->xt;
                else
                        return (cell)w->xt;
index 73c28875fa6e7502a623a5683391b64e4b8e10fa..c33f9b5d6f79046d246dbd5b54d87b5e77c2856d 100755 (executable)
@@ -293,8 +293,7 @@ code_block *factor_vm::jit_compile_quot(cell owner_, cell quot_, bool relocating
 void factor_vm::jit_compile_quot(cell quot_, bool relocating)
 {
        data_root<quotation> quot(quot_,this);
-
-       if(quot->code == NULL || quot->code == lazy_jit_compile_block())
+       if(!quot_compiled_p(quot.untagged()))
        {
                code_block *compiled = jit_compile_quot(quot.value(),quot.value(),relocating);
                set_quot_xt(quot.untagged(),compiled);
@@ -356,11 +355,16 @@ VM_C_API cell lazy_jit_compile(cell quot, factor_vm *parent)
        return parent->lazy_jit_compile(quot);
 }
 
+bool factor_vm::quot_compiled_p(quotation *quot)
+{
+       return quot->code != NULL && quot->code != lazy_jit_compile_block();
+}
+
 void factor_vm::primitive_quot_compiled_p()
 {
        tagged<quotation> quot(ctx->pop());
        quot.untag_check(this);
-       ctx->push(tag_boolean(quot->code != lazy_jit_compile_block()));
+       ctx->push(tag_boolean(quot_compiled_p(quot.untagged())));
 }
 
 cell factor_vm::find_all_quotations()
index 5f0858dab37f4c8e6afb5b247029cda3acd47ce7..92e921000b603efbaad315ae2ff0fc0ed8a4dd72 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -606,6 +606,7 @@ struct factor_vm
        void jit_compile_quot(cell quot_, bool relocating);
        fixnum quot_code_offset_to_scan(cell quot_, cell offset);
        cell lazy_jit_compile(cell quot);
+       bool quot_compiled_p(quotation *quot);
        void primitive_quot_compiled_p();
        cell find_all_quotations();
        void initialize_all_quotations();