Package org.mvel2.optimizers.impl.asm
Class ASMAccessorOptimizer
java.lang.Object
org.mvel2.compiler.AbstractParser
org.mvel2.optimizers.AbstractOptimizer
org.mvel2.optimizers.impl.asm.ASMAccessorOptimizer
- All Implemented Interfaces:
Serializable
,Parser
,AccessorOptimizer
Implementation of the MVEL Just-in-Time (JIT) compiler for Property Accessors using the ASM bytecode
engineering library.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private StringAppender
private static MVELClassLoader
private String
private int
private ArrayList
<ExecutableStatement> private Object
private org.objectweb.asm.ClassWriter
private boolean
private static final Object[]
private static final Class[]
private boolean
private Class
private static final int
private static String
private boolean
private static final int
private static final String
private int
private boolean
private org.objectweb.asm.MethodVisitor
private static String
private boolean
private static final int
private boolean
private Class
private int
private Object
private long
private Object
private static final int
private VariableResolverFactory
Fields inherited from class org.mvel2.optimizers.AbstractOptimizer
BEAN, COL, collection, currType, METH, nullSafe, staticAccess, tkStart, WITH
Fields inherited from class org.mvel2.compiler.AbstractParser
CLASS_LITERALS, compileMode, cursor, debugSymbols, dStack, end, expr, fields, GET, GET_OR_CREATE, greedy, lastLineStart, lastNode, lastWasComment, lastWasIdentifier, lastWasLineLabel, length, LEVEL_0_PROPERTY_ONLY, LEVEL_1_BASIC_LANG, LEVEL_2_MULTI_STATEMENT, LEVEL_3_ITERATION, LEVEL_4_ASSIGNMENT, LEVEL_5_CONTROL_FLOW, line, literalOnly, LITERALS, OP_CONTINUE, OP_NOT_LITERAL, OP_OVERFLOW, OP_RESET_FRAME, OP_TERMINATE, OPERATORS, pCtx, REMOVE, SET, splitAccumulator, st, start, stk
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ASMAccessorOptimizer
(org.objectweb.asm.ClassWriter cw, org.objectweb.asm.MethodVisitor mv, ArrayList<ExecutableStatement> compiledInputs, String className, StringAppender buildLog, int compileDepth) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private int
_getAccessor
(Object o, Class type) private Accessor
private void
_initJIT()
Does all the boilerplate for initiating the JIT.private void
private void
addPrintOut
(String text) private Object
private void
anyArrayCheck
(Class cls) void
arrayStore
(Class cls) private void
private void
private Accessor
private void
createArray
(Class componentType, int length) Create an array of any type (primitive or reference)private void
dataConversion
(Class target) private boolean
private void
private Object
getBeanProperty
(Object ctx, String property) private Object
getBeanPropertyAO
(Object ctx, String property) private Object
getCollectionProperty
(Object ctx, String prop) private Object
getCollectionPropertyAO
(Object ctx, String prop) private Object
static MVELClassLoader
getName()
private Object
getWithProperty
(Object ctx) private Class
getWrapperClass
(Class cls) void
init()
private void
intPush
(int index) boolean
private void
ldcClassConstant
(Class cls) private Class
private void
loadField
(int number) private void
loadVariableByIndex
(int pos) private void
loadVariableByName
(String name) optimizeAccessor
(ParserContext pCtx, char[] property, int start, int offset, Object staticContext, Object thisRef, VariableResolverFactory factory, boolean root, Class ingressType) optimizeCollection
(ParserContext pCtx, Object o, Class type, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory) private Object
optimizeFieldMethodProperty
(Object ctx, String property, Class<?> cls, Member member) optimizeObjectCreation
(ParserContext pCtx, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory) optimizeSetAccessor
(ParserContext pCtx, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory, boolean rootThisRef, Object value, Class ingressType) private Object
propHandlerByteCode
(String property, Object ctx, Class handler) private void
propHandlerByteCodePut
(String property, Object ctx, Class handler, Object value) static void
static int
toPrimitiveTypeOperand
(Class<?> c) Gets the ASM instruction operand for the given primitive type.private void
unwrapPrimitive
(Class cls) private void
visitConstantClass
(Class<?> clazz) private void
wrapPrimitive
(Class<? extends Object> cls) void
wrapRuntimeConverstion
(Class toType) private void
private Class
private Class
writeLiteralOrSubexpression
(Object stmt, Class desiredTarget) private Class
writeLiteralOrSubexpression
(Object stmt, Class desiredTarget, Class knownIngressType) private void
private void
writeOutNullHandler
(Member member, int type) Methods inherited from class org.mvel2.optimizers.AbstractOptimizer
capture, findLastUnion, nextSubToken, scanTo, tryStaticAccess, whiteSpaceSkip
Methods inherited from class org.mvel2.compiler.AbstractParser
addFatalError, addFatalError, arithmeticFunctionReduction, captureIdentifier, captureToEOS, captureToEOSorEOL, captureToEOT, captureToNextTokenJunction, expectEOS, expectNextChar_IW, getCursor, getExpression, handleSubstatement, handleUnion, ifThenElseBlockContinues, incNextNonBlank, isArithmeticOperator, isNextIdentifier, isNextIdentifierOrLiteral, isStatementNotManuallyTerminated, lastNonWhite, loadLanguageFeaturesByLevel, lookAhead, lookAhead, lookBehind, lookToLast, nextNonBlank, nextToken, nextTokenSkipSymbols, reduce, setExpression, setExpression, setLanguageLevel, setupParser, skipWhitespace, tokenContinues, trimLeft, trimRight, trimWhitespace
-
Field Details
-
MAP_IMPL
- See Also:
-
LIST_IMPL
-
NAMESPACE
-
OPCODES_VERSION
private static final int OPCODES_VERSION -
ctx
-
thisRef
-
variableFactory
-
EMPTYARG
-
EMPTYCLS
-
first
private boolean first -
noinit
private boolean noinit -
deferFinish
private boolean deferFinish -
literal
private boolean literal -
propNull
private boolean propNull -
methNull
private boolean methNull -
className
-
cw
private org.objectweb.asm.ClassWriter cw -
mv
private org.objectweb.asm.MethodVisitor mv -
val
-
stacksize
private int stacksize -
maxlocals
private int maxlocals -
time
private long time -
compiledInputs
-
ingressType
-
returnType
-
compileDepth
private int compileDepth -
buildLog
-
classLoader
-
ARRAY
private static final int ARRAY- See Also:
-
LIST
private static final int LIST- See Also:
-
MAP
private static final int MAP- See Also:
-
VAL
private static final int VAL- See Also:
-
-
Constructor Details
-
ASMAccessorOptimizer
public ASMAccessorOptimizer() -
ASMAccessorOptimizer
private ASMAccessorOptimizer(org.objectweb.asm.ClassWriter cw, org.objectweb.asm.MethodVisitor mv, ArrayList<ExecutableStatement> compiledInputs, String className, StringAppender buildLog, int compileDepth)
-
-
Method Details
-
_initJIT
private void _initJIT()Does all the boilerplate for initiating the JIT. -
_initJIT2
private void _initJIT2() -
optimizeAccessor
public Accessor optimizeAccessor(ParserContext pCtx, char[] property, int start, int offset, Object staticContext, Object thisRef, VariableResolverFactory factory, boolean root, Class ingressType) - Specified by:
optimizeAccessor
in interfaceAccessorOptimizer
-
optimizeSetAccessor
public Accessor optimizeSetAccessor(ParserContext pCtx, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory, boolean rootThisRef, Object value, Class ingressType) - Specified by:
optimizeSetAccessor
in interfaceAccessorOptimizer
-
_finishJIT
private void _finishJIT() -
visitConstantClass
-
_initializeAccessor
- Throws:
Exception
-
compileAccessor
-
getWithProperty
-
getBeanPropertyAO
private Object getBeanPropertyAO(Object ctx, String property) throws IllegalAccessException, InvocationTargetException -
getBeanProperty
private Object getBeanProperty(Object ctx, String property) throws IllegalAccessException, InvocationTargetException -
optimizeFieldMethodProperty
private Object optimizeFieldMethodProperty(Object ctx, String property, Class<?> cls, Member member) throws IllegalAccessException - Throws:
IllegalAccessException
-
writeFunctionPointerStub
-
getCollectionProperty
private Object getCollectionProperty(Object ctx, String prop) throws IllegalAccessException, InvocationTargetException -
getCollectionPropertyAO
private Object getCollectionPropertyAO(Object ctx, String prop) throws IllegalAccessException, InvocationTargetException -
getMethod
private Object getMethod(Object ctx, String name) throws IllegalAccessException, InvocationTargetException -
dataConversion
-
setMVELClassLoader
-
getMVELClassLoader
-
init
public void init()- Specified by:
init
in interfaceAccessorOptimizer
-
getContextClassLoader
-
loadClass
- Throws:
Exception
-
debug
-
getName
-
getResultOptPass
- Specified by:
getResultOptPass
in interfaceAccessorOptimizer
-
getWrapperClass
-
unwrapPrimitive
-
wrapPrimitive
-
anyArrayCheck
-
writeOutLiteralWrapped
-
toPrimitiveTypeOperand
Gets the ASM instruction operand for the given primitive type. Will throw IllegalStateException if the type is not primitive.- Parameters:
c
- The class representing the primitive type.- Returns:
- The operand
-
createArray
Create an array of any type (primitive or reference)- Parameters:
componentType
- The type of array elementslength
- The length of the array
-
arrayStore
-
wrapRuntimeConverstion
-
addSubstatement
-
loadVariableByName
-
loadVariableByIndex
private void loadVariableByIndex(int pos) -
loadField
private void loadField(int number) -
ldcClassConstant
-
buildInputs
private void buildInputs() -
_getAccessor
-
writeLiteralOrSubexpression
-
writeLiteralOrSubexpression
-
writeLiteralOrSubexpression
-
addPrintOut
-
optimizeCollection
public Accessor optimizeCollection(ParserContext pCtx, Object o, Class type, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory) - Specified by:
optimizeCollection
in interfaceAccessorOptimizer
-
checkcast
-
intPush
private void intPush(int index) -
optimizeObjectCreation
public Accessor optimizeObjectCreation(ParserContext pCtx, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory) - Specified by:
optimizeObjectCreation
in interfaceAccessorOptimizer
-
getEgressType
- Specified by:
getEgressType
in interfaceAccessorOptimizer
-
dumpAdvancedDebugging
private void dumpAdvancedDebugging() -
propHandlerByteCode
-
propHandlerByteCodePut
-
writeOutNullHandler
-
isLiteralOnly
public boolean isLiteralOnly()- Specified by:
isLiteralOnly
in interfaceAccessorOptimizer
-