/** * Flow function composition * * @return { (x, z) | (x, y) \in g, (y, z) \in f } */ private static IUnaryFlowFunction compose(final IUnaryFlowFunction f, final IUnaryFlowFunction g) { return d1 -> { final MutableSparseIntSet set = MutableSparseIntSet.makeEmpty(); g.getTargets(d1).foreach(x -> set.addAll(f.getTargets(x))); return set; }; }
/** * Warning: inefficient; this should not be called often. */ MutableSparseIntSet makeSparseCopy() { if (privatePart == null) { if (sharedPart == null) { return MutableSparseIntSet.makeEmpty(); } else { return new MutableSparseIntSetFactory().makeCopy(sharedPart); } } else { if (sharedPart == null) { return MutableSparseIntSet.make(privatePart); } else { /* privatePart != null, sharedPart != null */ MutableSparseIntSet result = MutableSparseIntSet.make(privatePart); result.addAll(sharedPart); return result; } } }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPhi(CGNode node, SSAPhiInstruction instruction) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (int i = 0; i < instruction.getNumberOfUses(); i++) { int vn = instruction.getUse(i); if (vn != -1) { PointerKey lpk = pointerKeys.getPointerKeyForLocal(node, vn); OrdinalSet pointees = getPointsToSet(lpk); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPi(CGNode node, SSAPiInstruction instruction) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (int i = 0; i < instruction.getNumberOfUses(); i++) { int vn = instruction.getUse(i); if (vn != -1) { PointerKey lpk = pointerKeys.getPointerKeyForLocal(node, vn); OrdinalSet pointees = getPointsToSet(lpk); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPi(CGNode node, SSAPiInstruction instruction) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (int i = 0; i < instruction.getNumberOfUses(); i++) { int vn = instruction.getUse(i); if (vn != -1) { PointerKey lpk = pointerKeys.getPointerKeyForLocal(node, vn); OrdinalSet pointees = getPointsToSet(lpk); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtPhi(CGNode node, SSAPhiInstruction instruction) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (int i = 0; i < instruction.getNumberOfUses(); i++) { int vn = instruction.getUse(i); if (vn != -1) { PointerKey lpk = pointerKeys.getPointerKeyForLocal(node, vn); OrdinalSet pointees = getPointsToSet(lpk); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } } return new OrdinalSet<>(S, instanceKeys); }
/** * @return the points-to set for the exceptional return values from a particular call site */ private OrdinalSet<InstanceKey> computeImplicitExceptionsForCall(CGNode node, SSAInvokeInstruction call) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (CGNode target : getCallGraph().getPossibleTargets(node, call.getCallSite())) { PointerKey retVal = pointerKeys.getPointerKeyForExceptionalReturnValue(target); IntSet set = getPointsToSet(retVal).getBackingSet(); if (set != null) { S.addAll(set); } } return new OrdinalSet<>(S, instanceKeys); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtALoad(CGNode node, SSAArrayLoadInstruction instruction) { PointerKey arrayRef = pointerKeys.getPointerKeyForLocal(node, instruction.getArrayRef()); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); OrdinalSet<InstanceKey> refs = getPointsToSet(arrayRef); for (InstanceKey ik : refs) { PointerKey key = pointerKeys.getPointerKeyForArrayContents(ik); OrdinalSet pointees = getPointsToSet(key); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } return new OrdinalSet<>(S, instanceKeys); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtALoad(CGNode node, SSAArrayLoadInstruction instruction) { PointerKey arrayRef = pointerKeys.getPointerKeyForLocal(node, instruction.getArrayRef()); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); OrdinalSet<InstanceKey> refs = getPointsToSet(arrayRef); for (InstanceKey ik : refs) { PointerKey key = pointerKeys.getPointerKeyForArrayContents(ik); OrdinalSet pointees = getPointsToSet(key); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } return new OrdinalSet<>(S, instanceKeys); }
/** * @return the points-to set for the exceptional return values from a particular call site */ private OrdinalSet<InstanceKey> computeImplicitExceptionsForCall(CGNode node, SSAInvokeInstruction call) { MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (CGNode target : getCallGraph().getPossibleTargets(node, call.getCallSite())) { PointerKey retVal = pointerKeys.getPointerKeyForExceptionalReturnValue(target); IntSet set = getPointsToSet(retVal).getBackingSet(); if (set != null) { S.addAll(set); } } return new OrdinalSet<>(S, instanceKeys); }
@Override public IntSet getSuccNodeNumbers(T node) { int number = getNumber(node); IntSet s = normalEdgeManager.getSuccNodeNumbers(node); MutableSparseIntSet result = s == null ? MutableSparseIntSet.makeEmpty() : MutableSparseIntSet.make(s); s = exceptionalEdgeManager.getSuccNodeNumbers(node); if (s != null) { result.addAll(s); } if (normalToExit.get(number) || exceptionalToExit.get(number)) { result.add(exit.getNumber()); } if (fallThru.get(number)) { result.add(number + 1); } return result; }
@Override public IntSet getSuccNodeNumbers(T node) { int number = getNumber(node); IntSet s = normalEdgeManager.getSuccNodeNumbers(node); MutableSparseIntSet result = s == null ? MutableSparseIntSet.makeEmpty() : MutableSparseIntSet.make(s); s = exceptionalEdgeManager.getSuccNodeNumbers(node); if (s != null) { result.addAll(s); } if (normalToExit.get(number) || exceptionalToExit.get(number)) { result.add(exit.getNumber()); } if (fallThru.get(number)) { result.add(number + 1); } return result; }
@Override public void visitAstGlobalRead(AstGlobalRead instruction) { JSPointerAnalysisImpl jsAnalysis = (JSPointerAnalysisImpl) analysis; FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); assert !directGlobalObjectRef(field); IField f = jsAnalysis.builder.getCallGraph().getClassHierarchy().resolveField(field); assert f != null; MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); InstanceKey globalObj = ((AstSSAPropagationCallGraphBuilder) jsAnalysis.builder).getGlobalObject(JavaScriptTypes.jsName); PointerKey fkey = analysis.getHeapModel().getPointerKeyForInstanceField(globalObj, f); if (fkey != null) { OrdinalSet<InstanceKey> pointees = analysis.getPointsToSet(fkey); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } pointsToSet = new OrdinalSet<>(S, analysis.getInstanceKeyMapping()); }
@Override public void visitAstGlobalRead(AstGlobalRead instruction) { JSPointerAnalysisImpl jsAnalysis = (JSPointerAnalysisImpl) analysis; FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); assert !directGlobalObjectRef(field); IField f = jsAnalysis.builder.getCallGraph().getClassHierarchy().resolveField(field); assert f != null; MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); InstanceKey globalObj = ((AstSSAPropagationCallGraphBuilder) jsAnalysis.builder).getGlobalObject(JavaScriptTypes.jsName); PointerKey fkey = analysis.getHeapModel().getPointerKeyForInstanceField(globalObj, f); if (fkey != null) { OrdinalSet<InstanceKey> pointees = analysis.getPointsToSet(fkey); IntSet set = pointees.getBackingSet(); if (set != null) { S.addAll(set); } } pointsToSet = new OrdinalSet<>(S, analysis.getInstanceKeyMapping()); }