]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/code_blocks.cpp
webapps.wiki: adding search bar
[factor.git] / vm / code_blocks.cpp
index 7348174076eeb85a7a22f555e4f6f3bdb482f75b..d9d774f9f961e1bca3a093d48a2f43c054e0bf11 100644 (file)
@@ -38,7 +38,7 @@ static cell compute_here_address(cell arg, cell offset, code_block* compiled) {
 }
 
 cell code_block::owner_quot() const {
-  if (!optimized_p() && TAG(owner) == WORD_TYPE)
+  if (type() != CODE_BLOCK_OPTIMIZED && TAG(owner) == WORD_TYPE)
     return untag<word>(owner)->def;
   return owner;
 }
@@ -47,7 +47,7 @@ cell code_block::owner_quot() const {
 // scan offset. In all other cases -1 is returned.
 // Allocates memory (quot_code_offset_to_scan)
 cell code_block::scan(factor_vm* vm, cell addr) const {
-  if (type() != code_block_unoptimized) {
+  if (type() != CODE_BLOCK_UNOPTIMIZED) {
     return tag_fixnum(-1);
   }
 
@@ -87,13 +87,13 @@ void factor_vm::update_word_references(code_block* compiled,
                                        bool reset_inline_caches) {
   if (code->uninitialized_p(compiled)) {
     initialize_code_block(compiled);
-  // update_word_references() is always applied to every block in
-  // the code heap. Since it resets all call sites to point to
-  // their canonical entry point (cold entry point for non-tail calls,
-  // standard entry point for tail calls), it means that no PICs
-  // are referenced after this is done. So instead of polluting
-  // the code heap with dead PICs that will be freed on the next
-  // GC, we add them to the free list immediately.
+    // update_word_references() is always applied to every block in
+    // the code heap. Since it resets all call sites to point to
+    // their canonical entry point (cold entry point for non-tail calls,
+    // standard entry point for tail calls), it means that no PICs
+    // are referenced after this is done. So instead of polluting
+    // the code heap with dead PICs that will be freed on the next
+    // GC, we add them to the free list immediately.
   } else if (reset_inline_caches && compiled->pic_p()) {
     code->free(compiled);
   } else {
@@ -283,33 +283,6 @@ void factor_vm::fixup_labels(array* labels, code_block* compiled) {
   }
 }
 
-// Might GC
-// Allocates memory
-code_block* factor_vm::allot_code_block(cell size, code_block_type type) {
-  code_block* block = code->allocator->allot(size + sizeof(code_block));
-
-  // If allocation failed, do a full GC and compact the code heap.
-  // A full GC that occurs as a result of the data heap filling up does not
-  // trigger a compaction. This setup ensures that most GCs do not compact
-  // the code heap, but if the code fills up, it probably means it will be
-  // fragmented after GC anyway, so its best to compact.
-  if (block == NULL) {
-    primitive_compact_gc();
-    block = code->allocator->allot(size + sizeof(code_block));
-
-    // Insufficient room even after code GC, give up
-    if (block == NULL) {
-      std::cout << "Code heap used: " << code->allocator->occupied_space()
-                << "\n";
-      std::cout << "Code heap free: " << code->allocator->free_space() << "\n";
-      fatal_error("Out of memory in add-compiled-block", 0);
-    }
-  }
-
-  block->set_type(type);
-  return block;
-}
-
 // Might GC
 // Allocates memory
 code_block* factor_vm::add_code_block(code_block_type type, cell code_,
@@ -359,10 +332,6 @@ code_block* factor_vm::add_code_block(code_block_type type, cell code_,
       std::make_pair(compiled, literals.value()));
   this->code->all_blocks.insert((cell)compiled);
 
-  // next time we do a minor GC, we have to trace this code block, since
-  // the fields of the code_block struct might point into nursery or aging
-  this->code->write_barrier(compiled);
-
   return compiled;
 }