Java Code Examples for org.objectweb.asm.Opcodes#AALOAD
The following examples show how to use
org.objectweb.asm.Opcodes#AALOAD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagedStrategyTransformer.java From lin-check with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void visitInsn(int opcode) { switch (opcode) { case Opcodes.AALOAD: case Opcodes.LALOAD: case Opcodes.FALOAD: case Opcodes.DALOAD: case Opcodes.IALOAD: invokeBeforeSharedVariableRead(); break; case Opcodes.AASTORE: case Opcodes.IASTORE: case Opcodes.LASTORE: case Opcodes.FASTORE: case Opcodes.DASTORE: invokeBeforeSharedVariableWrite(); break; } super.visitInsn(opcode); }
Example 2
Source File: HideAccessObfuscationTransformer.java From deobfuscator with Apache License 2.0 | 5 votes |
@Override public BasicValue binaryOperation(final AbstractInsnNode insn, final BasicValue value1, final BasicValue value2) throws AnalyzerException { if(insn.getOpcode() == Opcodes.AALOAD) return new BasicValue(value1.getType().getElementType()); return super.binaryOperation(insn, value1, value2); }
Example 3
Source File: InstructionAssembler.java From es6draft with MIT License | 5 votes |
public final void aload(Type type) { switch (type.getOpcode(Opcodes.IALOAD)) { case Opcodes.IALOAD: iaload(); return; case Opcodes.LALOAD: laload(); return; case Opcodes.FALOAD: faload(); return; case Opcodes.DALOAD: daload(); return; case Opcodes.AALOAD: aaload(); return; case Opcodes.BALOAD: baload(); return; case Opcodes.CALOAD: caload(); return; case Opcodes.SALOAD: saload(); return; default: throw new IllegalArgumentException(); } }
Example 4
Source File: StackHelper.java From zelixkiller with GNU General Public License v3.0 | 4 votes |
public InsnValue loadFromArray(AbstractInsnNode insn, InsnValue value1, InsnValue indexValue) throws AnalyzerException { Object indexObj = indexValue.getValue(), arrayObj = value1.getValue(); int index = indexObj == null ? -1 : ((Number) indexObj).intValue(); boolean arrayNotSimulated = arrayObj == null; Type t = arrayNotSimulated ? null : Type.getType(arrayObj.getClass()); switch (insn.getOpcode()) { case Opcodes.IALOAD: if (arrayNotSimulated) { return InsnValue.INT_VALUE; } // Sometimes Object[] contain values. Stringer obfuscator does this. // TODO: Have this sort of check for others? boolean oarr = t.equals(InsnValue.REFERENCE_ARR_VALUE.getType()); if (oarr) { int[] ia = (int[]) arrayObj; return InsnValue.intValue(ia[index]); }else{ Object[] obarr = (Object[]) arrayObj; Object o = obarr[index]; if (o == null){ return InsnValue.INT_VALUE; } return InsnValue.intValue(((Number) o).intValue()); } case Opcodes.LALOAD: if (arrayNotSimulated) { return InsnValue.LONG_VALUE; } long[] la = (long[]) arrayObj; return InsnValue.longValue(la[index]); case Opcodes.FALOAD: if (arrayNotSimulated) { return InsnValue.FLOAT_VALUE; } float[] fa = (float[]) arrayObj; return InsnValue.floatValue(fa[index]); case Opcodes.DALOAD: if (arrayNotSimulated) { return InsnValue.DOUBLE_VALUE; } double[] da = (double[]) arrayObj; return InsnValue.doubleValue(da[index]); case Opcodes.AALOAD: // TODO: Check if it's an object array, but the contents aren't objects return InsnValue.REFERENCE_VALUE; case Opcodes.BALOAD: if (arrayNotSimulated) { return InsnValue.BYTE_VALUE; } boolean db = t.equals(InsnValue.DOUBLE_ARR_VALUE.getType()), in = t.equals(InsnValue.INT_ARR_VALUE.getType()), saa = t.equals(InsnValue.SHORT_ARR_VALUE.getType()); if (db) { double[] dba = (double[]) arrayObj; return InsnValue.intValue(dba[index]); } else if (in) { int[] ina = (int[]) arrayObj; return InsnValue.intValue(ina[index]); } else if (saa){ short[] saaa = (short[]) arrayObj; return InsnValue.intValue(saaa[index]); } else { System.err.println("UNKNOWN TYPE BALOAD: " + t); throw new RuntimeException(); } case Opcodes.CALOAD: if (arrayNotSimulated) { return InsnValue.CHAR_VALUE; } char[] ca = (char[]) arrayObj; return InsnValue.charValue(ca[index]); case Opcodes.SALOAD: if (arrayNotSimulated) { return InsnValue.SHORT_VALUE; } short[] sa = (short[]) arrayObj; return InsnValue.intValue((short) sa[index]); } return null; }
Example 5
Source File: AllocationMethodAdapter.java From allocation-instrumenter with Apache License 2.0 | 4 votes |
void calculateArrayLengthAndDispatch(String typeName, int dimCount) { // Since the dimensions of the array are not known at instrumentation // time, we take the created multi-dimensional array and peel off nesting // levels from the left. For each nesting layer we probe the array length // and accumulate a partial product which we can then feed the recording // function. // below we note the partial product of dimensions 1 to X-1 as productToX // (so productTo1 == 1 == no dimensions yet). We denote by aref0 the // array reference at the current nesting level (the containing aref's [0] // element). If we hit a level whose arraylength is 0 or whose // reference is null, there's no point continuing, so we shortcut // out. // This approach works pretty well when you create a new array with the // newarray bytecodes. You can also create a new array by cloning an // existing array; an existing multidimensional array might have had some // of its [0] elements nulled out. We currently deal with this by bailing // out, but arguably we should do something more principled (like calculate // the size of the multidimensional array from scratch if you are using // clone()). // TODO(java-platform-team): Do something about modified multidimensional // arrays and clone(). Label zeroDimension = new Label(); super.visitInsn(Opcodes.DUP); // -> stack: ... origaref aref0 super.visitLdcInsn(1); // -> stack: ... origaref aref0 productTo1 for (int i = 0; i < dimCount; ++i) { // pre: stack: ... origaref aref0 productToI super.visitInsn(Opcodes.SWAP); // -> stack: ... origaref productToI aref super.visitInsn(Opcodes.DUP); Label nonNullDimension = new Label(); // -> stack: ... origaref productToI aref aref super.visitJumpInsn(Opcodes.IFNONNULL, nonNullDimension); // -> stack: ... origaref productToI aref super.visitInsn(Opcodes.SWAP); // -> stack: ... origaref aref productToI super.visitJumpInsn(Opcodes.GOTO, zeroDimension); super.visitLabel(nonNullDimension); // -> stack: ... origaref productToI aref super.visitInsn(Opcodes.DUP_X1); // -> stack: ... origaref aref0 productToI aref super.visitInsn(Opcodes.ARRAYLENGTH); // -> stack: ... origaref aref0 productToI dimI Label nonZeroDimension = new Label(); super.visitInsn(Opcodes.DUP); // -> stack: ... origaref aref0 productToI dimI dimI super.visitJumpInsn(Opcodes.IFNE, nonZeroDimension); // -> stack: ... origaref aref0 productToI dimI super.visitInsn(Opcodes.POP); // -> stack: ... origaref aref0 productToI super.visitJumpInsn(Opcodes.GOTO, zeroDimension); super.visitLabel(nonZeroDimension); // -> stack: ... origaref aref0 productToI max(dimI,1) super.visitInsn(Opcodes.IMUL); // -> stack: ... origaref aref0 productTo{I+1} if (i < dimCount - 1) { super.visitInsn(Opcodes.SWAP); // -> stack: ... origaref productTo{I+1} aref0 super.visitInsn(Opcodes.ICONST_0); // -> stack: ... origaref productTo{I+1} aref0 0 super.visitInsn(Opcodes.AALOAD); // -> stack: ... origaref productTo{I+1} aref0' super.visitInsn(Opcodes.SWAP); } // post: stack: ... origaref aref0 productTo{I+1} } super.visitLabel(zeroDimension); super.visitInsn(Opcodes.SWAP); // -> stack: ... origaref product aref0 super.visitInsn(Opcodes.POP); // -> stack: ... origaref product super.visitInsn(Opcodes.SWAP); // -> stack: ... product origaref invokeRecordAllocation(typeName); }
Example 6
Source File: ArrayLoadExpression.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static int tryReduce(List<Instruction> instructions, int index) { Instruction instr = instructions.get(index); switch (instr.getOpcode()) { case Opcodes.AALOAD: case Opcodes.FALOAD: case Opcodes.CALOAD: case Opcodes.DALOAD: case Opcodes.BALOAD: case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.SALOAD: break; default: return -1; } if (index < 2) { return -1; } Instruction indexInstr = instructions.get(index-1); if (!(indexInstr instanceof AssignableExpression)) { return -1; } Instruction arrInstr = instructions.get(index-2); if (!(arrInstr instanceof AssignableExpression)) { return -1; } ArrayLoadExpression out = new ArrayLoadExpression(); out.loadInstruction = instr; out.indexInstruction = indexInstr; out.targetArrayInstruction = arrInstr; instructions.remove(index-2); instructions.remove(index-2); instructions.remove(index-2); instructions.add(index-2, out); return index-2; }