clasp
clasp copied to clipboard
ldbxxx functions should be implemented using gmp
@selwynsimsek is working on bignum stuff right now, but I thought I'd take a glance at this, and I don't actually see how to do it in any direct fashion.
What we do now is (ldb (byte size position) integer) = (logand (ash integer (- position)) (lognot (ash -1 size))), i.e., we lose the low bits then AND it with an appropriately sized mask. With bignums, from what I can see of GMP (https://gmplib.org/manual/Integer-Functions.html) we'd have to do the same thing. There's no specific way to extract a couple bits.
though if we had access to the array of limbs directly, like selwyn was doing, we could just grab whatever limbs are covered by the position, i suppose. might save a few cycles that would be used ANDing irrelevant bits.
Now that I have rewritten bignums this does seem more possible, as we can access the bignum "digits" directly. We can reduce or eliminate consing in some cases, though I don't know how much they come up.