CVS difference for ais/ai-00147.txt

Differences between 1.12 and version 1.13
Log of other versions for file ais/ai-00147.txt

--- ais/ai-00147.txt	2002/03/14 23:47:08	1.12
+++ ais/ai-00147.txt	2002/10/29 20:24:56	1.13
@@ -1,5 +1,7 @@
-!standard 07.06    (21)                               02-03-11  AI95-00147/10
+!standard 07.06    (21)                               02-10-23  AI95-00147/11
 !class binding interpretation 96-06-06
+!status Amendment 200Y 02-10-23
+!status ARG Approved (with changes) 9-0-1  02-10-12
 !status work item 02-03-11
 !status ARG Approved 7-0-0  02-02-12
 !status work item 99-04-20
@@ -15,7 +17,7 @@
 
 !summary
 
-7.6(18-21) does not apply to limited controlled types.  Thus, the
+7.6(18-21) does not apply to limited controlled types. Thus, the
 Initialize and Finalize calls will happen as described in other
 paragraphs of the Standard.
 
@@ -25,9 +27,9 @@
 !question
 
 RM-7.6(18-21) give implementations permission to eliminate certain calls
-to Adjust and Finalize.  The purpose of these rules is to allow greater
+to Adjust and Finalize. The purpose of these rules is to allow greater
 efficiency than is implied by the canonical semantics of controlled
-types.  However, it appears that these rules may not go far enough.
+types. However, it appears that these rules may not go far enough.
 
 Consider first a very simple example:
 
@@ -96,7 +98,7 @@
 Is an implementation allowed to optimize the above by creating the
 aggregate directly in X, thus avoiding all calls to Adjust and Finalize? (Yes.)
 (Such an optimization might well be feasible if F and G are inlined, or
-if the compiler is doing other kinds of inter-procedural analysis.  It
+if the compiler is doing other kinds of inter-procedural analysis. It
 might even be feasible without inter-procedural analysis, if the sizes of
 the function results are known at the call site and there is no danger of
 source/target overlap.)
@@ -123,10 +125,10 @@
 Add a new bulleted paragraph after 7.6(21):
 
 Furthermore, an implementation is permitted to omit implicit
-Initialize, Adjust and Finalize calls and associated assignment
-operations on an object of non-limited controlled type if
-  a) the implicit Initialize call invokes an Initialize procedure which is not
-     user-defined, and
+Initialize, Adjust, and Finalize calls and associated assignment
+operations on an object of nonlimited controlled type if
+  a) any omitted Initialize call is not a call on a user-defined Initialize
+     procedure, and
   b) any usage of the value of the object after the implicit Initialize or
      Adjust call and before any subsequent Finalize call on the object
      does not have some effect on the external interactions of the program, and
@@ -140,6 +142,22 @@
 This permission applies to Adjust and Finalize calls even if the
 implicit calls have additional external effects.
 
+AARM To Be Honest (for (a)):
+
+This does not apply to any calls to a user-defined Initialize routine that
+happen to occur in an Adjust or Finalize routine. It is intended that it is
+never necessary to look inside of an Adjust or Finalize routine to determine if
+the call can be omitted.
+
+AARM Reason:
+
+The goal of the above rules is to allow typical dead assignment
+removal algorithms to work for controlled types, and for typical
+dead variable removal to work unless these objects are default
+initialized by a user-defined Initialize procedure. This latter
+exception is to allow locks to be performed by a paired Initialize
+Finalize pair, even if the type is non-limited.
+
 !discussion
 
 The above examples show that the implicit calls can create a non-trivial
@@ -152,7 +170,7 @@
 assignments as stated in RM 7.6(17), with the anonymous temporary
 object being introduced as a named "temporary" object. In the case of
 the anonymous object, RM 7.6(21) allows the simplification asked for
-in the question.  It seems strange that the explicit introduction of
+in the question. It seems strange that the explicit introduction of
 the object in the code should make a significant difference in semantics.
 
 A slight rewriting of the last example would apparently fall under the
@@ -184,12 +202,12 @@
 7.6(18-21) does not allow the elimination of Initialize/Finalize pairs
 -- just Adjust/Finalize pairs, and then only on anonymous objects.
 
-For limited types, this is exactly what we want.  Limited controlled
+For limited types, this is exactly what we want. Limited controlled
 types are used, for example, to ensure properly matched calls, such as
-Lock/Unlock or Open/Close.  Another example is a limited controlled
+Lock/Unlock or Open/Close. Another example is a limited controlled
 type that is used purely because Initialize is an abort-deferred
-region.  That is, a limited controlled object might be used purely for
-the side-effects of its Initialize and Finalize operations.  (It is
+region. That is, a limited controlled object might be used purely for
+the side-effects of its Initialize and Finalize operations. (It is
 better to use Initialize for this purpose, rather than Finalize,
 because then the implementation has a better chance of optimizing away
 any finalization-related overhead.)  Therefore, 7.6(18-21) should
@@ -222,7 +240,7 @@
 number of call pairs.
 
 Note also that it is the assignment *operation* that is abort
-deferred, not the assignment_statement.  Thus, it is possible under
+deferred, not the assignment_statement. Thus, it is possible under
 canonical semantics for "A := B;" to be aborted after adjusting B in
 an anonymous temporary object or after finalizing A, but before
 assigning the new value into A and adjusting it. (Only the latter part
@@ -279,8 +297,8 @@
       ...
 
 We would like to eliminate the first Adjust call and BOTH Finalize
-calls.  As a group, they constitute the matching pairs. We cannot
-always eliminate single pairs.  It is fairly easy to do in a compiler,
+calls. As a group, they constitute the matching pairs. We cannot
+always eliminate single pairs. It is fairly easy to do in a compiler,
 but hard to describe in these terms in a language definition.
 
 The words in the !wording therefore capture the bounds of the
@@ -311,6 +329,56 @@
 permissions in 7.6(21). Therefore, the permission adds nothing but words to the
 language, and the entire last sentence of 7.6(21) should be deleted.
 
+!corrigendum 07.06(21)
+
+@drepl
+@xbullet<For an @fa<aggregate> or function call whose value is assigned into a target object,
+the implementation need not create a separate anonymous object if it can safely
+create the value of the @fa<aggregate> or function call directly in the target
+object. Similarly, for an @fa<assignment_statement>, the implementation need not
+create an anonymous object if the value being assigned is the result of
+evaluating a name denoting an object (the source object) whose storage cannot
+overlap with the target. If the source object might overlap with the target
+object, then the implementation can avoid the need for an intermediary
+anonymous object by exercising one of the above permissions and perform the
+assignment one component at a time (for an overlapping array assignment), or
+not at all (for an assignment where the target and the source of the assignment
+are the same object). Even if an anonymous object is created, the
+implementation may move its value to the target object as part of the
+assignment without re-adjusting so long as the anonymous object has no aliased
+subcomponents.>
+@dby
+@xbullet<For an @fa<aggregate> or function call whose value is assigned into a target object,
+the implementation need not create a separate anonymous object if it can safely
+create the value of the @fa<aggregate> or function call directly in the target
+object. Similarly, for an @fa<assignment_statement>, the implementation need not
+create an anonymous object if the value being assigned is the result of
+evaluating a name denoting an object (the source object) whose storage cannot
+overlap with the target. If the source object might overlap with the target
+object, then the implementation can avoid the need for an intermediary
+anonymous object by exercising one of the above permissions and perform the
+assignment one component at a time (for an overlapping array assignment), or
+not at all (for an assignment where the target and the source of the assignment
+are the same object).>
+
+Furthermore, an implementation is permitted to omit implicit
+Initialize, Adjust, and Finalize calls and associated assignment
+operations on an object of nonlimited controlled type if
+@xbullet<any omitted Initialize call is not a call on a user-defined Initialize
+procedure, and>
+@xbullet<any usage of the value of the object after the implicit Initialize or
+Adjust call and before any subsequent Finalize call on the object
+does not have some effect on the external interactions of the program, and>
+@xbullet<after the omission of such calls and operations, any execution of
+the program that executes an Initialize or Adjust call on an object
+or initializes an object by an @fa<aggregate> will also later execute a
+Finalize call on the object and will always do so prior to assigning
+a new value to the object, and>
+@xbullet<the assignment operations associated with omitted Adjust calls are
+also omitted.>
+This permission applies to Adjust and Finalize calls even if the
+implicit calls have additional external effects.
+
 !ACATS test
 
 This ruling gives permissions for optimizations. Such permissions aren't
@@ -1741,7 +1809,9 @@
 >really as an controlled object, but as a bit bucket to avoid premature
 >overwriting in the process of assigning overlapping objects)
 
-Yes, this seems like a better model. (Indeed, in this model, I think that the problems that showed up in Claw with the original optimization would not appear).
+Yes, this seems like a better model. (Indeed, in this model, I think that the
+problems that showed up in Claw with the original optimization would not
+appear).
 
 Let's look at the example using this model:
 

Questions? Ask the ACAA Technical Agent