comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: A Gnother Gnasty bug
Date: Mon, 9 Apr 2012 14:09:00 -0700 (PDT)
Date: 2012-04-09T14:09:00-07:00	[thread overview]
Message-ID: <16824531.853.1334005741021.JavaMail.geo-discussion-forums@ynbv36> (raw)
In-Reply-To: <wccd37jzlwu.fsf@shell01.TheWorld.com>

On Saturday, April 7, 2012 6:55:29 AM UTC-7, Robert A Duff wrote:
> There are at least two ways to implement it:
> 
>     Call F(42), putting the result in a temp.
>     Call Allocate with the size and alignment of that temp.
>     Copy the temp into the newly-allocated object,
>         with adjustment/finalization if controlled.
> 
>     Call F, passing it a hidden thunk, which does
>         the allocation.
>     At the point where F does "return", call the thunk,
>         passing this size and alignment.
>     Store the result of F at the address returned by
>         the thunk.
> 
> If the designated type is limited, the second way is
> necessary, because the first way won't work (it involves
> a copy, which won't work for limited types).

That last isn't really true, I think.  The language says there's no *assignment* for limited types; the assignment operation is defined by the language, and that operation involves finalization, adjustment, maybe some constraint checks, maybe some other things.  But there's no rule saying that the compiler can't implement things by doing a byte copy "under the hood", as long as it doesn't result in any additional Adjust/Finalizes being called.  The language specifies how things look semantically, not how they're implemented.

The tricky case is where the result of F contains self-references (possibly in a component); now, if the compiler generates code to do a byte copy, it has to make sure any self-references are fixed.  I don't think that generating code like this violates any language semantics, though.  (In fact, see AARM 7.6(17.q-17.v); I think those say that the "intended implementation" is that the address of J.all is the same as the address of the return object when F is called, but that's not a requirement and alternative implementations are theoretically possible.)

                    -- Adam



  reply	other threads:[~2012-04-09 21:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-07  0:44 A Gnother Gnasty bug sbelmont700
2012-04-07 11:09 ` Ludovic Brenta
2012-04-07 12:48   ` sbelmont700
2012-04-07 13:55   ` Robert A Duff
2012-04-09 21:09     ` Adam Beneschan [this message]
2012-04-09 21:39       ` Robert A Duff
2012-04-07 11:54 ` Simon Wright
replies disabled

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