use of org.objectweb.asm.tree.analysis.BasicValue in project drill by apache.
the class InstructionModifier method getFunctionReturn.
/**
* Get the value of a function return if it is a ReplacingBasicValue.
*
* <p>Assumes that we're in the middle of processing an INVOKExxx instruction.
*
* @return the value that will be on the top of the stack after the function returns
*/
private ReplacingBasicValue getFunctionReturn() {
final Frame<BasicValue> nextFrame = list.nextFrame;
final BasicValue basicValue = nextFrame.getStack(nextFrame.getStackSize() - 1);
return filterReplacement(basicValue);
}
use of org.objectweb.asm.tree.analysis.BasicValue in project drill by apache.
the class ReplacingInterpreter method naryOperation.
@Override
public BasicValue naryOperation(final AbstractInsnNode insn, final List<? extends BasicValue> values) throws AnalyzerException {
if (insn instanceof MethodInsnNode) {
boolean skipOne = insn.getOpcode() != Opcodes.INVOKESTATIC;
// Note if the argument is a holder, and is used as a function argument
for (BasicValue value : values) {
// if non-static method, skip over the receiver
if (skipOne) {
skipOne = false;
continue;
}
if (value instanceof ReplacingBasicValue) {
final ReplacingBasicValue argument = (ReplacingBasicValue) value;
argument.setFunctionArgument();
}
}
}
return super.naryOperation(insn, values);
}
use of org.objectweb.asm.tree.analysis.BasicValue in project drill by apache.
the class ScalarReplacementNode method visitEnd.
@Override
public void visitEnd() {
/*
* Note this is a MethodNode, not a MethodVisitor. As a result, calls to the various visitX()
* methods will be building up a method. Then, once we analyze it, we use accept() to visit that
* method and transform it with the InstructionModifier at the bottom.
*/
super.visitEnd();
final LinkedList<ReplacingBasicValue> valueList = new LinkedList<>();
final MethodAnalyzer<BasicValue> analyzer = new MethodAnalyzer<BasicValue>(new ReplacingInterpreter(className, valueList));
Frame<BasicValue>[] frames;
try {
frames = analyzer.analyze(className, this);
} catch (final AnalyzerException e) {
throw new IllegalStateException(e);
}
if (logger.isTraceEnabled()) {
final StringBuilder sb = new StringBuilder();
sb.append("ReplacingBasicValues for " + className + "\n");
for (final ReplacingBasicValue value : valueList) {
value.dump(sb, 2);
sb.append('\n');
}
logger.debug(sb.toString());
}
// wrap the instruction handler so that we can do additional things
final TrackingInstructionList list = new TrackingInstructionList(frames, this.instructions);
this.instructions = list;
MethodVisitor methodVisitor = inner;
if (verifyBytecode) {
methodVisitor = new CheckMethodVisitorFsm(CompilationConfig.ASM_API_VERSION, methodVisitor);
}
final InstructionModifier holderV = new InstructionModifier(this.access, this.name, this.desc, this.signature, this.exceptionsArr, list, methodVisitor);
accept(holderV);
}
Aggregations