Package alt.jiapi.reflect

Examples of alt.jiapi.reflect.Instruction


     */
    public HotSpot[] getHotSpots() {
        ArrayList al = new ArrayList();

        for (int i = 0; i < il.size(); i++) {
            Instruction ins = il.get(i);
            short opCode = ins.getOpcode();

            for (int j = 0; j < opCodes.length; j++) {
                if (opCode == opCodes[j]) {
                    HotSpot hs = createHotSpot(il, i);
//                     if (rule.match(hs.getName()))
View Full Code Here


     *
     * @param il InstructionList
     * @param idx hotspot Instruction.
     */
    private HotSpot createHotSpot(InstructionList il, int idx) {
        Instruction end = il.get(idx);
        Instruction start = end;

        int stackConsumption = end.stackConsumption();
        while(stackConsumption > 0) {
            start = il.get(idx - 1); // Previous instruction
            stackConsumption -= start.stackUsage();
            idx--;
        }

        return new HotSpot(il, start, end);
    }
View Full Code Here

        exitList.add(factory.invoke(methodExited));

        // Find all method exits
        int idx = il.indexOf(OpcodeGroups.RETURN_INSTRUCTIONS, 0);
        while (idx != -1) {
            Instruction ins = il.get(idx);
            il.insert(idx, exitList);

            // Next index. Skip Instructions created above.
            idx = il.indexOf(OpcodeGroups.RETURN_INSTRUCTIONS,
                             idx + exitList.size() + 1);
View Full Code Here

                // of the code.

//                 targetCode = il.createEmptyList();
                if (true)
                    throw new RuntimeException("NOT IMPLEMENTED");
                Instruction i = il.get(0);
               

                int lvIdx = -1;
                switch(i.getOpcode()) {
                case Opcodes.ASTORE:
                    // throws NullPointerException
                    //lvIdx = Integer.parseInt(i.getOperand().toString());
                    lvIdx = -1; // Force failure
                    break;
View Full Code Here

    public void checkForBranchTarget(Instruction firstHotSpotInstruction,
             InstructionList methodList,
             Instruction firstBeforeInstruction) {
  for (int idx = 0; idx < methodList.size(); idx++) {
      Instruction i = (Instruction)methodList.get(idx);

      if (i instanceof BranchInstruction) {
    BranchInstruction bi = (BranchInstruction)i;
    if (bi.getTarget() == firstHotSpotInstruction) {
        bi.setTarget(firstBeforeInstruction);
View Full Code Here

         * Actual copying of instructions to hotspot.
         */
        private void copyInstructions(HotSpot hs) {
            InstructionList am_il = adviceMethod.getInstructionList();
            InstructionList il = hs.getInstructionList();
      Instruction firstHotSpotInstruction = il.get(0);

            //
            // NOTE: We must handle local variables correctly
            // NOTE: should be done in InstructionList.add/insert(Instruction)
            am_il = changeLocalVars(am_il, il.getDeclaringMethod().getMaxLocals()-1);
View Full Code Here

           
            InstructionList newList = new InstructionList();
           
            InstructionFactory factory = new InstructionFactory();
            for(int i = 0; i < advice.size(); i++) {
                Instruction ins = advice.get(i);
                newList.add(ins);
                switch(ins.getOpcode()) {
                    // -- ALOAD family --------------------------------------
                    case Opcodes.ALOAD_0:
                        newList.replace(i, factory.aload(maxLocalsInOtherList));
                        break;
                    case Opcodes.ALOAD_1:
                        newList.replace(i, factory.aload(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.ALOAD_2:
                        newList.replace(i, factory.aload(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.ALOAD_3:
                        newList.replace(i, factory.aload(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.ALOAD:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                    case Opcodes.ASTORE_0:
                        newList.replace(i, factory.astore(maxLocalsInOtherList));
                        break;
                    case Opcodes.ASTORE_1:
                        newList.replace(i, factory.astore(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.ASTORE_2:
                        newList.replace(i, factory.astore(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.ASTORE_3:
                        newList.replace(i, factory.astore(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.ASTORE:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;

                    // -- ILOAD family --------------------------------------
                    case Opcodes.ILOAD_0:
                        newList.replace(i, factory.iload(maxLocalsInOtherList));
                        break;
                    case Opcodes.ILOAD_1:
                        newList.replace(i, factory.iload(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.ILOAD_2:
                        newList.replace(i, factory.iload(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.ILOAD_3:
                        newList.replace(i, factory.iload(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.ILOAD:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                    case Opcodes.ISTORE_0:
                        newList.replace(i, factory.istore(maxLocalsInOtherList));
                        break;
                    case Opcodes.ISTORE_1:
                        newList.replace(i, factory.istore(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.ISTORE_2:
                        newList.replace(i, factory.istore(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.ISTORE_3:
                        newList.replace(i, factory.istore(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.ISTORE:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;

                    // -- DLOAD family --------------------------------------
                    case Opcodes.DLOAD_0:
                        newList.replace(i, factory.dload(maxLocalsInOtherList));
                        break;
                    case Opcodes.DLOAD_1:
                        newList.replace(i, factory.dload(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.DLOAD_2:
                        newList.replace(i, factory.dload(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.DLOAD_3:
                        newList.replace(i, factory.dload(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.DLOAD:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                    case Opcodes.DSTORE_0:
                        newList.replace(i, factory.dstore(maxLocalsInOtherList));
                        break;
                    case Opcodes.DSTORE_1:
                        newList.replace(i, factory.dstore(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.DSTORE_2:
                        newList.replace(i, factory.dstore(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.DSTORE_3:
                        newList.replace(i, factory.dstore(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.DSTORE:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;

                    // -- LLOAD family --------------------------------------
                    case Opcodes.LLOAD_0:
                        newList.replace(i, factory.lload(maxLocalsInOtherList));
                        break;
                    case Opcodes.LLOAD_1:
                        newList.replace(i, factory.lload(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.LLOAD_2:
                        newList.replace(i, factory.lload(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.LLOAD_3:
                        newList.replace(i, factory.lload(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.LLOAD:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                    case Opcodes.LSTORE_0:
                        newList.replace(i, factory.lstore(maxLocalsInOtherList));
                        break;
                    case Opcodes.LSTORE_1:
                        newList.replace(i, factory.lstore(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.LSTORE_2:
                        newList.replace(i, factory.lstore(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.LSTORE_3:
                        newList.replace(i, factory.lstore(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.LSTORE:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                       
                    // -- FLOAD family --------------------------------------
                    case Opcodes.FLOAD_0:
                        newList.replace(i, factory.fload(maxLocalsInOtherList));
                        break;
                    case Opcodes.FLOAD_1:
                        newList.replace(i, factory.fload(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.FLOAD_2:
                        newList.replace(i, factory.fload(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.FLOAD_3:
                        newList.replace(i, factory.fload(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.FLOAD:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                    case Opcodes.FSTORE_0:
                        newList.replace(i, factory.fstore(maxLocalsInOtherList));
                        break;
                    case Opcodes.FSTORE_1:
                        newList.replace(i, factory.fstore(maxLocalsInOtherList + 1));
                        break;
                    case Opcodes.FSTORE_2:
                        newList.replace(i, factory.fstore(maxLocalsInOtherList + 2));
                        break;
                    case Opcodes.FSTORE_3:
                        newList.replace(i, factory.fstore(maxLocalsInOtherList + 3));
                        break;
                    case Opcodes.FSTORE:
                        // Handle this differently. This
                        // form of handling does not break exception table
                        // So, we minimize damage by handling this differently
                        ins.getBytes()[1] += (byte)maxLocalsInOtherList;
                        break;
                       
                }
            }
View Full Code Here

                // Name of the field; 2nd parameter to interceptor
                nList.add(factory.pushConstant(fa.getFieldName()));

                // 3rd parameter; field value
                Instruction pIns = null;
                if (primitive) {
                    // Provide wrapper for primitive types
                    pIns = handlePrimitiveType(fa.getTypeName(), nList);
                }
                //nList.add(fa);
View Full Code Here

            }
        }
        else if ("void".equals(rType)){
            // Pop out the return value(probably null) of
            // the invocation handler if it was a 'void' method
            il.add(new Instruction(new byte[]{Opcodes.POP}));
        }
        else { // Cast to correct Object
            il.add(factory.cast(rType));
        }
    }
View Full Code Here

            cName = "java.lang.Double";
        }

         il.add(f.newClass(cName));
         il.add(f.dup());
         Instruction ins = f.invoke(Modifier.PUBLIC, cName, "<init>", s);
         return ins;
    }
View Full Code Here

TOP

Related Classes of alt.jiapi.reflect.Instruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.