@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()); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCheckCast(CGNode node, SSACheckCastInstruction instruction) { PointerKey rhs = pointerKeys.getPointerKeyForLocal(node, instruction.getVal()); OrdinalSet<InstanceKey> rhsSet = getPointsToSet(rhs); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (TypeReference t : instruction.getDeclaredResultTypes()) { IClass klass = getCallGraph().getClassHierarchy().lookupClass(t); if (klass == null) { // could not find the type. conservatively assume Object return rhsSet; } else { if (klass.isInterface()) { for (InstanceKey ik : rhsSet) { if (getCallGraph().getClassHierarchy().implementsInterface(ik.getConcreteType(), klass)) { S.add(getInstanceKeyMapping().getMappedIndex(ik)); } } } else { for (InstanceKey ik : rhsSet) { if (getCallGraph().getClassHierarchy().isSubclassOf(ik.getConcreteType(), klass)) { S.add(getInstanceKeyMapping().getMappedIndex(ik)); } } } } } return new OrdinalSet<>(S, instanceKeys); }
@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()); }
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtCheckCast(CGNode node, SSACheckCastInstruction instruction) { PointerKey rhs = pointerKeys.getPointerKeyForLocal(node, instruction.getVal()); OrdinalSet<InstanceKey> rhsSet = getPointsToSet(rhs); MutableSparseIntSet S = MutableSparseIntSet.makeEmpty(); for (TypeReference t : instruction.getDeclaredResultTypes()) { IClass klass = getCallGraph().getClassHierarchy().lookupClass(t); if (klass == null) { // could not find the type. conservatively assume Object return rhsSet; } else { if (klass.isInterface()) { for (InstanceKey ik : rhsSet) { if (getCallGraph().getClassHierarchy().implementsInterface(ik.getConcreteType(), klass)) { S.add(getInstanceKeyMapping().getMappedIndex(ik)); } } } else { for (InstanceKey ik : rhsSet) { if (getCallGraph().getClassHierarchy().isSubclassOf(ik.getConcreteType(), klass)) { S.add(getInstanceKeyMapping().getMappedIndex(ik)); } } } } } return new OrdinalSet<>(S, instanceKeys); }