Bytecode generation
Saxon-EE 9.4 selectively compiles stylesheets and queries into Java bytecode before execution.
This change should be largely invisible to users, apart from the performance gain, which in typical cases is around 25%.
Where Saxon decides that generating bytecode would be advantageous, the bytecode is generated as the final stage in the query or stylesheet compilation process. The bytecode is held in memory (never written out to disk) as part of the expression tree. Interpreted expressions can call compiled expressions, and vice versa.
Bytecode generation is done using the ASM library, which is included as an integral part of the Saxon-EE JAR file.
Bytecode generation occurs even in the .NET version of the product. The bytecode is automatically and dynamically converted to .NET IL code prior to execution, by the IKVM runtime.
There are several configuration options associated with bytecode generation. The option GENERATE_BYTE_CODE
can be set to false
to disable byte code generation (which might be useful, for example, when doing low-level
debugging). The option
DEBUG_BYTE_CODE
can be set to cause the generated byte code to contain debugging
information. And the option
DISPLAY_BYTE_CODE
can be set to cause the generated code to be displayed
(on the standard error output).
The facility to generate byte code replaces the facility in Saxon 9.3 to generate Java source code (which was available for XQuery only). It also replaces the XSLT facility for "compiled stylesheets".