private HashSet<Integer> getAALOADNewIds(OperandStack stack) { HashSet<Integer> toRet = new HashSet<Integer>(); try { int currentSizeOfStack = stack.getNumberOfTypesInStack(); GCType type = (GCType) stack.get(currentSizeOfStack - 2); toRet = type.getAllNewIds(); toRet.remove(-1); } catch (Exception d) { d.printStackTrace(); System.exit(1); } return toRet; }
/** * 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(); } }
@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(); } }