comp.lang.ada
 help / color / mirror / Atom feed
From: noc.near.net!das-news.harvard.edu!honeydew.srv.cs.cmu.edu!bb3.andrew.cmu. edu!news.sei.cmu.edu!firth@uunet.uu.net  (Robert Firth)
Subject: Re: GNAT & Unconstrained Arrays
Date: 28 Sep 93 12:08:10 GMT	[thread overview]
Message-ID: <1993Sep28.080810.15779@sei.cmu.edu> (raw)

In article <CE1vHy.4C4@inmet.camb.inmet.com> stt@spock.camb.inmet.com (Tucker T
aft) writes:

>The Intermetrics Ada compilers generally use a "secondary stack" for
>objects whose size is not known at compile-time, as well as for
>returning from functions with unconstrained result subtypes.
>A secondary stack is simply a per-task mark/release heap.

I have used exactly this system in two language implementations, and
strongly recommend it.

Some advantages, briefly:

(a) the primary stack size is known at the function level at compile
    time.  This not only saves a register, it simplifies both variable
    addressing and variable allocation.  For example, you don;t have
    to float simple variables out of inner blocks.

(b) the register you save can be the secondary stack pointer, and the
    mark/allocate/release then becomes simple open code

(c) the secondary stack is per task.  You don't have to worry about
    interrupts and task context switches during variable allocations -
    NEW must still implement mutual exclusion (or hairy tricks), but
    nothing else has to

(d) within a task, you have substantial gains in data locality

(e) you have much more freedom when and how to implement the release,
    since you know that the allocation is (almost) strictly LIFO and
    contiguous.  For example, you can release all the dynamic memory
    on function exit with one instruction, since you know there has
    been no task interleaving fragmenting a global heap.

In my humble opinion, putting local objects onto a global heap almost
always causes more trouble than it's worth, and leads to a series of
ever hairier, more dubious, and less maintainable hacks.

Robert Firth

             reply	other threads:[~1993-09-28 12:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-28 12:08 Robert Firth [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-28 10:32 GNAT & Unconstrained Arrays Richard Kenner
replies disabled

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