use of org.mvel2.asm.Label in project mvel by mvel.
the class GeneratorAdapter method catchException.
/**
* Marks the start of an exception handler.
*
* @param start
* beginning of the exception handler's scope (inclusive).
* @param end
* end of the exception handler's scope (exclusive).
* @param exception
* internal name of the type of exceptions handled by the
* handler.
*/
public void catchException(final Label start, final Label end, final Type exception) {
Label doCatch = new Label();
if (exception == null) {
mv.visitTryCatchBlock(start, end, doCatch, null);
} else {
mv.visitTryCatchBlock(start, end, doCatch, exception.getInternalName());
}
mark(doCatch);
}
use of org.mvel2.asm.Label in project mvel by mikebrock.
the class ASMAccessorOptimizer method _finishJIT.
private void _finishJIT() {
if (deferFinish) {
return;
}
if (returnType != null && returnType.isPrimitive()) {
// noinspection unchecked
wrapPrimitive(returnType);
}
if (returnType == void.class) {
assert debug("ACONST_NULL");
mv.visitInsn(ACONST_NULL);
}
assert debug("ARETURN");
mv.visitInsn(ARETURN);
assert debug("\n{METHOD STATS (maxstack=" + stacksize + ")}\n");
// dump advanced debugging if necessary
dumpAdvancedDebugging();
mv.visitMaxs(stacksize, maxlocals);
mv.visitEnd();
mv = cw.visitMethod(ACC_PUBLIC, "getKnownEgressType", "()Ljava/lang/Class;", null, null);
mv.visitCode();
mv.visitLdcInsn(org.mvel2.asm.Type.getType(returnType != null ? returnType : Object.class));
mv.visitInsn(ARETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
if (propNull) {
cw.visitField(ACC_PUBLIC, "nullPropertyHandler", "L" + NAMESPACE + "integration/PropertyHandler;", null, null).visitEnd();
}
if (methNull) {
cw.visitField(ACC_PUBLIC, "nullMethodHandler", "L" + NAMESPACE + "integration/PropertyHandler;", null, null).visitEnd();
}
buildInputs();
if (buildLog != null && buildLog.length() != 0 && expr != null) {
mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLdcInsn(buildLog.toString() + "\n\n## { " + new String(expr) + " }");
mv.visitInsn(ARETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
cw.visitEnd();
}
use of org.mvel2.asm.Label in project mvel by mikebrock.
the class ASMAccessorOptimizer method writeFunctionPointerStub.
private void writeFunctionPointerStub(Class c, Method m) {
ldcClassConstant(c);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getMethods", "()[Ljava/lang/reflect/Method;");
mv.visitVarInsn(ASTORE, 7);
mv.visitInsn(ICONST_0);
mv.visitVarInsn(ISTORE, 5);
mv.visitVarInsn(ALOAD, 7);
mv.visitInsn(ARRAYLENGTH);
mv.visitVarInsn(ISTORE, 6);
Label l1 = new Label();
mv.visitJumpInsn(GOTO, l1);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitVarInsn(ALOAD, 7);
mv.visitVarInsn(ILOAD, 5);
mv.visitInsn(AALOAD);
mv.visitVarInsn(ASTORE, 4);
Label l3 = new Label();
mv.visitLabel(l3);
mv.visitLdcInsn(m.getName());
mv.visitVarInsn(ALOAD, 4);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Method", "getName", "()Ljava/lang/String;");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z");
Label l4 = new Label();
mv.visitJumpInsn(IFEQ, l4);
Label l5 = new Label();
mv.visitLabel(l5);
mv.visitVarInsn(ALOAD, 4);
mv.visitInsn(ARETURN);
mv.visitLabel(l4);
mv.visitIincInsn(5, 1);
mv.visitLabel(l1);
mv.visitVarInsn(ILOAD, 5);
mv.visitVarInsn(ILOAD, 6);
mv.visitJumpInsn(IF_ICMPLT, l2);
Label l6 = new Label();
mv.visitLabel(l6);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
// deferFinish = true;
}
use of org.mvel2.asm.Label in project mvel by mikebrock.
the class ASMAccessorOptimizer method ldcClassConstant.
private void ldcClassConstant(Class cls) {
if (OPCODES_VERSION == Opcodes.V1_4) {
assert debug("LDC \"" + cls.getName() + "\"");
mv.visitLdcInsn(cls.getName());
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;");
Label l4 = new Label();
mv.visitJumpInsn(GOTO, l4);
mv.visitTypeInsn(NEW, "java/lang/NoClassDefFoundError");
mv.visitInsn(DUP_X1);
mv.visitInsn(SWAP);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "getMessage", "()Ljava/lang/String;");
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/NoClassDefFoundError", "<init>", "(Ljava/lang/String;)V");
mv.visitInsn(ATHROW);
mv.visitLabel(l4);
} else {
assert debug("LDC " + getType(cls));
mv.visitLdcInsn(getType(cls));
}
}
use of org.mvel2.asm.Label in project mvel by mikebrock.
the class ASMAccessorOptimizer method writeOutNullHandler.
private void writeOutNullHandler(Member member, int type) {
assert debug("DUP");
mv.visitInsn(DUP);
Label j = new Label();
assert debug("IFNONNULL : jump");
mv.visitJumpInsn(IFNONNULL, j);
assert debug("POP");
mv.visitInsn(POP);
assert debug("ALOAD 0");
mv.visitVarInsn(ALOAD, 0);
if (type == 0) {
this.propNull = true;
assert debug("GETFIELD 'nullPropertyHandler'");
mv.visitFieldInsn(GETFIELD, className, "nullPropertyHandler", "L" + NAMESPACE + "integration/PropertyHandler;");
} else {
this.methNull = true;
assert debug("GETFIELD 'nullMethodHandler'");
mv.visitFieldInsn(GETFIELD, className, "nullMethodHandler", "L" + NAMESPACE + "integration/PropertyHandler;");
}
assert debug("LDC '" + member.getName() + "'");
mv.visitLdcInsn(member.getName());
assert debug("ALOAD 1");
mv.visitVarInsn(ALOAD, 1);
assert debug("ALOAD 3");
mv.visitVarInsn(ALOAD, 3);
assert debug("INVOKEINTERFACE PropertyHandler.getProperty");
mv.visitMethodInsn(INVOKEINTERFACE, NAMESPACE + "integration/PropertyHandler", "getProperty", "(Ljava/lang/String;Ljava/lang/Object;L" + NAMESPACE + "integration/VariableResolverFactory;)Ljava/lang/Object;");
assert debug("LABEL:jump");
mv.visitLabel(j);
}
Aggregations