comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: GC+FSD for GNAT/GCC
Date: 1999/02/06
Date: 1999-02-06T00:00:00+00:00	[thread overview]
Message-ID: <79hsmq$jhv$1@plug.news.pipex.net> (raw)
In-Reply-To: m33e4jvs1n.fsf@muc.de

Andi Kleen wrote in message ...
[...]
|I wonder how hard it would be to put a "malloc()" plugin compatible
conservative
|GC like the Boehm GC into the GNAT run time library. As far as I can see
|GNAT uses a wrapper around the C Library's malloc function for its memory
|allocation needs. What would happen if I linked it with a GC malloc
library?


This strategy alone couldn't perform heap compaction - I'm going to call it
'free space defragmentation' (FSD) from now on (if nobody minds) - only GC,
and even then there are better ways (I think) of providing the GC. Without
FSD, however, you inevitably get creeping fragmentation (unless all blocks
allocated in the pool are the same size). I doubt that a GC scheme which
does not deal with fragmentation is of much value, in reality, but I would
welcome comments on this.

One kind of 'mark-sweep' scheme I am envisioning at this stage has the
following broad design.

The compiler (I'm not sure whether the front or back end) generates a piece
of constant data which encodes the locations of all access objects within
each record and array type, and of all access objects, and access
component-containing records and arrays, within each stack-frame. This data
is called the 'crib'.

The pool type's implementation can then use this crib to 'sweep' over all
access objects (including all those in the pool itself), 'marking' all
allocated objects which are still accessed (thus finding out all which are
not accessed, so performing GC), and then to sweep again, adjusting the
access values (or their data-pointers) as required (as a part of FSD).
Finally, the extant objects are shuffled into their new positions
(completing the FSD).

This is a non-locking scheme. The user (Ada programmer) must ensure that the
execution of a block which contains code that uses a pool (managed by this
scheme) in one task will never overlap with the execution of a block which
contains code that uses the same pool in another task. (If this cannot be
arranged, a locking scheme must be selected instead.) The most common case
will be where the pool is only ever used in one task (indeed, frequently in
a program which only has one task).

The compiler must generate code such that: no access object is in a
temporary location whenever an allocator or deallocator (of a managed pool)
is called; for every access object whose value is put into a temporary
location within a certain block, the value is written back into the
non-temporary location before the end of that block.

There are some details of this scheme I haven't quite sorted out yet (it's
quite complicated), but nothing major (with luck).

It is important to realise that this is just one scheme (albeit the most
important one, I think). I believe a variety of schemes -
locking/non-locking, mark-sweep/reference counter,
crib-reiteration/double-indirection/ring-of-pointers - will have to be
supplied.

Comments?

-------------------------------------------
Nick Roberts
-------------------------------------------

PS: I think the __GNAT_malloc() and __GNAT_free() routines would remain
unchanged, the entire GC+FSD stuff being managed at a higher level.








  parent reply	other threads:[~1999-02-06  0:00 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-14  0:00 Fixed point multiplication ambiguity Marc A. Criley
1999-01-14  0:00 ` Robert I. Eachus
1999-01-14  0:00 ` bob
1999-01-14  0:00 ` David C. Hoos, Sr.
1999-01-14  0:00 ` Matthew Heaney
1999-01-14  0:00 ` Tucker Taft
1999-01-15  0:00   ` robert_dewar
1999-01-28  0:00   ` Nick Roberts
1999-01-28  0:00     ` robert_dewar
1999-01-28  0:00     ` Tucker Taft
1999-01-28  0:00       ` robert_dewar
1999-01-29  0:00       ` Nick Roberts
1999-01-29  0:00         ` Tucker Taft
1999-01-29  0:00           ` Nick Roberts
1999-01-29  0:00             ` Tucker Taft
1999-02-01  0:00               ` Robert I. Eachus
1999-02-02  0:00               ` Building a compiler (was: Fixed point multiplication ambiguity) Nick Roberts
1999-02-03  0:00                 ` dennison
1999-02-03  0:00                 ` Chris Morgan
1999-02-04  0:00                   ` robert_dewar
1999-02-04  0:00                     ` Garbage collection - was " news.oxy.com
1999-02-04  0:00                       ` robert_dewar
1999-02-05  0:00                         ` David Botton
1999-02-05  0:00                         ` Tom Moran
1999-02-18  0:00                         ` news.oxy.com
1999-02-18  0:00                           ` Garbage collection - was Re: Building a compiler Samuel Mize
1999-02-19  0:00                             ` Samuel Mize
1999-02-18  0:00                           ` Garbage collection - was Re: Building a compiler (was: Fixed point multiplication ambiguity) David Botton
1999-02-18  0:00                           ` dewar
1999-02-18  0:00                           ` AdaHag
1999-02-19  0:00                           ` Steven Hovater
1999-02-20  0:00                           ` A Modest Defense of ACT (though they are big boys and can take care of themselves) Steve Quinlan
1999-02-21  0:00                             ` dewar
1999-02-22  0:00                               ` Matthew Heaney
1999-02-21  0:00                                 ` bill
1999-02-22  0:00                                   ` Larry Kilgallen
1999-02-22  0:00                                 ` dennison
1999-02-22  0:00                             ` dennison
1999-02-24  0:00                               ` Steve Quinlan
1999-02-25  0:00                                 ` dennison
1999-02-26  0:00                                   ` Steve Quinlan
1999-02-26  0:00                                     ` dennison
1999-02-27  0:00                                       ` Simon Wright
1999-02-27  0:00                                         ` Dave Taylor
1999-02-28  0:00                                       ` dewar
1999-02-25  0:00                                 ` dewar
1999-02-25  0:00                                   ` Steve Quinlan
1999-02-25  0:00                                     ` robert_dewar
1999-02-05  0:00                     ` GC+HC for GNAT/GCC (was: Building a compiler) Nick Roberts
     [not found]                       ` <m33e4jvs1n.fsf@muc.de>
1999-02-06  0:00                         ` Nick Roberts [this message]
1999-02-07  0:00                           ` GC+FSD for GNAT/GCC robert_dewar
1999-02-05  0:00                   ` Building a compiler Nick Roberts
1999-02-05  0:00                     ` Tucker Taft
1999-02-06  0:00                       ` Nick Roberts
1999-01-30  0:00             ` Fixed point multiplication ambiguity robert_dewar
1999-02-02  0:00               ` Building a compiler (was: Fixed point multiplication ambiguity) Nick Roberts
1999-02-03  0:00                 ` Tucker Taft
1999-02-03  0:00                 ` robert_dewar
1999-01-14  0:00 ` Fixed point multiplication ambiguity Tom Moran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox