Compiling Queries
In Saxon 9.4, Saxon-EE automatically (and selectively) compiles queries to Java bytecode. When running on .NET, the bytecode is then automatically converted to IL code for execution. The bytecode exists only in memory, and would not be useful otherwise because it contains many references to the data structures generated by the Saxon parser and optimizer.
This facility replaces the ability in previous Saxon-EE releases to generate Java source code from a query.
The performance boost achieved by bytecode generation is variable; 25% is typical. The constructs 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 (FeatureKeys.GENERATE_BYTE_CODE
), to
insert debugging logic into the generated bytecode (FeatureKeys.DEBUG_BYTE_CODE
), and to display the generated
bytecode (FeatureKeys.DISPLAY_BYTE_CODE
).