This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Args list too long

"Bradley A. Smith" <> writes:

> What is the appropriate way to collapse groups of objects into a single
> object?

I've been thinking we should add a mechanism to compile an entire
package at once, to a single .o file.

This has a number of advantages:
* Much faster compilation.  The compiler needs to read in many
classes that are referenced, in addition to the class being compiled.
If we compile them all at once, each such class only needs to be
read in once.
* Shorting linker command lines, solving the current problem.
* Smaller executables.  For examples constants that appear in
multiple classes only appear once in the generated .o file.
* Compile-time method resolution.  If the compiler knows that
it has all the classes in a package, then it knows all the overrides
*and* all the call sites of any methods that have default
accessibility (package-private).  If a method is not overridden,
it can be changed from virtual to non-virtual.  It also becomes
a candidate for inlining.

The compiler can already compile multiple classes in a single
source file, since that is required by the Java spec.  All we
need to implement package-level compilation is define the
command-level interface, and then set up a mechanism to iterate
over the source files.  Note this mechanism is useful for both
java-to-native and class-to-native compilation.

This mechanism integrates pretty well with make, too.  For example:

JAVA_LANG_SOURCES = java/lang/ java/lang/ ...

java-lang.jpackage: Makefile
        echo $(JAVA_LANG_SOURCES) > java-lang.jpackage

java-lang.o:  $(JAVA_LANG_SOURCES) java-lang.jpackage
        gcj -o java-lang.o -O -g java-lang.jpackage

This assume we add jpackage as a new suffix, and a .jpackage
file contains a list of class filenames.
	--Per Bothner

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]