Harissa Manual


Installing Harissa

To install harissa:


How to use Harissa

Harissa offers two commands:

hi

hi is a Java interpreter. Its syntax can be obtained by executing it with no parameters:

hi version alpha3.01 copyright (C) Irisa/Inria 1996,1997
syntax: hi [-p] class args...
-p : generate profiling information
'class' is a class containing a 'main' method which will be launched.
        Its signature must be  'public static void main(String[])'.
'args' are the arguments given to the 'main' method.

The profiling information is written into the files vm.prof and call.prof.

hac

hac is a Java to C translator. A C source file is generated for each Java class used by the compiled application. The syntax can be obtained by executing hac with no parameters:

Hac version alpha3.02 copyright (C) Irisa/Inria 1996,1997
syntax: hac [-h] [-V] [-o output] [-d path] [-l lib] [-P] [-R] [-J] [-n]
            [-O] [-C] [-i size] [-I n] [-M nClass] [-B] [-T] [-g] [-s] [-t] [-S] [-N (+|-)Method]
            command classes...
'command' : one of header,stub,src,code,prog
'classes' : the Java classes to handle
-h : print this help
-V : verbose (more progress indication)
-o object : name of executable binary (default='./gen')
-d dir : directory of generated C sources (default='a.out')
-l x : don't generate classes provided by the 'libx' library
-P : print bytecode within each method
-R : Generate a dummy return after index bound exceptions (default for the SPARC)
-J : Generate a jump to a common label for index bound exceptions (default for i386)
-O : turn on optimizations (equivalent to -C -i100 -I1 -g)
-C : Class Hierarchy Analysis
-i size : allow method inlining when bytecode size <= size
-I n : perform at most n iterations of inlining (default: 0)
-M nClass : perform at most n iterations of inlining of classes matching Class
-B : no bound checks
-T : no type checks
-g : include source file information (name of variables, name of fields)
-s : assume that no class will be loaded dynamically
-t : Analyse thread creation (implies -C and -s)
-S : Force generation of single-threaded code
-N +Method : Specify that native methods matching Method may create threads (for -t)
-N -Method : Specify that native methods matching Method do not create threads (for -t)

When you compile a Java program into C, the C source files are written by default within the directory ./gen. A Makefile is also created. To compile the C sources you only need to go in the gen directory and type make.

Behavior of commands:

Behavior of options:


Creating and compiling separate libraries

The makefile provided in the directory libjdk permits to generate a library containing JDK java classes. Before typing make, edit #define that are OS dependent. Basically, the makefile lists classes of the JDK archive and for each class calls:

 hac code class
Then, C files are compiled and put together in a libjdk.so library. Then, the library has to be be used with -l jdk option.


Compiling the Javac compiler

The first step is to create a gen directory.

The following command can then be used to create an optimized binary (assuming the JDK library has been compiled seperately):

  hac -ljdk -t -O -o cjavac prog sun.tools.javac.Main 
to create the C files (this compilation process consumes about 40Mb of memory).

The C code can be compiled using the make command:

  cd gen; make

On a PC/Pentium 90 Mhz, C code generation (without optimizations) takes about 1 mn. C code compilation by gcc 2.7.2 with the -O2 option takes about 8 minutes.

To limit the memory consumption (and compile more quickly) one might use:

  hac -ljdk -o cjavac prog sun.tools.javac.Main 
which consumes about 15M of memory and thus should work fine on most systems. To compile the jdk library into the binary, use:
  hac -o cjavac prog sun.tools.javac.Main 

To compile a highly optimized binary, assuming that enough RAM is available (about 100Mb), one might use the command:

  hac -o cjavac -O -I5 -M1java. prog sun.tools.javac.Main

On SunOS, the make process sometime crashes, read the FAQ for solution.


Using the graphic Biss library

Graphic applications relying on Biss must be linked with the jdk, awt and biss libraries. Therefore, one should give the -ljdk -lawt -lbiss options to hac. For instance, the LibBrowser application distributed with Biss can be compiled with the following command:

  hac -ljdk -lawt -lbiss -C -g prog biss.jde.LibBrowser 
CHA requires a lot of memory, for large applications !! 240 Mb of virtual address space are required to compile LibBrowser with CHA.

Choosing between the GC and the non-GC version

Harissa is provided in two different configurations with and without Garbage Collection. The GC version is based on the Boehm-Demers-Weiser conservative garbage collector. The non GC version is based on the system malloc primitive. Since objects are never deallocated, it leads to an increase of the heap segment and a slow down of the application due to disk swapping.

The choice between the two versions is done by linking the application either with lib/mmwithgc/libmem.so or lib/mmwithout/libmem.so. To switch between versions, you have to change the LD_LIBRARY_PATH and HARISSA_LIB_MEM variables. On SunOS, the libmem.so library is statically linked with the program and the link phase has to be redone. To to so the application binary must be removed and the make restarted.


Controlling inlining

As a solution for the memory consumption problems that can arise with inlining on large programs, the command-line switch -M is provided. The command-line switches -i and -I control how much inlining can be performed. The current memory consumption problems are primarily visible when inlining is performed in multiple iterations. The -M option allows one to limit the inlining performed on certain parts of the program, such as the java class library and classes containing non-critical methods.


Implementation details

The Linux version of Harissa uses version 0.6-4 of the linuxthreads package (available at most Linux FTP sites). To compile the programs produced by Harissa, this library must be installed on the machine. Harissa has been tested with version 5.4.33-1 of the libc library.

Harissa's garbage collector, the Boehm-Demers-Weiser conservative garbage collector, internally provides specific memory allocation primitives for data that is known to not contain pointers. These primitives are used for array and string allocation, and in a few other places (as appropriate). However, the garbage collector is conservative and does assume that any value not allocated in this fashion may be a pointer. This can lead to memory leaks, as is probably the case with hac at the moment, but for most applications it works fine.


back to the Harissa home page