Bytecode generation
When a stylesheet package is compiled into its in-memory representation, SaxonJ-EE by default generates Java bytecode for faster execution of selected parts of the code. The generated bytecode is mixed with interpreted code, each calling the other where appropriate.
From Saxon 9.8, bytecode generation is by default applied only to hotspots, that is, parts of the
executable code that are found to be frequently executed. These will often be predicates in filter
expressions. The threshold for generating bytecode is configurable. Bytecode generation can be monitored
using the -TB
option on the command line.
The performance boost achieved by bytecode generation is variable; 25% is typical. The functions and templates that benefit the most are those where the expression tree contains many constructs that are relatively cheap in themselves, such as type conversion, comparisons, and arithmetic. This is because the saving from bytecode generation is mainly not in the cost of performing primitive operations, but in the cost of deciding which operations to perform: so the saving is greater where the number of operations is high relative to their average cost.
There are configuration options to suppress bytecode generation (GENERATE_BYTE_CODE), to insert debugging logic into the generated bytecode (DEBUG_BYTE_CODE), and to display the generated bytecode (DISPLAY_BYTE_CODE).
Currently, exported packages do not include bytecode.