]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix 'become'
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 21 Apr 2009 05:05:39 +0000 (00:05 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 21 Apr 2009 05:05:39 +0000 (00:05 -0500)
core/memory/memory-tests.factor
vm/data_gc.c
vm/quotations.c

index 670c21d6ffb967d6c0835a48cbed1722fe0bd1a9..a6ecdc005e682af256ebe7f8c61468ffa3421f58 100644 (file)
@@ -3,6 +3,8 @@ sequences tools.test words namespaces layouts classes
 classes.builtin arrays quotations io.launcher system ;
 IN: memory.tests
 
+[ ] [ { } { } become ] unit-test
+
 ! LOL
 [ ] [
     vm
index 2252d07541f05ceb10a1d6db8050ae9572f73d63..cc1df13d58a203072eee8307759722b6e0dc58b7 100755 (executable)
@@ -564,6 +564,8 @@ void primitive_clear_gc_stats(void)
        clear_gc_stats();
 }
 
+/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
+   to coalesce equal but distinct quotations and wrappers. */
 void primitive_become(void)
 {
        F_ARRAY *new_objects = untag_array(dpop());
@@ -585,5 +587,9 @@ void primitive_become(void)
 
        gc();
 
+       /* If a word's definition quotation was in old_objects and the
+          quotation in new_objects is not compiled, we might leak memory
+          by referencing the old quotation unless we recompile all
+          unoptimized words. */
        compile_all_words();
 }
index f56ab6eada2cfa4b22eab9531128155ef96bf239..d08fecdefb3ea7ab223ecf6c486328bda13b1c8f 100755 (executable)
@@ -532,7 +532,8 @@ void compile_all_words(void)
        {
                F_WORD *word = untag_word(array_nth(untag_array(words),i));
                REGISTER_UNTAGGED(word);
-               jit_compile_word(word,word->def,false);
+               if(word->optimizedp == F)
+                       jit_compile_word(word,word->def,false);
                UNREGISTER_UNTAGGED(word);
                update_word_xt(word);
        }