public class OptimizerEE extends Optimizer
config, FULL_OPTIMIZATION, NO_OPTIMIZATION, tracing
Constructor and Description |
---|
OptimizerEE(Configuration config)
Create the Saxon-EE optimizer
|
Modifier and Type | Method and Description |
---|---|
void |
assessFunctionStreamability(XSLFunction sourceFunction,
UserFunction compiledFunction)
Assess whether a declared-streamable function is actually streamable.
|
void |
checkStreamability(XSLTemplate sourceTemplate,
TemplateRule compiledTemplate)
Check the streamability of a template
|
Expression |
compileToByteCode(ICompilerService compilerService,
Expression expr,
java.lang.String objectName,
int evaluationMethods)
Generate Java byte code for an expression
|
Expression |
convertPathExpressionToKey(SlashExpression pathExp,
ExpressionVisitor visitor)
Examine a path expression to see whether it can be replaced by a call on the key() function;
if so, generate an appropriate key definition and return the call on key().
|
FilterExpression |
convertToFilterExpression(SlashExpression pathExp,
TypeHierarchy th)
Convert a path expression such as a/b/c[predicate] into a filter expression
of the form (a/b/c)[predicate].
|
Expression |
eliminateCommonSubexpressions(Expression in)
Eliminate common subexpressions.
|
Sequence |
evaluateStreamingArgument(Expression expr,
XPathContext context)
Evaluate the streaming (first) argument of a streamable stylesheet function
|
int |
gatherOrExpressions(int commonParts,
ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType,
java.util.HashMap<Expression,java.util.List<Expression>> map,
java.util.List<Expression> otherExps,
Expression expr)
Try to convert a collection of comparisons connected by "or" operators into a
single GeneralComparison
|
Expression |
generateMultithreadedInstruction(Expression instruction)
Generate a multi-threaded version of an instruction.
|
void |
injectByteCodeCandidates(Expression expression) |
int |
isIndexableFilter(Expression filter)
Test whether a filter predicate is indexable.
|
Expression |
makeByteCodeCandidate(ExpressionOwner owner,
Expression expr,
java.lang.String objectName,
int requiredEvaluationModes)
Insert a ByteCodeCandidate into the expression tree.
|
Expression |
makeConditionalDocumentSorter(DocumentSorter sorter,
SlashExpression path)
Make a conditional document sorter.
|
void |
makeCopyOperationsExplicit(Expression parent,
Operand childOp)
In streaming mode, make the copy operation applied to subexpressions of a complex-content
sequence constructor into explicit copy-of operations.
|
Sequence |
makeIndexedValue(SequenceIterator iter)
Create an indexed value
|
Expression |
optimizeForExpressionForStreaming(ForExpression expr)
In streaming mode, optimize a ForExpression for streaming.
|
Expression |
optimizeGeneralComparison(ExpressionVisitor visitor,
GeneralComparison gc,
boolean backwardsCompatible,
ContextItemStaticInfo contextItemType)
Optimize a GeneralComparison expression.
|
Expression |
optimizeNumberInstruction(NumberInstruction ni,
ContextItemStaticInfo contextInfo) |
Expression |
optimizeQuantifiedExpressionForStreaming(QuantifiedExpression expr)
In streaming mode, optimize a QuantifiedExpression for streaming.
|
Expression |
optimizeSaxonStreamFunction(ExpressionVisitor visitor,
ContextItemStaticInfo cisi,
Expression select)
Attempt to optimize a copy operation.
|
Expression |
promoteExpressionsToGlobal(Expression expr,
GlobalVariableManager globalVariableManager,
ExpressionVisitor visitor)
Identify expressions within a function or template body that can be promoted to be
evaluated as global variables.
|
Expression |
tryGeneralComparison(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType,
OrExpression orExpr)
Try to convert an Or expression into a comparison with Literal sequence
|
Expression |
tryIndexedFilter(FilterExpression f,
ExpressionVisitor visitor,
boolean indexFirstOperand,
boolean contextIsDoc)
Try converting a filter expression to a call on the key function.
|
Expression |
tryInlineFunctionCall(UserFunctionCall functionCall,
ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Replace a function call by the body of the function, assuming all conditions for inlining
the function are satisfied
|
Expression |
trySwitch(Choose choose,
ExpressionVisitor visitor)
Try to convert a Choose expression (or an XQuery 3.0 switch) into an optimized switch
|
getConfiguration, getOptimizerOptions, isOptionSet, isVariableReplaceableByDot, makeInversion, setOptimizerOptions, trace, trace
public OptimizerEE(Configuration config)
config
- the Saxon-EE configurationpublic Expression optimizeGeneralComparison(ExpressionVisitor visitor, GeneralComparison gc, boolean backwardsCompatible, ContextItemStaticInfo contextItemType)
optimizeGeneralComparison
in class Optimizer
visitor
- the expression visitorgc
- the GeneralComparison to be optimizedbackwardsCompatible
- true if in 1.0 compatibility modepublic Expression optimizeSaxonStreamFunction(ExpressionVisitor visitor, ContextItemStaticInfo cisi, Expression select) throws XPathException
optimizeSaxonStreamFunction
in class Optimizer
select
- the expression that selects the items to be copiedXPathException
public void makeCopyOperationsExplicit(Expression parent, Operand childOp) throws XPathException
makeCopyOperationsExplicit
in class Optimizer
parent
- The parent expression of the expression that is to be wrapped in an implicit copy-of.childOp
- The operand that is to be wrapped in an implicit copy-of, if it is suitable.XPathException
public void checkStreamability(XSLTemplate sourceTemplate, TemplateRule compiledTemplate) throws XPathException
checkStreamability
in class Optimizer
sourceTemplate
- the source of the template in the stylesheet treecompiledTemplate
- the compiled templateXPathException
- if the template is declared streamable but does not satisfy the straming rulespublic Expression optimizeForExpressionForStreaming(ForExpression expr) throws XPathException
optimizeForExpressionForStreaming
in class Optimizer
expr
- the expression to be optimizedXPathException
public Expression optimizeQuantifiedExpressionForStreaming(QuantifiedExpression expr) throws XPathException
optimizeQuantifiedExpressionForStreaming
in class Optimizer
expr
- the expression to be optimizedXPathException
public Expression convertPathExpressionToKey(SlashExpression pathExp, ExpressionVisitor visitor) throws XPathException
convertPathExpressionToKey
in class Optimizer
pathExp
- The path expression to be converted.visitor
- The expression visitorXPathException
public Expression tryIndexedFilter(FilterExpression f, ExpressionVisitor visitor, boolean indexFirstOperand, boolean contextIsDoc)
tryIndexedFilter
in class Optimizer
f
- the filter expression to be convertedvisitor
- the expression visitor, which must be currently visiting the filter expression findexFirstOperand
- true if the first operand of the filter comparison is to be indexed;contextIsDoc
- true if the context item is known to be a document nodepublic FilterExpression convertToFilterExpression(SlashExpression pathExp, TypeHierarchy th) throws XPathException
convertToFilterExpression
in class Optimizer
pathExp
- the path expression to be convertedth
- the type hierarchy cacheXPathException
public int isIndexableFilter(Expression filter)
isIndexableFilter
in class Optimizer
filter
- the predicate expressionpublic Sequence makeIndexedValue(SequenceIterator iter) throws XPathException
makeIndexedValue
in class Optimizer
iter
- the iterator that delivers the sequence of values to be indexedXPathException
public Sequence evaluateStreamingArgument(Expression expr, XPathContext context) throws XPathException
evaluateStreamingArgument
in class Optimizer
expr
- the expression supplied for the value of the streaming argumentcontext
- the XPath evaluation context of the callerXPathException
public Expression makeConditionalDocumentSorter(DocumentSorter sorter, SlashExpression path) throws XPathException
makeConditionalDocumentSorter
in class Optimizer
sorter
- an expression that sorts and deduplicates its operandpath
- the slash expression that is the operand of the sorterXPathException
public Expression tryInlineFunctionCall(UserFunctionCall functionCall, ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)
tryInlineFunctionCall
in class Optimizer
functionCall
- the functionCall expressionvisitor
- the expression visitorcontextItemType
- the static type of the context itempublic Expression trySwitch(Choose choose, ExpressionVisitor visitor)
public int gatherOrExpressions(int commonParts, ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, java.util.HashMap<Expression,java.util.List<Expression>> map, java.util.List<Expression> otherExps, Expression expr) throws XPathException
commonParts
- the number of common subexpressions found at this levelvisitor
- the expression visitorcontextItemType
- static information about the context item typemap
- a map to be populated with comparison expressions, keyed on the common
operandotherExps
- a list to be populated with expressions in the "or" tree that are
not comparison expressions, so they are retained "as is"expr
- the Or expression to be optimizedXPathException
- if an error occurspublic Expression tryGeneralComparison(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, OrExpression orExpr) throws XPathException
tryGeneralComparison
in class Optimizer
visitor
- the expression visitorcontextItemType
- static information about the context item typeorExpr
- the Choose expressionXPathException
public Expression promoteExpressionsToGlobal(Expression expr, GlobalVariableManager globalVariableManager, ExpressionVisitor visitor) throws XPathException
promoteExpressionsToGlobal
in class Optimizer
expr
- the expression; either this expression or any subexpression might be promotedvisitor
- the expression visitorXPathException
public Expression eliminateCommonSubexpressions(Expression in)
Optimizer
eliminateCommonSubexpressions
in class Optimizer
in
- the expression to be optimizedpublic Expression generateMultithreadedInstruction(Expression instruction)
generateMultithreadedInstruction
in class Optimizer
instruction
- the instruction to be multi-threadedpublic Expression compileToByteCode(ICompilerService compilerService, Expression expr, java.lang.String objectName, int evaluationMethods)
compileToByteCode
in class Optimizer
compilerService
- the compiler serviceexpr
- the expression to be compiledobjectName
- the name of the object to be compiled, used as a hint for the Java class/method nameevaluationMethods
- The evaluation modes for which code is generated. Currently a subset of
Expression.PROCESS_METHOD
, Expression.ITERATE_METHOD
. If no code is generated for
a given evaluation method, the fallback implementation from the superclass is used.public Expression makeByteCodeCandidate(ExpressionOwner owner, Expression expr, java.lang.String objectName, int requiredEvaluationModes)
makeByteCodeCandidate
in class Optimizer
owner
- the owning construct in the expression treeexpr
- the child (target) expressionobjectName
- name to be used in forming the name of the bytecode classrequiredEvaluationModes
- public void injectByteCodeCandidates(Expression expression) throws XPathException
injectByteCodeCandidates
in class Optimizer
XPathException
public Expression optimizeNumberInstruction(NumberInstruction ni, ContextItemStaticInfo contextInfo)
optimizeNumberInstruction
in class Optimizer
public void assessFunctionStreamability(XSLFunction sourceFunction, UserFunction compiledFunction) throws XPathException
assessFunctionStreamability
in class Optimizer
XPathException
- if the function is declared streamable but is not actually streamableCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.