Optimizations and performance improvements
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
can be set to
false to disable bytecode generation (which might be useful, for example, when doing low-level
debugging). The option
DEBUG_BYTE_CODE can be set to cause the generated bytecode 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 bytecode 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".
net.sf.saxon.CompileStylesheet facility, which serialized the internal representation of a stylesheet,
is withdrawn in this release. Because the feature offered few performance benefits, it was used mainly to enable XSLT stylesheets
to be distributed without revealing the source code to users, thus preserving the intellectual property of the author. The
feature is replaced by a new facility designed to achieve the same effect in a cleaner way, with fewer restrictions.
Saxon-PE/EE now provide a command to create a packaged stylesheet in the form of a ZIP file. The contents are
in obfuscated form so the source code is not visible. A JAR file,
saxon9-unpack.jar, is available
with all Saxon editions allowing a stylesheet that comes in this form to be executed. This JAR file contains
Saxonica proprietary (non-open-source) code, but is available at no cost and does not require a license key to run.
For full details of the facility see Packaged Stylesheets.