Version 1 (modified by astalla, 12 years ago) (diff)


Loading compiled functions

ABCL compiles functions into Java classes, implementing the appropriate overloads of the execute() method.

Compiled functions are loaded with the Lisp function LOAD-COMPILED-FUNCTION, which relies on the Java method org.armedbear.lisp.Lisp.loadCompiledFunction which has several overloads. These methods can read the bytecode representing the compiled function from various sources, and ultimately turn it into a live Java (and Lisp) object.

A custom classloader is used to convert the bytecode (in the form of a byte array) into a Java class.

Performance considerations

To be used, a Java class must be instantiated, and compiled Lisp functions are no different. Currently, ABCL uses java.lang.Class.newInstance() to create a singleton object from the compiled function class. This is heavy performance-wise since it uses reflection; Erik Huelsmann profiled ABCL to discover that 40% of its startup time is spent in the native methods that look for the appropriate constructor to be invoked for each compiled function class. Several alternatives were discussed, but none proved satisfactory. I'm reporting them here for further reference.