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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Thu, 30 Jul 2015 14:22:53 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1ckwx9hern944$.1w0k6fbvlqo62$.dlg@40tude.net> <1ipfeas9434z5.o8661mp0cpkh.dlg@40tude.net> <75a31df9-801e-4e7f-8e29-403c0650c891@googlegroups.com> <53238a9a-1b46-457a-98d7-29d8db4ce165@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1438284175 26727 24.196.82.226 (30 Jul 2015 19:22:55 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 30 Jul 2015 19:22:55 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: number.nntp.giganews.com comp.lang.ada:194544 Date: 2015-07-30T14:22:53-05:00 List-Id: wrote in message news:eed7de55-d776-426d-a0e8-9d536fa2dad0@googlegroups.com... >Le mercredi 29 juillet 2015 22:40:08 UTC+2, Randy Brukardt a écrit : >> Besides, a compiler has a better idea of what can and should be inlined >> than >> a programmer. >About the "should", and assuming you want code optimization in time: do you >know > any compiler having a better idea than a programmer of what should be > inlined? Janus/Ada would have, had the full design ever have been implemented. I suspect that some obscure compilers have done it, but I don't know for sure. It depends on having link-time or JIT code generation, where the entire program can be processed at once. JIT is even better as it typically has hints about the usage of the routines, so it can know which ones are "hot". Else there would be some benefit to "hotness" hints. But the basic idea is that one specifies how much code expansion is allowable (from none to something just short of infinite - paging pressure means that performance will decrease at some amount of expansion, so one always wants to stop there), and then the compiler choses optimizations (inlining, loop unrolling, partial evaluation/body duplication) to meet that goal, maximizing "bang-for-the-buck" -- that is, getting the most value out of the allowed expansion. There is no way that a programmer can do that, as the number of calculations required is far beyond what a programmer can do. Moreover, there are some inlinings (or partial evaluations, if inlining isn't practical for some reason) that should always be accomplished. For instance, any subprogram that is called exactly once is a candidate, since any parameters eliminated will reduce both the time and space of the program. These can't reasonably be identified by a programmer. In the specific case of Janus/Ada, any generic that is instantiated exactly once will have all calls to a subprogram declared in that generic having a common generic descriptor parameter -- eliminating that cuts overhead and opens up the possibility of other optimizations (giving code quality much closer to a template implementation). And so on. If there aren't compilers that do this, it is sad, because it means that programs are a lot larger and slower than they have to be. Randy.