use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class Union method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
if (accessor != null) {
return accessor.getValue(main.getReducedValueAccelerated(ctx, thisValue, factory), thisValue, factory);
} else {
try {
AccessorOptimizer o = OptimizerFactory.getThreadAccessorOptimizer();
accessor = o.optimizeAccessor(getCurrentThreadParserContext(), expr, start, offset, main.getReducedValueAccelerated(ctx, thisValue, factory), thisValue, factory, false, main.getEgressType());
return o.getResultOptPass();
} finally {
OptimizerFactory.clearThreadAccessorOptimizer();
}
}
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class LiteralDeepPropertyNode method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
if (accessor != null) {
return accessor.getValue(literal, thisValue, factory);
} else {
try {
AccessorOptimizer aO = getThreadAccessorOptimizer();
accessor = aO.optimizeAccessor(getCurrentThreadParserContext(), expr, start, offset, literal, thisValue, factory, false, null);
return aO.getResultOptPass();
} finally {
OptimizerFactory.clearThreadAccessorOptimizer();
}
}
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class OptimizerFactory method setDefaultOptimizer.
public static void setDefaultOptimizer(String name) {
try {
//noinspection unchecked
AccessorOptimizer ao = accessorCompilers.get(defaultOptimizer = name);
ao.init();
setThreadAccessorOptimizer(ao.getClass());
} catch (Exception e) {
throw new RuntimeException("unable to instantiate accessor compiler", e);
}
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class DynamicSetAccessor method optimize.
private Object optimize(Object ctx, Object elCtx, VariableResolverFactory variableResolverFactory, Object value) {
if (DynamicOptimizer.isOverloaded()) {
DynamicOptimizer.enforceTenureLimit();
}
AccessorOptimizer ao = OptimizerFactory.getAccessorCompiler("ASM");
_accessor = ao.optimizeSetAccessor(context, property, start, offset, ctx, elCtx, variableResolverFactory, false, value, value != null ? value.getClass() : Object.class);
assert _accessor != null;
return value;
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class ASTNode method optimize.
private Object optimize(Object ctx, Object thisValue, VariableResolverFactory factory) {
if ((fields & DEOP) != 0) {
fields ^= DEOP;
}
AccessorOptimizer optimizer;
Object retVal = null;
if ((fields & NOJIT) != 0 || factory != null && factory.isResolveable(nameCache)) {
optimizer = getAccessorCompiler(SAFE_REFLECTIVE);
} else {
optimizer = getDefaultAccessorCompiler();
}
ParserContext pCtx;
if ((fields & PCTX_STORED) != 0) {
pCtx = (ParserContext) literal;
} else {
pCtx = new ParserContext(new ParserConfiguration(getInjectedImports(factory), null));
}
try {
pCtx.optimizationNotify();
setAccessor(optimizer.optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, egressType));
} catch (OptimizationNotSupported ne) {
setAccessor((optimizer = getAccessorCompiler(SAFE_REFLECTIVE)).optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, null));
}
if (accessor == null) {
return get(expr, start, offset, ctx, factory, thisValue);
}
if (retVal == null) {
retVal = optimizer.getResultOptPass();
}
if (egressType == null) {
egressType = optimizer.getEgressType();
}
return retVal;
}
Aggregations