From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: I'm facing an issue with: call to abstract procedure must be dispatching Date: Thu, 10 Dec 2015 17:43:24 -0600 Organization: JSA Research & Innovation Message-ID: References: <8bc7fd76-f00a-4eea-9715-470af028fc84@googlegroups.com> <1krm4xun4e4ny.jmh9kvf6s0a9.dlg@40tude.net> <12dc7aea-933d-4271-95bd-10df808917e4@googlegroups.com> <5hfb2q9imjfu.zs3xp9gxw0d3.dlg@40tude.net> <5788b259-8886-4ee2-8c3d-7799abfd840e@googlegroups.com> <14acd8b0-a5e9-40fd-b7cc-d319f914d507@googlegroups.com> <112596d0-d4ee-46e9-a02d-8de837aff352@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1449791005 19355 24.196.82.226 (10 Dec 2015 23:43:25 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 10 Dec 2015 23:43:25 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28766 Date: 2015-12-10T17:43:24-06:00 List-Id: "Serge Robyns" 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.