]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/code_heap.cpp
vm: strip out call-counting profiler
[factor.git] / vm / code_heap.cpp
index 1d978f243967d2ce35ae4441890421f3ac3a348f..f46891f7b8268164f0de1a331df12f2e267469b8 100755 (executable)
@@ -71,15 +71,35 @@ void code_heap::flush_icache()
        factor::flush_icache(seg->start,seg->size);
 }
 
-/* Allocate a code heap during startup */
-void factor_vm::init_code_heap(cell size)
+struct address_finder {
+       cell address;
+       code_block *found_code_block;
+
+       address_finder(cell address)
+               : address(address), found_code_block(NULL) {}
+
+       void operator()(code_block *block, cell size)
+       {
+               if ((cell)block->entry_point() <= address
+                       && address - (cell)block->entry_point() < block->size())
+               {
+                       assert(found_code_block == NULL);
+                       found_code_block = block;
+               }
+       }
+};
+
+code_block *code_heap::code_block_for_address(cell address)
 {
-       code = new code_heap(size);
+       address_finder finder(address);
+       allocator->iterate(finder);
+       return finder.found_code_block;
 }
 
-bool factor_vm::in_code_heap_p(cell ptr)
+/* Allocate a code heap during startup */
+void factor_vm::init_code_heap(cell size)
 {
-       return (ptr >= code->seg->start && ptr <= code->seg->end);
+       code = new code_heap(size);
 }
 
 struct word_updater {
@@ -158,15 +178,13 @@ void factor_vm::primitive_modify_code_heap()
                                        parameters,
                                        literals);
 
-                               word->code = compiled;
+                               word->entry_point = compiled->entry_point();
                        }
                        break;
                default:
                        critical_error("Expected a quotation or an array",data.value());
                        break;
                }
-
-               update_word_entry_point(word.untagged());
        }
 
        if(update_existing_words)