VM: Remove redundant #ifdef FACTOR_DEBUGs

FACTOR_DEBUG checks around asserts aren't needed, since FACTOR_ASSERT is
already conditionally defined by FACTOR_DEBUG.
db4
Erik Charlebois 2013-05-12 23:44:32 -04:00
parent 7b1b1eef23
commit b918c3e646
13 changed files with 6 additions and 36 deletions

View 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 */

View 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);

View 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

View 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
}

View 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();
}
};

View 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

View 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();
}
};

View 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;
}

View 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;
}

View 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;
}

View 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--;
}

View 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_));
}

View File

@ -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