Threaded code and quick instructions for Kaffe

This directory contains patches to the Kaffe JavaVM implementation that speed up the interpreter with threaded code and quick instructions. These patches were written by Helmut Eller.

Threaded code provides about 10% speedup over the original bytecode interpreter, threaded code and quick instructions provide about a factor of three (detailed results). More performance improvements in the kaffe interpreter should be possible without too much work (e.g., stack caching); the benefit of threaded code and quick instructions would be even more prominent if these optimizations were applied.
[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]COPYING03-Oct-1994 19:23 18K 
[TXT]benchmarks.txt22-Nov-1999 10:04 1.5K 
[CMP]kaffe-1.0.5.tar.gz25-Oct-1999 10:58 3.0M 
[CMP]submit_with_quick.patch.gz29-Nov-1999 10:00 21K 
[CMP]submit_without_quick.patch.gz29-Nov-1999 10:00 20K 
[CMP]threaded_no_patent.patch.gz14-Dec-1999 12:10 23K 
[CMP]with_quick.patch.gz22-Nov-1999 10:04 88K 
[CMP]without_quick.patch.gz22-Nov-1999 10:04 89K 

Building

Unpack the original kaffe package, e.g, kaffe-1.0.5:
tar xvfz kaffe-1.0.5.tar.gz
Then apply the desired patch (e.g., apply the patch with quick instructions to kaffe-1.05):
zcat with_quick.patch.gz |patch -p1 -d kaffe-1.0.5
A recent version of patch is required (e.g., patch 2.1 does not work).

Now run configure and make (GNU make required) to get the threaded code interpreter:

cd kaffe-1.0.5
./configure --with-engine=threaded_int
make
After successful compilation you may type:
make install
This installs the binaries and some skripts to setup your environment. Be aware that this will also install some less usefull wrapper skripts, e.g, `javac'. Read kaffe-1.0.5/INSTALL for more details.

Running kaffe without installing

Since Kaffe uses libtool the real executable is generated at installation time. To run kaffe without installing it, you can use the skript generated in kaffe-1.0.5/kaffe/kaffe/ named `Kaffe', but you have to set some environment variables. On Linux I do the following (in kaffe-1.0.5):
KAFFE_ROOT=`pwd`
LD_LIBRARY_PATH=\
`find $KAFFE_ROOT -name ".libs" -type d -printf "$KAFFE_ROOT/%P:"`
export LD_LIBRARY_PATH
to tell the dynamic linker where to find the libraries, and:
export CLASSPATH=$KAFFE_ROOT/libraries/javalib/Klasses.jar:.
to tell Kaffe where to find its .class files. After this
kaffe/kaffe/Kaffe 
should behave like an ordinary Java interpreter.

Note: the threaded code interpreter needs more stack space; it's recommended to use kaffe/kaffe/Kaffe -ss 1M

What files are patched

Most patches are applied to automatically created files named `Makefile.in'. More important are the following files:
configure.in
add threaded_int as optional execution engine
kaffe/kaffevm/classMethod.h
add the icode field to the _methods struct
kaffe/kaffevm/classMethod.c
add initialization code for the icode field (conditional compiled)
kaffe/kaffevm/threaded_int/
the subdirectory containing the source for the threaded code interpreter
config/i386/common.h
line 95 is changed from
		  : "r" (N), "a" (O), "1" (*(A)) : "cc" ); \
to
 		  : "r" (N), "a" (O), "r" (*(A)) : "cc" ); \
Without this modification I couldn't compile kaffe with -O0. But I don't know if the modified version is actually correct.

Legal issues

This code is available under the GPL.

The conversion to quick instructions is performed the first time the instruction is executed; this method may be patented. This should be easy to circumvent by doing the conversion in the same pass with the conversion to threaded code. This is done by threaded_no_patent.patch.gz; however, this variant currently converts only those instructions that can be resolved with the currently-loaded class files, so the resulting code is not as fast (30% slower than submit_with_quick.patch.gz).

[other Java stuff][Threaded code and Forth stuff]


Anton Ertl