]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: Remove redundant #ifdef FACTOR_DEBUGs
authorErik Charlebois <erikcharlebois@gmail.com>
Mon, 13 May 2013 03:44:32 +0000 (23:44 -0400)
committerErik Charlebois <erikcharlebois@gmail.com>
Mon, 13 May 2013 03:44:32 +0000 (23:44 -0400)
FACTOR_DEBUG checks around asserts aren't needed, since FACTOR_ASSERT is
already conditionally defined by FACTOR_DEBUG.

13 files changed:
vm/allot.hpp
vm/arrays.hpp
vm/code_blocks.cpp
vm/code_heap.cpp
vm/code_roots.hpp
vm/compaction.cpp
vm/data_roots.hpp
vm/generic_arrays.hpp
vm/layouts.hpp
vm/mark_bits.hpp
vm/object_start_map.cpp
vm/tagged.hpp
vm/vm.hpp

index cc45535adff2b5ab78c6af3a413fbd5c60dbe3e0..4e2375c22bd427ea2d7c4203714de89fda72d802 100644 (file)
@@ -6,9 +6,7 @@ namespace factor {
  */
 /* Allocates memory */
 inline object* factor_vm::allot_object(cell type, cell size) {
-#ifdef FACTOR_DEBUG
   FACTOR_ASSERT(!current_gc);
-#endif
 
   /* If the object is smaller than the nursery, allocate it in the nursery,
      after a GC if needed */
index 5c039ad2c2b54d3508fb64420ddd68f8210286c5..772a0afb3f89c47ca4b96e2902754447257923cb 100644 (file)
@@ -1,18 +1,14 @@
 namespace factor {
 
 inline cell array_nth(array* array, cell slot) {
-#ifdef FACTOR_DEBUG
   FACTOR_ASSERT(slot < array_capacity(array));
   FACTOR_ASSERT(array->type() == ARRAY_TYPE);
-#endif
   return array->data()[slot];
 }
 
 inline void factor_vm::set_array_nth(array* array, cell slot, cell value) {
-#ifdef FACTOR_DEBUG
   FACTOR_ASSERT(slot < array_capacity(array));
   FACTOR_ASSERT(array->type() == ARRAY_TYPE);
-#endif
   cell* slot_ptr = &array->data()[slot];
   *slot_ptr = value;
   write_barrier(slot_ptr);
index 9a30a9f891ec479501098eb535d099cdf695a86e..17175d2f1e16666e564293ae4c051b9b760a33cb 100644 (file)
@@ -73,13 +73,13 @@ cell factor_vm::code_block_owner(code_block* compiled) {
   if (owner.type_p(QUOTATION_TYPE)) {
     tagged<quotation> quot(owner.as<quotation>());
     tagged<array> elements(quot->array);
-#ifdef FACTOR_DEBUG
+
     FACTOR_ASSERT(array_capacity(elements.untagged()) == 5);
     FACTOR_ASSERT(array_nth(elements.untagged(), 4) ==
                       special_objects[PIC_MISS_WORD] ||
                   array_nth(elements.untagged(), 4) ==
                       special_objects[PIC_MISS_TAIL_WORD]);
-#endif
+
     tagged<wrapper> word_wrapper(array_nth(elements.untagged(), 0));
     return word_wrapper->object;
   } else
index 07b4f45f8e34060ef4e44c511ccbdcbe77e69bfc..68918607224672ce8eb5e21937a1b9f6fd0a4cad 100644 (file)
@@ -125,7 +125,7 @@ void code_heap::initialize_all_blocks_set() {
   all_blocks.clear();
   all_blocks_set_inserter inserter(this);
   allocator->iterate(inserter);
-#if defined(FACTOR_DEBUG)
+#ifdef FACTOR_DEBUG
   verify_all_blocks_set();
 #endif
 }
index f18a32037549906cc006ee657afdb799662c9952..ba525d0daca715d298e55cfc04fcfd9a4143f11b 100644 (file)
@@ -13,9 +13,7 @@ struct code_root {
   }
 
   ~code_root() {
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(parent->code_roots.back() == this);
-#endif
     parent->code_roots.pop_back();
   }
 };
index 136301918ffcbd9af96f6bffe2be15281c2f2567..1e301bc196d62d6d18eca73e5b5cfd2f585c8a13 100644 (file)
@@ -173,7 +173,7 @@ void factor_vm::update_code_roots_for_compaction() {
 void factor_vm::collect_compact_impl(bool trace_contexts_p) {
   gc_event* event = current_gc->event;
 
-#if defined(FACTOR_DEBUG)
+#ifdef FACTOR_DEBUG
   code->verify_all_blocks_set();
 #endif
 
index 1224554eb7e934f8914600c1427a02fd296bbd1c..bfbcb803e2d29a6997f5424bf126474c1cbd47f2 100644 (file)
@@ -41,9 +41,7 @@ struct gc_bignum {
   }
 
   ~gc_bignum() {
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(parent->bignum_roots.back() == (cell) addr);
-#endif
     parent->bignum_roots.pop_back();
   }
 };
index c28ee5f3ba9a1b5c1ce7a36dee6cb5324873ad30..d97ed1a8a50ad6953324ad04c1fa49253db85a9d 100644 (file)
@@ -1,9 +1,7 @@
 namespace factor {
 
 template <typename Array> cell array_capacity(const Array* array) {
-#ifdef FACTOR_DEBUG
   FACTOR_ASSERT(array->type() == Array::type_number);
-#endif
   return array->capacity >> TAG_BITS;
 }
 
index 7f87e06f44cba62c6cc25fa77c83f5cd0938f1ee..5377db32ea3653fd96344ddb982365597ab6ecf6 100644 (file)
@@ -109,9 +109,7 @@ inline static bool immediate_p(cell obj) {
 }
 
 inline static fixnum untag_fixnum(cell tagged) {
-#ifdef FACTOR_DEBUG
   FACTOR_ASSERT(TAG(tagged) == FIXNUM_TYPE);
-#endif
   return ((fixnum) tagged) >> TAG_BITS;
 }
 
index 769b2ecd3a9a5c44a43b8525baf0dc544bd1f2b9..fe5cf587b629c415a1e9f4b86d81ef5b8dad7820 100644 (file)
@@ -65,18 +65,14 @@ template <typename Block> struct mark_bits {
     if (start.first == end.first)
       bits[start.first] |= start_mask ^ end_mask;
     else {
-#ifdef FACTOR_DEBUG
       FACTOR_ASSERT(start.first < bits_size);
-#endif
       bits[start.first] |= ~start_mask;
 
       for (cell index = start.first + 1; index < end.first; index++)
         bits[index] = (cell) - 1;
 
       if (end_mask != 0) {
-#ifdef FACTOR_DEBUG
         FACTOR_ASSERT(end.first < bits_size);
-#endif
         bits[end.first] |= end_mask;
       }
     }
@@ -99,9 +95,7 @@ template <typename Block> struct mark_bits {
   /* We have the popcount for every mark_bits_granularity entries; look
      up and compute the rest */
   Block* forward_block(const Block* original) {
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(marked_p(original));
-#endif
     std::pair<cell, cell> position = bitmap_deref(original);
     cell offset = (cell) original & (data_alignment - 1);
 
@@ -111,9 +105,7 @@ template <typename Block> struct mark_bits {
     cell new_line_number =
         approx_popcount + popcount(marked[position.first] & mask);
     Block* new_block = (Block*)((char*)line_block(new_line_number) + offset);
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(new_block <= original);
-#endif
     return new_block;
   }
 
index d432763746a82b1b19c0b73d9a3d059c4125ab22..bcefda321d02b444c50c25c623d943eeeddf3cc1 100644 (file)
@@ -22,10 +22,8 @@ cell object_start_map::find_object_containing_card(cell card_index) {
     card_index--;
 
     while (first_object_in_card(card_index) == card_starts_inside_object) {
-#ifdef FACTOR_DEBUG
       /* First card should start with an object */
       FACTOR_ASSERT(card_index > 0);
-#endif
       card_index--;
     }
 
index 04a25486b964330c8cbf4b4e25c6298b344e4500..4ec0f7e93493c01b6661a91e998269a6374e7798 100644 (file)
@@ -23,16 +23,12 @@ template <typename Type> struct tagged {
   }
 
   cell value() const {
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(type_p());
-#endif
     return value_;
   }
 
   Type* untagged() const {
-#ifdef FACTOR_DEBUG
     FACTOR_ASSERT(type_p());
-#endif
     return (Type*)(UNTAG(value_));
   }
 
index 6d63f24423e48f229fbb9324e3c8ac72c426dbf9..599a656b5415aa9c9b9a344988af371bb102ba48 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -386,10 +386,8 @@ struct factor_vm {
   }
 
   inline void check_data_pointer(object* pointer) {
-#ifdef FACTOR_DEBUG
-    if (!(current_gc && current_gc->op == collect_growing_heap_op))
-      FACTOR_ASSERT(data->seg->in_segment_p((cell) pointer));
-#endif
+    FACTOR_ASSERT((current_gc && current_gc->op == collect_growing_heap_op) ||
+                  data->seg->in_segment_p((cell) pointer));
   }
 
   // generic arrays