Re: Fat references

Robert A Duff <bobduff@shell01.TheWorld.com>
Wed, 30 Dec 2009 12:24:53 -0500

          From comp.compilers

Related articles
Fat references jon@ffconsultancy.com (Jon Harrop) (2009-12-29)
Re: Fat references paul.biggar@gmail.com (Paul Biggar) (2009-12-30)
Re: Fat references bobduff@shell01.TheWorld.com (Robert A Duff) (2009-12-30)
Re: Fat references cr88192@hotmail.com (BGB / cr88192) (2009-12-30)
Re: Fat references gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-12-30)
Re: Fat references jon@ffconsultancy.com (Jon Harrop) (2009-12-30)
Re: Fat references kkylheku@gmail.com (Kaz Kylheku) (2009-12-30)
Re: Fat references jon@ffconsultancy.com (Jon Harrop) (2009-12-30)
Re: Fat references gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-12-31)
[26 later articles]
| List of all articles for this month |

From: Robert A Duff <bobduff@shell01.TheWorld.com>
Newsgroups: comp.compilers
Date: Wed, 30 Dec 2009 12:24:53 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 09-12-045
Keywords: storage, GC
Posted-Date: 30 Dec 2009 12:29:10 EST

Jon Harrop <jon@ffconsultancy.com> writes:


> I've been working on a project called HLVM in my spare time:
>
> http://forge.ocamlcore.org/projects/hlvm
>
> One goal was to have fast interop with C, so I didn't want to copy the
> traditional style of placing a header with GC metadata before every value
> in the heap because that would require C arrays to be copied just to add
> this header. I couldn't be bothered to allocate a separate header so,
> instead, I pulled the GC metadata into the reference. So my references are
> now "fat": a quadword of pointer to run-time type, array length or union
> type tag, pointer to mark state and pointer to the actual data itself.
>
> This actually works rather well except I sacrificed atomic read/write of
> references. Has it been done before?


GNAT (the gcc Ada compiler) uses fat pointers by default to represent
pointers to unconstrained arrays. (Unconstrained means different
objects of a given array type can have different lengths.) The fat
pointer consists of the address of the bounds and the address of the
data.


One advantage is that it can use zero-origin indexing. That is, if
the bounds of the array are 10..20, the data address points to the
0'th array component, even though that component doesn't exist. So
indexing doesn't need to subtract off the lower bound.


The purpose of these fat pointers has nothing to do with GC, though.
GNAT does not currently support GC, except for the versions targeting
.NET and the JVM.


The user can also request thin pointers, which are the address of the
data, with the bounds stored just before the data. The zero-origin
trick won't work in this case.


I don't fully understand the problem you're trying to solve, nor how
fat pointers are the solution. Are you saying all pointers are fat (4
words per pointer!?)? Or just pointers to arrays? Under what
circumstances are you worried about an extra copy? If the array is
allocated on the C side, you have to concoct the meta data somehow...


Why not just say that arrays allocated on the C side are not
subject to GC?


By the way, if you're interested in GC, you should join the
GC list, which our esteemed moderator set up some years ago.


- Bob



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.