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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.99.115.16 with SMTP id o16mr3493229pgc.63.1492358350876; Sun, 16 Apr 2017 08:59:10 -0700 (PDT) X-Received: by 10.157.84.12 with SMTP id j12mr130059oth.19.1492358350830; Sun, 16 Apr 2017 08:59:10 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!l11no757286itl.0!news-out.google.com!g66ni2189itc.0!nntp.google.com!e132no758451ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 16 Apr 2017 08:59:10 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.201.205; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.201.205 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0a9b7c30-cb2b-4bd5-ae34-4b141275ce9d@googlegroups.com> Subject: Interfaces, Inlining, and Dispatching From: Jere Injection-Date: Sun, 16 Apr 2017 15:59:10 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:46586 Date: 2017-04-16T08:59:10-07:00 List-Id: As I am messing around with interface types I am trying to figure out some things: 1. Is it possible for compilers to inline interface procedure implementations if the type being used is known at compile time? I.E: not using a class wide type or class wide access type to invoke the procedure. 2. If so, do current compilers implement this? 3. Assuming another part of the code use a separate implementation but dispatches from a class wide type or access type, will this revoke the inlining in the other code mentioned in question 1? I.E. Can the compiler have an inline version for statically dispatched procedure calls and a non inline version for dynamically dispatched calls? 4. If so, do current compilers implement this? Example: package Some_Interface is type Intfc is interface; type Intfc_Class_Access is access all Intfc'Class; procedure Do_Somethig(Self : in Intfc) is abstract; end Some_Interface; package Implementor_1 is type Impl is new interface with null record; overriding procedure Do_Something(Self : in Impl); end Implementor_1; package Implementor_2 is type Impl is new interface with null record; overriding procedure Do_Something(Self : in Impl); end Implementor_2; procedure Test_Intfc is Impl1 : Implementor_1.Impl; Impl2 : Implementor_2.Impl; Impls : array(1..2) of Some_Interface.Intfc_Class_Access := (1 => new Implementor_1.Impl, 2 => new Implementor_2.Impl); begin -- I think these cannot be inlined in order to do -- the dynamic dispatching for Ptr of Impls loop Ptr.Do_Something; end loop; -- Can (and does) the compiler inline these -- if they have a small simple implementation -- like just calling another private procedure, -- or does the dynamic dispatching above prevent the -- compiler from making a second inlined version -- of these procedures. Impl1.Do_Something; Impl2.Do_Something; end Test_Intfc; Forgive any typos. This was typed up just to illustrate the question. Thanks!