/** * Call it BEFORE executing an instruction virtually. * * @param instr * @param stack * @param localVar */ private void addRecord( FunctionStateKey stateKey, GCInstruction instr, GCOperandStack stack, GCLocalVariables localVar) { MethodInfo method = instr.getMethod(); String methodStr = oracle.getMethodOrFieldString(method); if (methodStr.contains("jvmTestCases.Main.fooGetOnly")) {} debugPrint("\n\n", "***** adding record *****"); debugPrint("method Str=", methodStr); debugPrint("instr =", instr); HashSet<Integer> unqiueForField = new HashSet<Integer>(); if (instr.getOpCode() != JavaInstructionsOpcodes.AALOAD) { int cpIndex = instr.getOperandsData().intValueUnsigned(); unqiueForField.add(cpIndex); } else { unqiueForField = getAALOADNewIds(stack); } Iterator<Integer> it = unqiueForField.iterator(); while (it.hasNext()) { contrForField.addRecord(stateKey, instr, it.next()); } }
/** * 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(); } }