]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: initialize all_blocks map from image
authorJoe Groff <arcata@gmail.com>
Fri, 18 Nov 2011 01:13:18 +0000 (17:13 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 23 Nov 2011 19:11:26 +0000 (11:11 -0800)
um, code blocks from the image need to go in the set too

vm/code_heap.cpp
vm/code_heap.hpp
vm/compaction.cpp
vm/image.cpp

index a804ee23a78f260eb61445ee96f6b34ff1c1dbd8..737f3cc837caf52881786413f54dba582d62c062 100755 (executable)
@@ -84,19 +84,34 @@ code_block *code_heap::code_block_for_address(cell address)
        return found_block;
 }
 
-void code_heap::update_all_blocks_map(mark_bits<code_block> *code_forwarding_map)
+struct all_blocks_set_inserter {
+       code_heap *code;
+
+       all_blocks_set_inserter(code_heap *code) : code(code) {}
+
+       void operator()(code_block *block, cell size)
+       {
+               code->all_blocks.insert(block);
+       }
+};
+
+void code_heap::initialize_all_blocks_set()
+{
+       all_blocks.clear();
+       all_blocks_set_inserter inserter(this);
+       allocator->iterate(inserter);
+}
+
+void code_heap::update_all_blocks_set(mark_bits<code_block> *code_forwarding_map)
 {
-       std::cout << "updating block map" << std::endl;
        std::set<code_block *> new_all_blocks;
        for (std::set<code_block *>::const_iterator oldi = all_blocks.begin();
                oldi != all_blocks.end();
                ++oldi)
        {
                code_block *new_block = code_forwarding_map->forward_block(*oldi);
-               std::cout << "compact " << (void*)*oldi << " -> " << (void*)new_block << std::endl;
                new_all_blocks.insert(new_block);
        }
-       std::cout << "updated" << std::endl;
        all_blocks.swap(new_all_blocks);
 }
 
index 5545f1e7d55a7c639691946445f87f725d1bcbe1..ac1df6a292ec194feafd73166dabe5b6e40f1ba2 100755 (executable)
@@ -47,7 +47,8 @@ struct code_heap {
        void flush_icache();
        void guard_safepoint();
        void unguard_safepoint();
-       void update_all_blocks_map(mark_bits<code_block> *code_forwarding_map);
+       void initialize_all_blocks_set();
+       void update_all_blocks_set(mark_bits<code_block> *code_forwarding_map);
 
        code_block *code_block_for_address(cell address);
 
index 16cc4ed92406b7e51d47ccadfa0af4b4942b70dd..dc31fce5d1fd0e51d8fbf5cd94e858f283634c9b 100644 (file)
@@ -186,7 +186,7 @@ void factor_vm::update_code_roots_for_compaction()
                        root->valid = false;
        }
 
-       code->update_all_blocks_map(state);
+       code->update_all_blocks_set(state);
 }
 
 /* Compact data and code heaps */
index 696d9ee1b4d4917d2b9a6d114382766b69b0e8e9..d1851d6b3277afdf09e25fa0894cf846c590d832 100755 (executable)
@@ -53,6 +53,7 @@ void factor_vm::load_code_heap(FILE *file, image_header *h, vm_parameters *p)
        }
 
        code->allocator->initial_free_list(h->code_size);
+       code->initialize_all_blocks_set();
 }
 
 struct startup_fixup {