[net.lang.ada] Problems with memory usage of Ada compilers

dik@mcvax.uucp (Dik T. Winter) (08/13/86)

We are experiencing problems with (virtual) memory requirements of
the Ada compilers.  We experienced them with both DG/ROLM and
DEC compilers (the last one with the default setting of 5 Mbyte
virtual memory).
The program structure is as follows:
	generic
	    type REAL is digits <>;
	package GENERIC_A is
	    -- a number of specifications
	end GENERIC_A;
	package body GENERIC_A is
	    -- the bodies of the routines from the specification
	    -- all indicated by body stubs.
	end GENERIC_A;
	-- followed by the subunits required.
A second source file contains the two lines:
	with GENERIC_A;
	package A_FLOAT is new GENERIC_A(FLOAT);

I admit the size of the subunits is a bit long, but: the first
file will not compile due to an internal STORAGE_ERROR on both
compilers.  It compiles if we split it in a number of source
files (i.e. the compiler is not releasing unused memory, or
not all unused memory).  But even if the generic templates
compile, the instantiation will not compile!  (Although it will
compile with the DEC compiler with more than 6 Mbyte virtual
memory.)

When we change the generic package to non-generic it compiles
and works.

Now we are faced with the following problem: software maintenance
dictates that we use a generic version and use standard instantiations
for all floating point types provided by the machines where it will
run.  But the compiler dictates that we use non-generic versions.
Another reason to use the non-generic version is that the (20 or so)
routines depend heavily on branches on the attribute REAL'DIGITS.
In a non-generic version this is static, while in a generic version
it is non-static making elimination of dead branches more difficult.

You might argue that we should split the package in a number of packages,
but this won't help as there are a lot of dependencies amongst the
routines involved.  As these dependencies are of no interest for the
user (and in fact might change in the future) the routines then have
to make local instantiations of generic packages (or routines); which
will not help a lot, and is impossible if the references are mutually
recursive (i.e. if routine A calls B while B calls A, now there is no
way to split the package).

Another reason to use the non-generic version, is that it might
simplify selective loading (i.e. if package A contains body stubs
for routines B and C, and the user uses B only, not C, the actual
code image should contain B only, not C).  I know that selective
loading is not done with the DG/ROLM system, but the process is in
fact quite simple.  (I know of an ALGOL68 compiler that also defined
precompilation in terms of packages and body stubs, that did
selective loading at no cost, not compile-time, not link-time and
not run-time, so it can be done.)  Also there is no real reason why it
should be more difficult with generics.  But the problems indicate
that the compilers generate code on an instantiation for the
generic template and all its subunits in one binary load module.
This zVis at least an fact with the DG/ROLM compiler.

So, what is the future of generics?  I await your comments on this.
-- 
dik t. winter, cwi, amsterdam, nederland
UUCP: {seismo,decvax,philabs,okstate,garfield}!mcvax!dik
  or: dik@mcvax.uucp
ARPA: dik%mcvax.uucp@seismo.css.gov