Optimization of Uncommon Code (Was Java ByteCode ...)

dlmoore@ix.netcom.com (David L Moore)
30 Jun 1996 16:52:25 -0400

          From comp.compilers

Related articles
Re: Java virtual machine as target language for C/C++ kik@zia.cray.com (1996-05-08)
Re: Java virtual machine as target language for C/C++ dw3u+@andrew.cmu.edu (Daniel C. Wang) (1996-05-27)
Re: Java virtual machine as target language for C/C++ d.love@daresbury.ac.uk (Dave Love) (1996-06-13)
Re: Java virtual machine as target language for C/C++ cdg@nullstone.com (1996-06-21)
Optimization of Uncommon Code (Was Java ByteCode ...) dlmoore@ix.netcom.com (1996-06-30)
Re: Optimization of Uncommon Code (Was Java ByteCode ...) wws@renaissance.cray.com (Walter Spector) (1996-07-01)
Re: Optimization of Uncommon Code dwight@pentasoft.com (Dwight VandenBerghe) (1996-07-02)
Re: Optimization of Uncommon Code rweaver@ix.netcom.com (1996-07-03)
Re: Optimization of Uncommon Code (Was Java ByteCode ...) ok@cs.rmit.edu.au (1996-07-04)
Re: Optimization of Uncommon Code (Was Java ByteCode ...) grout@polestar.csrd.uiuc.edu (1996-07-05)
Re: Optimization of Uncommon Code wws@renaissance.cray.com (Walter Spector) (1996-07-09)
[3 later articles]
| List of all articles for this month |

From: dlmoore@ix.netcom.com (David L Moore)
Newsgroups: comp.compilers
Date: 30 Jun 1996 16:52:25 -0400
Organization: Netcom
References: 96-05-061 96-05-163 96-06-048 96-06-081
Keywords: Fortran, comment

> f2c is a good case study for illustrating one type of problem with language A
> to language B translation systems.
>
> [f2c makes local variables static]
>
This used to be a common misconception - that locals in Fortran were
static and therefore retained their values from one call of a
procedure to the next. This was how Fortran was implemented on
some early machines.


Fortran 77 introduced the "save" statement to allow the programmer
to specify which variables should be static. Other variables can
be static or dynamic at the choice of the compiler.


So, either f2c has never been updated to the 77 standard in this area,
or else this is an example of a premature "optimisation" by a tool. In
either case, it is the tool that should be fixed, not the C optimizer.
[Sigh. Two minutes spent looking at the f2c manual page reveals that it has
an option to make variables automatic when it can. Some years ago I wrote
one of the earlier F77 compilers, INfort, and since it was running on a
PDP-11 with only a 16 bit address space, I tried hard to put everything on
the stack that I could. The customers hated it. There's millions of lines
of legacy Fortran code, almost all of which assumes that all variables are
static, regardless of what the F77 standard says. So I had to do the same
thing as f77 and f2c (which is f77 with a C generating back end) do, make
everything static unless requested otherwise. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.