[M3devel] fewer wrappers/more C? (or a wash?)
Rodney M. Bates
rodney.m.bates at cox.net
Mon Apr 20 04:45:49 CEST 2009
hendrik at topoi.pooq.com wrote:
> On Fri, Apr 17, 2009 at 10:57:10PM +1000, Tony Hosking wrote:
>
>> I am a little concerned about passing REFANY directly to C code as
>> there is no guarantee that REFANY and C pointers will always be
>> compatible. ADDRESS can more safely be assumed compatible.
>>
>
> Indeed, I once read the X toolkit specs, and it was rife with small
> integers being packed into pointers. Apparently the toolkit resolved
> it not by a tag bit, but by its magnitude. There was some constant
> somewhere that identified which numbers were small enough to be
> considered not-pointers.
>
> This was a discrimination without a tag bit. Similar concept to what
> we're planning for the future of REFANY, but different implementation.
>
> I don't know how they figured out which pointer values were safe to
> treat as integers.
>
In my more elaborate "safe" proposal, at least, the language itself
does not specify anything about what the bit-encodings of tagged
types are. It's an implementors' option, and the language
can support whatever the implementors choose.
This could be used to match the X toolkit's encoding. However,
using the lsb takes advantage of the fact that heap objects must
always be aligned and thus the lsb is already always zero, when
it's really a heap pointer. That seems like by far the most efficient
encoding.
> -- hendrik
>
>
>
More information about the M3devel
mailing list