/** * How many value numbers does instruction s def? */ protected int getNumberOfDefs(SSAInstruction s) { return s.getNumberOfDefs(); }
@Override protected int getNumberOfDefs(SSAInstruction inst) { return inst.getNumberOfDefs(); }
/** * How many value numbers does instruction s def? */ protected int getNumberOfDefs(SSAInstruction s) { return s.getNumberOfDefs(); }
@Override protected int getNumberOfDefs(SSAInstruction inst) { return inst.getNumberOfDefs(); }
private static void updateForInstruction(Map<Integer, ConstantValue> constants, SymbolTable symbolTable, SSAInstruction s) { for (int j = 0; j < s.getNumberOfDefs(); j++) { symbolTable.ensureSymbol(s.getDef(j)); } for (int j = 0; j < s.getNumberOfUses(); j++) { int vn = s.getUse(j); symbolTable.ensureSymbol(vn); if (constants != null && constants.containsKey(Integer.valueOf(vn))) symbolTable.setConstantValue(vn, constants.get(Integer.valueOf(vn))); } }
private static void updateForInstruction(Map<Integer, ConstantValue> constants, SymbolTable symbolTable, SSAInstruction s) { for (int j = 0; j < s.getNumberOfDefs(); j++) { symbolTable.ensureSymbol(s.getDef(j)); } for (int j = 0; j < s.getNumberOfUses(); j++) { int vn = s.getUse(j); symbolTable.ensureSymbol(vn); if (constants != null && constants.containsKey(Integer.valueOf(vn))) symbolTable.setConstantValue(vn, constants.get(Integer.valueOf(vn))); } }
private void emitInstruction(SSAInstruction s) { if (s != null) { instructions[getCurrentInstructionIndex()] = s; for (int i = 0; i < s.getNumberOfDefs(); i++) { if (creators.length < (s.getDef(i) + 1)) { creators = Arrays.copyOf(creators, 2 * s.getDef(i)); } assert s.getDef(i) != -1 : "invalid def " + i + " for " + s; creators[s.getDef(i)] = s; } } }
private void emitInstruction(SSAInstruction s) { instructions[getCurrentInstructionIndex()] = s; for (int i = 0; i < s.getNumberOfDefs(); i++) { if (creators.length < (s.getDef(i) + 1)) { creators = Arrays.copyOf(creators, 2 * s.getDef(i)); } assert s.getDef(i) != -1 : "invalid def " + i + " for " + s; creators[s.getDef(i)] = s; } }
private void emitInstruction(SSAInstruction s) { instructions[getCurrentInstructionIndex()] = s; for (int i = 0; i < s.getNumberOfDefs(); i++) { if (creators.length < (s.getDef(i) + 1)) { creators = Arrays.copyOf(creators, 2 * s.getDef(i)); } assert s.getDef(i) != -1 : "invalid def " + i + " for " + s; creators[s.getDef(i)] = s; } }
private void emitInstruction(SSAInstruction s) { if (s != null) { instructions[getCurrentInstructionIndex()] = s; for (int i = 0; i < s.getNumberOfDefs(); i++) { if (creators.length < (s.getDef(i) + 1)) { creators = Arrays.copyOf(creators, 2 * s.getDef(i)); } assert s.getDef(i) != -1 : "invalid def " + i + " for " + s; creators[s.getDef(i)] = s; } } }
private int addOriginalStatements(SummarizedMethod m) { SSAInstruction[] original = m.getStatements(options.getSSAOptions()); // local value number 1 is "this", so the next free value number is 2 int nextLocal = 2; for (SSAInstruction s : original) { allInstructions.add(s); if (s instanceof SSAInvokeInstruction) { calls.add(s); } if (s instanceof SSANewInstruction) { allocations.add(s); } for (int j = 0; j < s.getNumberOfDefs(); j++) { int def = s.getDef(j); if (def >= nextLocal) { nextLocal = def + 1; } } for (int j = 0; j < s.getNumberOfUses(); j++) { int use = s.getUse(j); if (use >= nextLocal) { nextLocal = use + 1; } } } return nextLocal; }
private Iterable<CodeElement> getOutCodeElts(CGNode node, SSAInstruction inst) { int defNo = inst.getNumberOfDefs(); Set<CodeElement> elts = HashSetFactory.make(); if (inst instanceof SSAReturnInstruction) { // only one possible element for returns elts.add(new ReturnElement()); return elts; } if (inst instanceof SSAPutInstruction) { final Set<CodeElement> fieldAccessCodeElts = getFieldAccessCodeElts( node, (SSAPutInstruction) inst); elts.addAll(fieldAccessCodeElts); } if (inst instanceof SSAArrayStoreInstruction) { elts.addAll(getArrayRefCodeElts(node, (SSAArrayStoreInstruction) inst)); } for (int i = 0; i < defNo; i++) { int valNo = inst.getDef(i); elts.addAll(CodeElement.valueElements(valNo)); } return elts; }
private int addOriginalStatements(SummarizedMethod m) { SSAInstruction[] original = m.getStatements(options.getSSAOptions()); // local value number 1 is "this", so the next free value number is 2 int nextLocal = 2; for (SSAInstruction s : original) { allInstructions.add(s); if (s instanceof SSAInvokeInstruction) { calls.add(s); } if (s instanceof SSANewInstruction) { allocations.add(s); } for (int j = 0; j < s.getNumberOfDefs(); j++) { int def = s.getDef(j); if (def >= nextLocal) { nextLocal = def + 1; } } for (int j = 0; j < s.getNumberOfUses(); j++) { int use = s.getUse(j); if (use >= nextLocal) { nextLocal = use + 1; } } } return nextLocal; }
boolean check(IMethod m, IR ir) { System.err.println(("check for " + variableName + " defined at " + definingLineNumber)); SSAInstruction[] insts = ir.getInstructions(); for (int i = 0; i < insts.length; i++) { if (insts[i] != null) { int ln = m.getLineNumber(i); if (ln == definingLineNumber) { System.err.println((" found " + insts[i] + " at " + ln)); for (int j = 0; j < insts[i].getNumberOfDefs(); j++) { int def = insts[i].getDef(j); System.err.println((" looking at def " + j + ": " + def)); String[] names = ir.getLocalNames(i, def); if (names != null) { for (String name : names) { System.err.println((" looking at name " + name)); if (name.equals(variableName)) { return true; } } } } } } } return false; } }
private void handleNonHeapInstruction(SSAInstruction instruction) { for (int i = 0; i < instruction.getNumberOfDefs(); i++) { int def = instruction.getDef(i); PointerKey defPk = heapModel.getPointerKeyForLocal(node, def); addNode(defPk); for (int j = 0; j < instruction.getNumberOfUses(); j++) { int use = instruction.getUse(j); PointerKey usePk = heapModel.getPointerKeyForLocal(node, use); addNode(usePk); addEdge(defPk, usePk, AssignLabel.noFilter()); } } }
private void handleNonHeapInstruction(SSAInstruction instruction) { for (int i = 0; i < instruction.getNumberOfDefs(); i++) { int def = instruction.getDef(i); PointerKey defPk = heapModel.getPointerKeyForLocal(node, def); addNode(defPk); for (int j = 0; j < instruction.getNumberOfUses(); j++) { int use = instruction.getUse(j); PointerKey usePk = heapModel.getPointerKeyForLocal(node, use); addNode(usePk); addEdge(defPk, usePk, AssignLabel.noFilter()); } } }
private static IntSet valuesToConvert(AstIRFactory.AstIR ir) { SSAInstruction[] insts = ir.getInstructions(); MutableIntSet foundOne = new BitVectorIntSet(); MutableIntSet foundTwo = new BitVectorIntSet(); for (SSAInstruction inst : insts) { if (inst != null) { for (int j = 0; j < inst.getNumberOfDefs(); j++) { int def = inst.getDef(j); if (def != -1) { if (foundOne.contains(def) || ir.getSymbolTable().isConstant(def) || def <= ir.getNumberOfParameters() || inst instanceof AssignInstruction) { foundTwo.add(def); } else { foundOne.add(def); } } } } } return foundTwo; }
private static IntSet valuesToConvert(AstIRFactory.AstIR ir) { SSAInstruction[] insts = ir.getInstructions(); MutableIntSet foundOne = new BitVectorIntSet(); MutableIntSet foundTwo = new BitVectorIntSet(); for (SSAInstruction inst : insts) { if (inst != null) { for (int j = 0; j < inst.getNumberOfDefs(); j++) { int def = inst.getDef(j); if (def != -1) { if (foundOne.contains(def) || ir.getSymbolTable().isConstant(def) || def <= ir.getNumberOfParameters() || inst instanceof AssignInstruction) { foundTwo.add(def); } else { foundOne.add(def); } } } } } return foundTwo; }
SSAInstruction inst = instructions[i]; if (inst != null) { for (int j = 0; j < inst.getNumberOfDefs(); j++) { bits.remove(inst.getDef(j));
@Override public void check(CallGraph cg) { IR ir = getIR(cg, typeName, "main", "[Ljava/lang/String;", "V"); AstJavaTypeInference inference = new AstJavaTypeInference(ir, true); for (SSAInstruction instr : Iterator2Iterable.make(ir.iterateAllInstructions())) { // Check defs for (int def = 0; def < instr.getNumberOfDefs(); def++) { int ssaVariable = instr.getDef(def); inference.getType(ssaVariable); } // Check uses for (int def = 0; def < instr.getNumberOfUses(); def++) { int ssaVariable = instr.getUse(def); inference.getType(ssaVariable); } } }