VM: change type of bignum_roots and remove unnecessary not-null checks

Declaring bignum_roots to contain bignum** instead of cell avoids some
superfluous casts. Casting it to cell is wrong because the items in it
are never tagged. And due to a earlier commit, bignum_roots will never
contain NULL:s so checking for them is not needed.
db4
Björn Lindqvist 2014-06-12 19:10:42 +02:00 committed by John Benediktsson
parent 8ac3b80173
commit a6e0867b22
3 changed files with 10 additions and 11 deletions

View File

@ -35,13 +35,12 @@ struct gc_bignum {
factor_vm* parent;
gc_bignum(bignum** addr, factor_vm* parent) : addr(addr), parent(parent) {
if (*addr)
parent->check_data_pointer(*addr);
parent->bignum_roots.push_back((cell)addr);
parent->check_data_pointer(*addr);
parent->bignum_roots.push_back(addr);
}
~gc_bignum() {
FACTOR_ASSERT(parent->bignum_roots.back() == (cell)addr);
FACTOR_ASSERT(parent->bignum_roots.back() == addr);
parent->bignum_roots.pop_back();
}
};

View File

@ -186,14 +186,14 @@ template <typename Fixup> void slot_visitor<Fixup>::visit_data_roots() {
}
template <typename Fixup> void slot_visitor<Fixup>::visit_bignum_roots() {
std::vector<cell>::const_iterator iter = parent->bignum_roots.begin();
std::vector<cell>::const_iterator end = parent->bignum_roots.end();
std::vector<bignum**>::const_iterator iter =
parent->bignum_roots.begin();
std::vector<bignum**>::const_iterator end =
parent->bignum_roots.end();
for (; iter < end; iter++) {
cell* handle = (cell*)(*iter);
if (*handle)
*handle = (cell)fixup.fixup_data(*(object**)handle);
bignum** ref = *iter;
*ref = (bignum*)fixup.fixup_data(*ref);
}
}

View File

@ -114,7 +114,7 @@ struct factor_vm {
themselves here. See data_roots.hpp and code_roots.hpp */
std::vector<cell*> data_roots;
std::vector<cell> bignum_roots;
std::vector<bignum**> bignum_roots;
std::vector<code_root*> code_roots;
/* Debugger */