]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: deallocate old PIC after allocating the new one to avoid having the code heap...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 25 Nov 2009 03:20:23 +0000 (21:20 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 25 Nov 2009 03:20:23 +0000 (21:20 -0600)
vm/code_blocks.cpp
vm/inline_cache.cpp

index 9d6e9a4b2590cd0a1c11005b13eaadac71ab6d62..9c7349979c0daa86e7b2e785f925b844c81e18cb 100755 (executable)
@@ -79,9 +79,7 @@ void *factor_vm::get_rel_symbol(array *literals, cell index)
                        if(sym)
                                return sym;
                        else
-                       {
                                return (void *)factor::undefined_symbol;
-                       }
                }
        case ARRAY_TYPE:
                {
index 469bb8bf2e8aa2e007e836fc60a5a5dcc63b21db..76cdda116ee981e13e3e68f9b7b927062b39090d 100755 (executable)
@@ -183,23 +183,18 @@ void *factor_vm::inline_cache_miss(cell return_address_)
 
        check_code_pointer(return_address.value);
 
-       /* Since each PIC is only referenced from a single call site,
-          if the old call target was a PIC, we can deallocate it immediately,
-          instead of leaving dead PICs around until the next GC. */
-       deallocate_inline_cache(return_address.value);
-
        data_root<array> cache_entries(dpop(),this);
        fixnum index = untag_fixnum(dpop());
        data_root<array> methods(dpop(),this);
        data_root<word> generic_word(dpop(),this);
        data_root<object> object(((cell *)ds)[-index],this);
 
-       void *xt;
-
        cell pic_size = inline_cache_size(cache_entries.value());
 
        update_pic_transitions(pic_size);
 
+       void *xt;
+
        if(pic_size >= max_pic_size)
                xt = megamorphic_call_stub(generic_word.value());
        else
@@ -221,13 +216,17 @@ void *factor_vm::inline_cache_miss(cell return_address_)
        /* Install the new stub. */
        if(return_address.valid)
        {
+               /* Since each PIC is only referenced from a single call site,
+                  if the old call target was a PIC, we can deallocate it immediately,
+                  instead of leaving dead PICs around until the next GC. */
+               deallocate_inline_cache(return_address.value);
                set_call_target(return_address.value,xt);
 
 #ifdef PIC_DEBUG
                std::cout << "Updated "
-                       << (tail_call_site_p(return_address) ? "tail" : "non-tail")
-                       << " call site 0x" << std::hex << return_address << std::dec
-                       << " with " << std::hex << (cell)xt << std::dec;
+                       << (tail_call_site_p(return_address.value) ? "tail" : "non-tail")
+                       << " call site 0x" << std::hex << return_address.value << std::dec
+                       << " with " << std::hex << (cell)xt << std::dec << "\n";
 #endif
        }