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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8623fab5750cd6aa X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!news2.telebyte.nl!news-fra1.dfn.de!news-ber1.dfn.de!zrz.TU-Berlin.DE!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Improving Ada's image - Was: 7E7 Flight Controls Electronics Date: Fri, 18 Jun 2004 14:44:13 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <40b9c99e$0$268$edfadb0f@dread16.news.tele.dk> <1087325485.307616@master.nyc.kbcfp.com> <1087488758.881520@master.nyc.kbcfp.com> <1087508848.873039@master.nyc.kbcfp.com> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1087569853 25364 134.91.1.34 (18 Jun 2004 14:44:13 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Fri, 18 Jun 2004 14:44:13 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:1664 Date: 2004-06-18T14:44:13+00:00 List-Id: Brian May wrote: :>>>>> "Georg" == Georg Bauhaus writes: : : Georg> (And add a note that new String'("bla") need not mean dynamic heap : Georg> allocation, for example at library level.) : : Any chance you could please expand on this statement? How else could : it be implemented? What does GNAT do? An assembly listing for the following program shows no occurence of an allocator for Lib.fixed, and one occurence for dyn in main. Here is the library part. package Lib is type String_Access is access constant String; fixed: constant String_Access := new String'("AZAZAZ"); end Lib; ; ************* Initialized part of the global segment : 000000 lib.fixed DD __lcl.00000015 000004 __lcl.00000015 DD 00000001 DD 00000006 DB 41 DB 5A DB 41 DB 5A DB 41 DB 5A ; ********* End of segment, Total size = 18 To me, this looks like the String "AZAZAZ", with bounds 1 and 6. The listing has been produced by ObjectAda 722, GNAT appears to behave similarly. with Lib; procedure main is dyn: Lib.String_Access; n: Positive := 4; -- to prevent the compiler from "knowing" that lib.fixed(2..4) can be -- determined in advance, see the following statement. begin dyn := new String'(Lib.fixed(2..n)); end main; For this, I get MOVements for dyn, and n, then a small calculation, then a CALL rts_allocate. Then some instructions referring to __lcl.00000015 from above the lib.fixed character bytes, then a CALL _rts_block_move. So my guess is that the allocation happens for dyn, but not for fixed. (I don't read ASM fluently though, and neither Power PC assembler, so take this with a grain of salt.) IIRC, this has been discussed before. -- Georg