Version 1.9 of ai12s/ai12-0031-1.txt

Unformatted version of ai12s/ai12-0031-1.txt version 1.9
Other versions for file ai12s/ai12-0031-1.txt

!standard E.2.3(19/3)          14-05-08 AI12-0031-1/05
!class binding interpretation 12-11-17
!status Corrigendum 2015 13-12-17
!status WG9 Approved 14-06-27
!status ARG Approved 8-0-3 13-11-16
!status work item 12-06-06
!status received 12-05-17
!priority Low
!difficulty Medium
!subject All_Calls_Remote and indirect calls
!summary
The All_Calls_Remote aspect applies to all indirect or dispatching remote subprogram calls to the RCI unit as well as to direct calls from outside the declarative region of the RCI unit. Indirect and dispatching remote calls are always considered as being from outside the declarative region and are routed through the PCS.
!question
Does E.2.3(19/3) apply to indirect calls (that is those through remote access-to-subprogram values)? (Yes.)
Does E.2.3(19/3) apply to dispatching calls (that is those through remote access-to-class-wide types)? (Yes.)
!recommendation
(See summary.)
Modify AARM E.2.3(16.a/3):
Aspect Description for All_Calls_Remote: All {indirect or dispatching remote subprogram calls and all direct} remote {subprogram}[procedure] calls {from outside the declarative region of the RCI unit} should use the Partition Communication Subsystem[, even if they are local].
Replace E.2.3(19/3) with:
If aspect All_Calls_Remote is True for a given RCI library unit, then the implementation shall route any of the following calls through the Partition Communication Subsystem (PCS); see E.5:
* A direct call to a subprogram of the RCI unit from outside the declarative region of the unit;
* An indirect call through a remote access-to-subprogram value that designates a subprogram of the RCI unit;
* A dispatching call with a controlling operand designated by a remote access-to-class-wide value whose tag identifies a type declared in the RCI unit.
Modify AARM E.2.3(19.a/3):
Discussion: When this aspect is False (or not used), it is presumed that most implementations will {not} make [direct] calls {through the PCS} if the call originates in the same partition as that of the RCI unit. When this aspect is True, all {indirect or dispatching remote subprogram calls to the RCI unit and all direct} calls from outside the subsystem rooted at the RCI unit package are treated like calls from outside the partition, ensuring that the PCS is involved in all such calls (for debugging, redundancy, etc.).
Modify AARM E.2.3(19.b):
Reason: There is no point to force local {direct} calls ({including}[or] calls from children) to go through the PCS, since on the target system[,] these calls are always local, and all the units are in the same active partition.
!discussion
The goal of the All_Calls_Remote aspect is to force calls from outside the declarative region of the RCI unit to go through the PCS. Calls that are local to the RCI unit should always be local and never go through the PCS. This includes indirect and dispatching calls that don't involve remote access types.
This ideal can be implemented easily enough for direct calls, but there are excessive complications for the case of indirect or dispatching calls. In particular, it would be difficult for the implementation to determine if a call was local to the RCI unit, and thus whether the call should go through the PCS.
To avoid these complications, we say that all indirect or dispatching remote subprogram calls to an All_Calls_Remote RCI unit are assumed to be from outside the declarative region of the RCI unit, and therefore go through the PCS.
This has the additional benefit that All_Calls_Remote means all calls are remote from outside the declarative region of the RCI. This eliminates the possibility for requests to rename the pragma to Almost_All_Calls_Remote, or There_Is_A_Possibility_That_The_Call_You_Make_To_This_Package_Could_Be_Remote, etc.
!corrigendum E.2.3(19/3)
Replace the paragraph:
If aspect All_Calls_Remote is True for a given RCI library unit, then the implementation shall route any call to a subprogram of the RCI unit from outside the declarative region of the unit through the Partition Communication Subsystem (PCS); see E.5. Calls to such subprograms from within the declarative region of the unit are defined to be local and shall not go through the PCS.
by:
If aspect All_Calls_Remote is True for a given RCI library unit, then the implementation shall route any of the following calls through the Partition Communication Subsystem (PCS); see E.5:
!ACATS test
An ACATS C-Test should be constructed (probably using a custom PCS) to determine whether the intended calls are going through the PCS.
!appendix

From: Adam Beneschan
Sent: Thursday, May 17, 2012  3:12 PM

!topic Clarification on E.2.3(19)
!reference E.2.3(19)
!from Adam Beneschan 12-05-17
!discussion

Regarding this implementation requirement:

    If aspect All_Calls_Remote is True for a given RCI library unit,
    then the implementation shall route any call to a subprogram of
    the RCI unit from outside the declarative region of the unit
    through the Partition Communication Subsystem (PCS); see
    E.5. Calls to such subprograms from within the declarative region
    of the unit are defined to be local and shall not go through the
    PCS.

are the "calls" mentioned here intended to refer only to direct calls, or also
to indirect ones?  It seems like there are unnecessary complications if the
clause is supposed to apply to calls through access-to-subprogram objects.  For
example, if the program calls through a remote-access-to-subprogram object, the
access object will probably contain a partition_ID, and it makes sense for the
caller to check to see if the partition_ID refers to the current partition and
make a local call if so.  But if the rules require that it be a PCS call if the
subprogram is in an All_Calls_Remote package, the code would have to somehow
determine whether the subprogram address were in such a package.

Or in the case of a normal access-to-subprogram object: the access object is
probably just the address of a subroutine, and it would be the same subroutine
that would be called for a direct call, which, for a remote subprogram in an
All_Calls_Remote package, would be the address of a subroutine that uses the PCS
to call the target routine. If such an access-to-subprogram object were then
passed to a routine in a child package of the RCI unit, and the second sentence
of E.2.3(19) applied to indirect calls, the child package code would have to
somehow check the address in the access-to-subprogram object to see if it refers
to a remote subprogram in the parent unit, so that it could make a local call
instead of going through the PCS.

****************************************************************

From: Brad Moore
Sent: Sunday, June 16, 2013  1:40 AM 

The discussion of this AI yesterday arrived at this being a no action AI, and
the answer to the question being asked was changed to indicate that
All_Calls_Remote also applied to indirect calls from outside the declarative
region of the RCI package. The reasoning was that it would not be difficult to
add a bit of information to the fat pointer associated with a
remote-access-to-subprogram object to indicated whether the call came from
an All_Calls_Remote package. 

That is likely true, but I think the other case described in the AI is still a
problem, and is the main issue that needs to be solved. This is the case of a
normal access-to-subprogram object that happens to denote a subprogram in an
All_Calls_Remote package, when the call is being made from within the
declarative region of the RCI subprogram. This normal access-to-subprogram
object is likely not a fat pointer, and ordinarily would just invoke the
denoted All_Calls_Remote subprogram through the PCS. E.2.3(19/3) currently
says that this needs to be a local call though, yet it would likely be
difficult for the implementation to determine that the call is being made
from within the same declarative region.

The examples I had in the AI discussion unfortunately did not actually
capture this case. 

Here I think is a more specific example.

package RCI_Package is

   pragma Remote_Call_Interface;
   pragma All_Calls_Remote;

   procedure P;

end RCI_Package;

with Normal_Package;
package body RCI_Package is

   procedure Foo (Cb : Normal_Package.Callback) is
   begin
      Cb.all;  -- Supposed to be local call to P from 
               -- within declarative region.
               -- How can we determine this normal access-to-subprogram
               -- denotes an All_Calls_Remote subprogram from within
               -- the same declarative region?
   end Foo;

   procedure X is   -- this gets called somehow
   begin
      Normal_Package.Doit (Foo'Access);
   end X;

   procedure P is
   begin
     ...
   end P;

end RCI_Package.Child;

package Normal_Package is
   type Callback is access procedure;

   procedure Doit (Cb : Callback);
end Normal_Package;

with RCI_Package;
package body Normal_Package is

   procedure Doit (Cb : Callback) is
   begin
      Cb.all (RCI_Package.P'Access); 
      -- Normal access-to-subprogram object, which invokes
      -- an All_Calls_Remote subprogram though PCS
   end Doit;

end Normal_Package;

Based on this, I think perhaps that the AI as it was originally written up, is
closer to what we want.

****************************************************************

From: Brad Moore
Sent: Friday, November 15, 2013  11:23 PM 

Here is my homework. [This is version /03 of the AI - Editor.]

In a nutshell,

Indirect and dispatching calls to an All_Calls_Remote unit go through the PCS.
Direct calls from outside the declarative region of the ACR unit go through the PCS.
Local calls do not.

****************************************************************

Questions? Ask the ACAA Technical Agent