comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Great Circle and Ada?
Date: 1996/09/17
Date: 1996-09-17T00:00:00+00:00	[thread overview]
Message-ID: <DxvLyG.J86@world.std.com> (raw)
In-Reply-To: AE643969966856B24@dialup112-5-3.swipnet.se


In article <AE643969966856B24@dialup112-5-3.swipnet.se>,
Lars Farm <lars.farm@ite.mh.se> wrote:
>What is virtual origin?

This means you represent a pointer to array A as the address of A[0].
If the zeroth element doesn't exist, then use the address of where it
"would" be.  So, if A has bounds 1..10, the pointer to A is the address
just before the array in memory.  If A has bounds -10..10, the pointer
is an address of the middle of A.  If A has bounds 1_000_000..2_000_000,
then the pointer is the address of some word very far from A.

>... Somewhere there has to be a way to reach the block
>from users code if one is to use it.

The compiler knows it's doing this, and so can generate the right code.
The address of the N'th element is simply
(the pointer) + N*(size-of-component).  The efficiency advantage is
that you avoid subtracting off the lower bound (which would be necessary
if you always used the address of A(A'First).

The compiler needs to keep the bounds of the array "somewhere else", so
it can do bounds checking.

>... Is is a pointer into the interior of
>an allocated block rather than to the start of the block? If so, at least
>Boehms GC has no problems with it and Great Circle can probably handle
>interior pointers too.

It's quite possible to implement GC with virtual origins, but the GC has
to know about it, and do the appropriate thing (just like the
compiler-generated code does).  This requires some cooperation between
the compiler and the GC (which is a Good Thing anyway, IMHO, but is not
the case with gcc/GNAT).

- Bob




  reply	other threads:[~1996-09-17  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-17  0:00 Great Circle and Ada? Lars Farm
1996-09-17  0:00 ` Robert A Duff [this message]
1996-09-17  0:00   ` Norman H. Cohen
1996-09-18  0:00     ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-09-14  0:00 John G. Volan
1996-09-15  0:00 ` Robert Dewar
replies disabled

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