From: Tero Koskinen on 27 Jul 2010 10:10 On 07/27/2010 02:29 PM, Ludovic Brenta wrote: > AdaMagica writes: >> As far as I understand, GNAT replicates, RR shares generic code. >> (Don't know about IBM (former Rational).) > > My understanding is similar; indeed, Janus/Ada is the only compiler that > shares generics. Unfortunately, no compiler offers the option to > choose; this is an implementation decision. If I have understood correctly, Irvine's Ada compiler supports shared generics *and* provides a compile time option for this. On the other hand, Janus/Ada doesn't provide an option. With it, shared generics are always used. -Tero
From: anon on 27 Jul 2010 16:06 In <4c4e2d69$0$2378$4d3efbfe(a)news.sover.net>, "Peter C. Chapin" <pcc482719(a)gmail.com> writes: >It has been my understanding that Ada's generics are designed in such a >way as to allow implementations to share the code of a generic body >across all the instantiations. I understand that doing this might >involve a performance penalty relative to creating independent code for >each instantiation. However, I can see that there are cases where such >sharing would be desirable. > >Is my understanding still accurate (was it ever accurate), for example >even with Ada 2005? > >Thanks! > >Peter The Replication versus the Sharing of Generic code was initial based on the Ada Optimize pragma statement. That is, when the users define the option of "Time" the Generic code would be replicated, but the "Space" option would cause the compiler to share the code body. Not using the pragma statement or the Ada 95 "off" option allowed the designer to set an implementation default. Now as for GNAT it uses the optimization based on the GCC back end ( -OX where X in 0 .. 4 ). GNAT still preforms a syntactical check of the Optimize pragma statement, then treat's the statement as a comment like a number of other built-in Ada pragma statement. Which allows GNAT to replicate code and let the GCC handle rather its switches to shared or not. And at this time GCC does not understand the Ada's concept replication versus the sharing code for optimization.
From: Peter C. Chapin on 27 Jul 2010 18:23 On 2010-07-27 16:06, anon(a)att.net wrote: > Now as for GNAT it uses the optimization based on the GCC back end > ( -OX where X in 0 .. 4 ). GNAT still preforms a syntactical check of the > Optimize pragma statement, then treat's the statement as a comment like a > number of other built-in Ada pragma statement. Which allows GNAT to > replicate code and let the GCC handle rather its switches to shared or not. > And at this time GCC does not understand the Ada's concept replication > versus the sharing code for optimization. Thanks for all the replies to my question. I want to emphasize that my interest is not so much in what is done by current compilers but rather what is allowed by the standard. Is the standard (even the latest standard) written in such a way as to make a shared implementation of generic bodies possible? It sounds like the answer is yes. In contrast I have the impression that in C++ it is not really possible, or at least not feasible, for a compiler to share template bodies across instantiations. That is, the nature of C++ essentially requires a replication strategy. To be honest I'm not sure why I think this and I might be wrong. This isn't a C++ group so it's probably not appropriate to explore C++'s issues in too much detail here, but I will say that haven't heard any serious talk in the C++ community about implementations sharing template bodies. Peter
From: Keith Thompson on 27 Jul 2010 20:55 anon(a)att.net writes: [...] > The Replication versus the Sharing of Generic code was initial based on the > Ada Optimize pragma statement. That is, when the users define the option > of "Time" the Generic code would be replicated, but the "Space" option > would cause the compiler to share the code body. Not using the pragma > statement or the Ada 95 "off" option allowed the designer to set an > implementation default. I don't believe the definition of pragma Optimize was ever that specific; as far as I know, it was always intended merely as a vague hint. Here's the description from the Ada 83 reference manual: OPTIMIZE Takes one of the identifiers TIME or SPACE as the single argument. This pragma is only allowed within a declarative part and it applies to the block or body enclosing the declarative part. It specifies whether time or space is the primary optimization criterion. Using it to control generic code sharing would certainly be reasonable, but it's not required. -- Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst> Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"
From: Maciej Sobczak on 28 Jul 2010 03:59
On 28 Lip, 00:23, "Peter C. Chapin" <pcc482...(a)gmail.com> wrote: > In contrast I have the impression that in C++ it is not really possible, > or at least not feasible, for a compiler to share template bodies across > instantiations. Why? > That is, the nature of C++ essentially requires a > replication strategy. Why? What part of that "nature" requires it? From the point of view of object model and execution model, C++ and Ada are very similar. Compilation and deployment strategies are more or less equivalent. > To be honest I'm not sure why I think this and I > might be wrong. To be honest I'm not sure why you came up with such an idea. Formally, the C++ standard places no restrictions on how this should be done. > This isn't a C++ group so it's probably not appropriate > to explore C++'s issues in too much detail here, Don't worry, C and C++ are a frequent target of criticism here, so we might as well discuss some details from time to time. ;-) > but I will say that > haven't heard any serious talk in the C++ community about > implementations sharing template bodies. Because the code-expansion model is easier to implement and that's what most (all?) compiler vendors chosen to do. But, for the sake of exercise, think about a C++ *interpreter*. -- Maciej Sobczak * http://www.inspirel.com YAMI4 - Messaging Solution for Distributed Systems http://www.inspirel.com/yami4 |