コード例 #1
0
 public String getCodeWithArguments(
     Un fixedArguments, Vector<Integer> sizesOfIndividualParameters) {
   String ret = code;
   try {
     if (argumentFunction.size() != sizesOfIndividualParameters.size()) {
       Miscellaneous.printlnErr(
           "either bytecode defination file is wrong or opcode-parameter file is wrong.");
       Miscellaneous.printlnErr(
           "bytecode defination required "
               + argumentFunction.size()
               + " parameters, in "
               + "contrast the opcode-parameter file required "
               + sizesOfIndividualParameters.size()
               + " parameters");
       Miscellaneous.exit();
     }
     LFRevUn.bigEndian = true;
     for (int loop = argumentFunction.size() - 1; loop >= 0; loop--) {
       String nextThingToReplace = "@@" + (loop + 1);
       int argSize = sizesOfIndividualParameters.elementAt(loop);
       Un afterCutting = Un.cutBytes(argSize, fixedArguments);
       String toReplaceWith = "(0x" + afterCutting.toString() + ")";
       if (loop != argumentFunction.size() - 1) {
         toReplaceWith += ", ";
       }
       ret = ret.replace(nextThingToReplace, argumentType.elementAt(loop) + toReplaceWith);
     }
     LFRevUn.bigEndian = false;
   } catch (Exception d) {
     Miscellaneous.println("Error in bytecode defination file. " + this + ", " + fixedArguments);
     d.printStackTrace();
     Miscellaneous.exit();
   }
   return ret;
 }
コード例 #2
0
 @Override
 public void validateInput(String args[]) throws Exception {
   if (args.length < 2) {
     engine.inputMessage();
     Miscellaneous.exit();
   }
 }
コード例 #3
0
 String getCodeWithArguments(Un fixedArg) throws IOException {
   try {
     return code.replace("@@1", argumentType.elementAt(0) + "(0x" + fixedArg.toString() + ")");
   } catch (Exception d) {
     LogHolder.getInstanceOf()
         .addLog(" *******ERROR ********* in function getCodeWithArguments...", true);
     Miscellaneous.println(" Enter a character to continue...");
     System.in.read();
   }
   return "";
 }
コード例 #4
0
 /**
  * In case the method is still under-call then put the record of the method fields where get was
  * used in a seperate map. When a method any next instruction is called again then the record is
  * pop from the map and corresponding instructions are made dirty.
  *
  * <p>This method create that record of method fields.
  *
  * @param methodCallInfo
  * @param instrDataSettingInstr
  */
 private void handlePutRecalls(
     MethodCallInfo methodCallInfo, GCInstruction instrDataSettingInstr, OperandStack stack) {
   if (true) return;
   try {
     /**
      * 1. Firstly get from input instructions the uniqueId for corresponding data reterival
      * instructions. 2. Subsequently, add those instructions in the two different maps depending
      * upon if the method is still under call or not.
      */
     ControllerForFieldInstr contr = ControllerForFieldInstr.getInstanceOf();
     HashSet<Integer> uniqueIdForDataRetrivalInstr = new HashSet<Integer>();
     if (instrDataSettingInstr.getOpCode() != JavaInstructionsOpcodes.AASTORE) {
       int cpIndex = instrDataSettingInstr.getOperandsData().intValueUnsigned();
       uniqueIdForDataRetrivalInstr.add(cpIndex);
     } else {
       uniqueIdForDataRetrivalInstr = getAAStoreNewIds(stack);
     }
     /**
      * following are the all getField or getStatic instruction for the given constant pool index.
      */
     HashSet<FieldRecord> getFieldOrStateRecordSet =
         contr.getRecords(
             uniqueIdForDataRetrivalInstr,
             instrDataSettingInstr.getOpCode() == JavaInstructionsOpcodes.AASTORE);
     /**
      * Now we iterate from all of those instructions and put them in two different maps
      * depenending up if their method is still under call or not.
      */
     Iterator<FieldRecord> fieldRectIt = getFieldOrStateRecordSet.iterator();
     while (fieldRectIt.hasNext()) {
       FieldRecord fieldRec = fieldRectIt.next();
       HashSet<FunctionStateKey> allTheMethodCallsForTheField = fieldRec.getStateKeys();
       Iterator<FunctionStateKey> methodCallIt = allTheMethodCallsForTheField.iterator();
       while (methodCallIt.hasNext()) {
         FunctionStateKey stateKey = methodCallIt.next();
         GCDataFlowAnalyzer dataFlowAnalyzer = GCDataFlowAnalyzer.getInstanceOf();
         HashSet<FunctionStateKey> allMethodInExecution = dataFlowAnalyzer.getMethodsInExecution();
         String methodString = oracle.getMethodOrFieldString(stateKey.getMethod());
         long instrId = fieldRec.getInstr().getInstructionId();
         if (allMethodInExecution.contains(stateKey)) {
           putInMap(fieldsToSetDirtyInUnderCallMethod, stateKey, fieldRec);
         } else {
           putInMap(fieldsToSetDirtyAfterMethodCalled, stateKey, fieldRec);
         }
       }
     }
   } catch (Exception d) {
     d.printStackTrace();
     Miscellaneous.exit();
   }
 }
コード例 #5
0
 @Override
 public void init(String args[]) throws Exception {
   String superArgs[] = null;
   StatsHolder.getInstanceOf().addStatArgs(args);
   engine.setDefaults();
   try {
     superArgs = engine.processArgs(args);
   } catch (Exception d) {
     engine.inputMessage();
     // Miscellaneous.printlnErr("************ ERROR Wrong input: " + d.getMessage());
     // d.printStackTrace();
     Miscellaneous.exit();
   }
   // do not forget this. However, at the end as third parameter was set above properly
   super.init(superArgs);
   System.arraycopy(superArgs, 0, args, 0, args.length);
 }
コード例 #6
0
  @Override
  public void execute(String args[]) throws Exception {
    try {
      statHolder.addStat(
          StatGroups.BYTECODE_OPTIMIZATION,
          "Total size of all instructions ",
          CodeAtt.getCodeTotalLengthInput());
      super.execute(args);

      if (!doOptimization) {
        return;
      }
      InputOptionsController.getInstanceOf().execute();
      endWithOptimization = true;
      Oracle.getInstanceOf().updateAllCodeAttsLength();
    } catch (Exception d) {
      d.printStackTrace();
      Miscellaneous.exit();
    }
  }