[M3devel] fewer wrappers/more C? (or a wash?)
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Mon Apr 20 16:53:20 CEST 2009
On Sun, Apr 19, 2009 at 09:45:49PM -0500, Rodney M. Bates wrote:
> 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.
The X toolkit was set up to be called from C, and the small integers
were just parameters to a C function, or else pointers, whatever was
more convenient. They had a specific range of small integers (which was
machine-dependent as far as I can tell), and the whole convention seems
to have been set up for coding convenience. I don't know how the limit
on "small" inetgers was decided.
The LSB trick is what I would recommend for us. I was just reinforcing
the hopelessless of assuming we can make REFANY match C conventions. I
suspect there are too many different ones.
-- hendrik
More information about the M3devel
mailing list