@Override public void visitPut(SSAPutInstruction instruction) { visitPutInternal(instruction.getVal(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public String toString(SymbolTable symbolTable) { if (isStatic()) { return "putstatic " + getDeclaredField() + " = " + getValueString(symbolTable, val); } else { return "putfield " + getValueString(symbolTable, getRef()) + '.' + getDeclaredField() + " = " + getValueString(symbolTable, val); } }
derefValueNumber = ((SSAGetInstruction) instr).getRef(); } else if (instr instanceof SSAPutInstruction && !((SSAPutInstruction) instr).isStatic()) { derefValueNumber = ((SSAPutInstruction) instr).getRef(); } else if (instr instanceof SSAAbstractInvokeInstruction) { SSAAbstractInvokeInstruction callInst = (SSAAbstractInvokeInstruction) instr;
@Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) return insts.PutInstruction(iindex, uses == null ? val : uses[0], getDeclaredField()); else return insts.PutInstruction(iindex, uses == null ? getRef() : uses[0], uses == null ? val : uses[1], getDeclaredField()); }
/** * generate a numbering of the putstatic instructions */ private OrdinalSetMapping<Integer> numberPutStatics() { ArrayList<Integer> putInstrs = new ArrayList<>(); IR ir = ecfg.getIR(); SSAInstruction[] instructions = ir.getInstructions(); for (int i = 0; i < instructions.length; i++) { SSAInstruction instruction = instructions[i]; if (instruction instanceof SSAPutInstruction && ((SSAPutInstruction) instruction).isStatic()) { SSAPutInstruction putInstr = (SSAPutInstruction) instruction; // instrNum is the number that will be assigned to this putstatic int instrNum = putInstrs.size(); putInstrs.add(i); // also update the mapping of static fields to def'ing statements IField field = cha.resolveField(putInstr.getDeclaredField()); assert field != null; BitVector bv = staticField2DefStatements.get(field); if (bv == null) { bv = new BitVector(); staticField2DefStatements.put(field, bv); } bv.set(instrNum); } } return new ObjectArrayMapping<>(putInstrs.toArray(new Integer[0])); }
@Override public void visitPut(SSAPutInstruction instruction) { visitPutInternal(instruction.getVal(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitPut(SSAPutInstruction instruction) { result.add(instruction.getDeclaredField()); } };
/** * @see com.ibm.wala.ssa.SSAInstruction#getNumberOfUses() */ @Override public int getNumberOfUses() { return isStatic() ? 1 : 2; }
@Override public void visitPut(SSAPutInstruction put) { visitPut(put.getVal(), put.getDeclaredField().getName().toString()); }
@Override public void visitPut(SSAPutInstruction instruction) { if (!includePrimOps && instruction.getDeclaredFieldType().isPrimitiveType()) { return; } FieldReference fr = instruction.getDeclaredField(); IField f = cha.resolveField(fr); if (f == null) { return; } Set<MemoryAccess> s = MapUtil.findOrCreateSet(writeMap, f); MemoryAccess fa = new MemoryAccess(instructionIndex, node); s.add(fa); }
@Override public Iterator<PointerKey> getWritesToInstanceField(PointerKey pk, IField f) { // TODO: cache this!! if (f == ArrayContents.v()) { return getArrayWrites(pk); } pk = convertPointerKeyToHeapModel(pk, mam.getHeapModel()); Collection<MemoryAccess> writes = mam.getFieldWrites(pk, f); for (MemoryAccess a : writes) { addSubgraphForNode(a.getNode()); } ArrayList<PointerKey> written = new ArrayList<>(); for (MemoryAccess a : writes) { IR ir = a.getNode().getIR(); SSAPutInstruction s = (SSAPutInstruction) ir.getInstructions()[a.getInstructionIndex()]; if (s == null) { // s can be null because the memory access map may be constructed from bytecode, // and the write instruction may have been eliminated from SSA because it's dead // TODO clean this up continue; } PointerKey r = heapModel.getPointerKeyForLocal(a.getNode(), s.getVal()); // if (Assertions.verifyAssertions) { // Assertions._assert(containsNode(r)); // } written.add(r); } return written.iterator(); }
@Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) return insts.PutInstruction(iindex, uses == null ? val : uses[0], getDeclaredField()); else return insts.PutInstruction(iindex, uses == null ? getRef() : uses[0], uses == null ? val : uses[1], getDeclaredField()); }
for (int i = 0; i < instructions.length; i++) { SSAInstruction instruction = instructions[i]; if (instruction instanceof SSAPutInstruction && ((SSAPutInstruction) instruction).isStatic()) { SSAPutInstruction putInstr = (SSAPutInstruction) instruction; putInstrs.add(Pair.make(node, i)); IField field = cha.resolveField(putInstr.getDeclaredField()); assert field != null; BitVector bv = staticField2DefStatements.get(field);
@Override public void visitPut(SSAPutInstruction instruction) { visitPutInternal(instruction.getVal(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitPut(SSAPutInstruction instruction) { result.add(instruction.getDeclaredField()); } };
/** * @see com.ibm.wala.ssa.SSAInstruction#getNumberOfUses() */ @Override public int getNumberOfUses() { return isStatic() ? 1 : 2; }
@Override public void visitPut(SSAPutInstruction put) { visitPut(put.getVal(), put.getDeclaredField().getName().toString()); }
@Override public void visitPut(SSAPutInstruction instruction) { if (!includePrimOps && instruction.getDeclaredFieldType().isPrimitiveType()) { return; } FieldReference fr = instruction.getDeclaredField(); IField f = cha.resolveField(fr); if (f == null) { return; } Set<MemoryAccess> s = MapUtil.findOrCreateSet(writeMap, f); MemoryAccess fa = new MemoryAccess(instructionIndex, node); s.add(fa); }
@Override public Iterator<PointerKey> getWritesToInstanceField(PointerKey pk, IField f) { // TODO: cache this!! if (f == ArrayContents.v()) { return getArrayWrites(pk); } pk = convertPointerKeyToHeapModel(pk, mam.getHeapModel()); Collection<MemoryAccess> writes = mam.getFieldWrites(pk, f); for (MemoryAccess a : writes) { addSubgraphForNode(a.getNode()); } ArrayList<PointerKey> written = new ArrayList<>(); for (MemoryAccess a : writes) { IR ir = a.getNode().getIR(); SSAPutInstruction s = (SSAPutInstruction) ir.getInstructions()[a.getInstructionIndex()]; if (s == null) { // s can be null because the memory access map may be constructed from bytecode, // and the write instruction may have been eliminated from SSA because it's dead // TODO clean this up continue; } PointerKey r = heapModel.getPointerKeyForLocal(a.getNode(), s.getVal()); // if (Assertions.verifyAssertions) { // Assertions._assert(containsNode(r)); // } written.add(r); } return written.iterator(); }