comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching
Date: Thu, 10 Dec 2015 17:43:24 -0600
Date: 2015-12-10T17:43:24-06:00	[thread overview]
Message-ID: <n4d2mt$isr$1@loke.gir.dk> (raw)
In-Reply-To: c7533283-04c4-49f6-abe8-4f47d70b86df@googlegroups.com

"Serge Robyns" <serge.robyns@gmail.com> wrote in message 
news:c7533283-04c4-49f6-abe8-4f47d70b86df@googlegroups.com...
On Thursday, 10 December 2015 00:03:15 UTC+1, Randy Brukardt  wrote:
...
>If the variable is as following:
 > A_Reference : access not null T_something;  -- whereas T_Something is 
just a plain record type, i.e. not a tagged one.

If this is a stand-alone variable, it has dynamic accessibility (that is, 
the accessibility is that of the designated object, wherever it is).

>and the procedure signature
>  procedure Do_Something (Reference : not null access T_Something; ....);
>What would happen with:
 > Do_Something (A_Reference, ...);

Anonymous access parameters always have dynamic accessibility.

>My assumption is that the not null checks can be skipped during the call 
>and inside the procedure.

Most likely. Janus/Ada has an "assume nothing" mode as one could use 
streaming or Unchecked_Conversion to put a null value into a not null 
component, and in that case a check would be made anything. But that's 
usually only used for debugging when all else has failed (and it usually 
turns out that compiler assumptions aren't the problem).

> What other checks are performed inside Do_Something for A_Reference?

Accessibility checks. As I noted, the accessibility of Do_Something is 
dynamic. (I've always thought "accessibility" was a terrible term -- the 
correct concept is "lifetime". The designated object has to live long enough 
for the use it's put to, and if not, an accessibility check fails.)

Even if the body of Do_Something doesn't contain any accessibility checks 
(today), it could easily be changed to have one, so it's necessary to pass 
that information along with the pointer. And that can't be optimized away 
because to do so would make a body dependence (i.e., recompiling the body 
would require recompiling all of the calls).

To be fair, it would be possible to optimize the overhead away if the 
subprogram is inlined, or if the subprogram has a precondition that requires 
the object to be library-level. But I don't know if any compilers actually 
do any such optimizations.

Thus, "in out T" (which has static accessibility and thus doesn't have any 
accessibility overhead) is almost always cheaper than "not null access T" 
which has dynamic accessibility (and thus has to pass an accessibility 
value). As I said yesterday, the effect is small, but it's clearly non-zero 
(passing two words costs more than passing one word).

                                      Randy.



  reply	other threads:[~2015-12-10 23:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 16:45 I'm facing an issue with: call to abstract procedure must be dispatching Serge Robyns
2015-12-08 16:59 ` G.B.
2015-12-08 17:04 ` Dmitry A. Kazakov
2015-12-08 17:24   ` Serge Robyns
2015-12-08 17:42     ` Dmitry A. Kazakov
2015-12-08 18:00       ` Serge Robyns
2015-12-08 18:22         ` Dmitry A. Kazakov
2015-12-08 20:21           ` Serge Robyns
2015-12-08 21:08             ` Dmitry A. Kazakov
2015-12-08 21:55               ` Serge Robyns
2015-12-08 22:43                 ` Serge Robyns
2015-12-08 22:55                   ` Jeffrey R. Carter
2015-12-09 23:03                     ` Randy Brukardt
2015-12-10  8:38                       ` Serge Robyns
2015-12-10 23:43                         ` Randy Brukardt [this message]
2015-12-09  8:48                 ` Dmitry A. Kazakov
2015-12-09 10:53               ` G.B.
2015-12-09 12:03                 ` Dmitry A. Kazakov
2015-12-09 13:42                   ` G.B.
2015-12-09 14:23                     ` Dmitry A. Kazakov
2015-12-08 22:55             ` Jeffrey R. Carter
2015-12-08 23:04               ` Serge Robyns
2015-12-08 23:42                 ` Jeffrey R. Carter
2015-12-09 13:40                 ` Jere
2015-12-09 13:48                   ` G.B.
2015-12-09 15:33                     ` Jere
2015-12-13 21:37                 ` Shark8
2015-12-14  2:20                   ` Jeffrey R. Carter
2015-12-15  7:26                     ` Shark8
2015-12-08 17:30 ` Jeffrey R. Carter
2015-12-08 17:48   ` Serge Robyns
2015-12-08 18:46     ` Jeffrey R. Carter
2015-12-08 20:28       ` Serge Robyns
2015-12-08 22:20     ` 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