slavapestov/factor — pull request #1073 by bjourne (2014-06-17 11:24:43+00:00)
Title: Data roots refactor part2

Here is the second part of the data roots refactoring. It's not ready for merging and can even wait til after the release you guys are planning on July 4th.

The idea is to merge bignum_roots which is only used for root tracking of bignum objects with data_roots. It's tedious work but straightforward to convert. The patches below converts about half of bignum.cpp and I plan to add more to finish it. The old idioms are written like this:

bignum* q = allot_bignum(length_q, q_negative_p);
GC_BIGNUM(q);
... allocations here ..
... more usages of q here...

It works because `gc_bignum` stores a reference to `q` and if the gc decides to move the object, it can update the address of `q` directly. But with data_roots, you must only access the pointer through the root itself:

bignum* q_ = allot_bignum(length_q, q_negative_p); // like before
data_root q(q_, this); // saved!
... allocations ...
bignum_trim(q_); // wrong! q_ could be an invalid pointer
bignum_trim(q.untagged()); // right! must always be accessed through the root

To make the difference clear, I've suffixed `bignum*` values with `_` and the rooted values are without. But any naming convention could do.