From: Jere <jhb.chat@gmail.com>
Subject: Interfaces, Inlining, and Dispatching
Date: Sun, 16 Apr 2017 08:59:10 -0700 (PDT)
Date: 2017-04-16T08:59:10-07:00 [thread overview]
Message-ID: <0a9b7c30-cb2b-4bd5-ae34-4b141275ce9d@googlegroups.com> (raw)
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!
next reply other threads:[~2017-04-16 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-16 15:59 Jere [this message]
2017-04-17 5:53 ` Interfaces, Inlining, and Dispatching G.B.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox