use of org.objectweb.asm.MethodVisitor in project groovy by apache.
the class InvocationWriter method finnishConstructorCall.
protected void finnishConstructorCall(ConstructorNode cn, String ownerDescriptor, int argsToRemove) {
String desc = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, cn.getParameters());
MethodVisitor mv = controller.getMethodVisitor();
mv.visitMethodInsn(INVOKESPECIAL, ownerDescriptor, "<init>", desc, false);
controller.getOperandStack().remove(argsToRemove);
controller.getOperandStack().push(cn.getDeclaringClass());
}
use of org.objectweb.asm.MethodVisitor in project groovy by apache.
the class InvocationWriter method coerce.
public void coerce(ClassNode from, ClassNode target) {
if (from.isDerivedFrom(target))
return;
MethodVisitor mv = controller.getMethodVisitor();
OperandStack os = controller.getOperandStack();
os.box();
(new ClassExpression(target)).visit(controller.getAcg());
os.remove(1);
asTypeMethod.call(mv);
BytecodeHelper.doCast(mv, target);
os.replace(target);
}
use of org.objectweb.asm.MethodVisitor in project groovy by apache.
the class OperandStack method load.
public void load(ClassNode type, int idx) {
MethodVisitor mv = controller.getMethodVisitor();
BytecodeHelper.load(mv, type, idx);
push(type);
}
use of org.objectweb.asm.MethodVisitor in project groovy by apache.
the class OptimizingStatementWriter method writeFastPathPrelude.
private void writeFastPathPrelude(FastPathData meta) {
MethodVisitor mv = controller.getMethodVisitor();
mv.visitJumpInsn(GOTO, meta.afterPath);
mv.visitLabel(meta.pathStart);
controller.switchToFastPath();
}
use of org.objectweb.asm.MethodVisitor in project groovy by apache.
the class OptimizingStatementWriter method writeGuards.
private FastPathData writeGuards(StatementMeta meta, Statement statement) {
if (notEnableFastPath(meta))
return null;
controller.getAcg().onLineNumber(statement, null);
MethodVisitor mv = controller.getMethodVisitor();
FastPathData fastPathData = new FastPathData();
Label slowPath = new Label();
for (int i = 0; i < guards.length; i++) {
if (meta.involvedTypes[i]) {
guards[i].call(mv);
mv.visitJumpInsn(IFEQ, slowPath);
}
}
// meta class check with boolean holder
String owner = BytecodeHelper.getClassInternalName(controller.getClassNode());
MethodNode mn = controller.getMethodNode();
if (mn != null) {
mv.visitFieldInsn(GETSTATIC, owner, Verifier.STATIC_METACLASS_BOOL, "Z");
mv.visitJumpInsn(IFNE, slowPath);
}
//standard metaclass check
disabledStandardMetaClass.call(mv);
mv.visitJumpInsn(IFNE, slowPath);
// other guards here
mv.visitJumpInsn(GOTO, fastPathData.pathStart);
mv.visitLabel(slowPath);
return fastPathData;
}
Aggregations