@Override public boolean addFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { int idx = system.findOrCreateIndexForInstanceKey(concreteType); if (R.contains(idx)) { return L.add(idx); } return false; }
@Override public boolean addFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { int idx = system.findOrCreateIndexForInstanceKey(concreteType); if (R.contains(idx)) { return L.add(idx); } return false; }
@Override public void action(AbstractFieldPointerKey fieldKey) { if (!representsNullType(fieldKey.getInstanceKey())) { for (InstanceKey rhsFixedValue : rhsFixedValues) { system.findOrCreateIndexForInstanceKey(rhsFixedValue); system.newConstraint(fieldKey, rhsFixedValue); } } } }
@Override public void action(AbstractFieldPointerKey fieldKey) { if (!representsNullType(fieldKey.getInstanceKey())) { for (InstanceKey rhsFixedValue : rhsFixedValues) { system.findOrCreateIndexForInstanceKey(rhsFixedValue); system.newConstraint(fieldKey, rhsFixedValue); } } } }
@Override protected void action(PointerKey lexicalKey, int vn) { PointerKey rval = getPointerKeyForLocal(vn); if (contentsAreInvariant(symbolTable, du, vn)) { InstanceKey[] ik = getInvariantContents(vn); system.recordImplicitPointsToSet(rval); for (InstanceKey element : ik) { system.findOrCreateIndexForInstanceKey(element); system.newConstraint(lexicalKey, element); } } else { system.newConstraint(lexicalKey, assignOperator, rval); } } });
@Override protected void action(PointerKey lexicalKey, int vn) { PointerKey rval = getPointerKeyForLocal(vn); if (contentsAreInvariant(symbolTable, du, vn)) { InstanceKey[] ik = getInvariantContents(vn); system.recordImplicitPointsToSet(rval); for (InstanceKey element : ik) { system.findOrCreateIndexForInstanceKey(element); system.newConstraint(lexicalKey, element); } } else { system.newConstraint(lexicalKey, assignOperator, rval); } } });
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { int idx = system.findOrCreateIndexForInstanceKey(concreteType); if (!R.contains(idx) || L.contains(idx)) { return L.addAll(R); } else { MutableIntSet copy = IntSetUtil.makeMutableCopy(R.getValue()); copy.remove(idx); return L.addAll(copy); } }
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { int idx = system.findOrCreateIndexForInstanceKey(concreteType); if (!R.contains(idx) || L.contains(idx)) { return L.addAll(R); } else { MutableIntSet copy = IntSetUtil.makeMutableCopy(R.getValue()); copy.remove(idx); return L.addAll(copy); } }
/** * Side effect: records invariant parameters as implicit points-to-sets. * * @return if non-null, then result[i] holds the set of instance keys which may be passed as the ith parameter. (which must be * invariant) */ @Override public InstanceKey[][] computeInvariantParameters(SSAAbstractInvokeInstruction call) { InstanceKey[][] constParams = null; for (int i = 0; i < call.getNumberOfUses(); i++) { // not sure how getUse(i) <= 0 .. dead code? // TODO: investigate if (call.getUse(i) > 0) { if (contentsAreInvariant(symbolTable, du, call.getUse(i))) { system.recordImplicitPointsToSet(getPointerKeyForLocal(call.getUse(i))); if (constParams == null) { constParams = new InstanceKey[call.getNumberOfUses()][]; } constParams[i] = getInvariantContents(call.getUse(i)); for (int j = 0; j < constParams[i].length; j++) { system.findOrCreateIndexForInstanceKey(constParams[i][j]); } } } } return constParams; } }
/** * Side effect: records invariant parameters as implicit points-to-sets. * * @return if non-null, then result[i] holds the set of instance keys which may be passed as the ith parameter. (which must be * invariant) */ @Override public InstanceKey[][] computeInvariantParameters(SSAAbstractInvokeInstruction call) { InstanceKey[][] constParams = null; for (int i = 0; i < call.getNumberOfUses(); i++) { // not sure how getUse(i) <= 0 .. dead code? // TODO: investigate if (call.getUse(i) > 0) { if (contentsAreInvariant(symbolTable, du, call.getUse(i))) { system.recordImplicitPointsToSet(getPointerKeyForLocal(call.getUse(i))); if (constParams == null) { constParams = new InstanceKey[call.getNumberOfUses()][]; } constParams[i] = getInvariantContents(call.getUse(i)); for (int j = 0; j < constParams[i].length; j++) { system.findOrCreateIndexForInstanceKey(constParams[i][j]); } } } } return constParams; } }
@Override public void visitAstGlobalRead(AstGlobalRead instruction) { int lval = instruction.getDef(); FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); PointerKey def = getPointerKeyForLocal(lval); assert def != null; IField f = getClassHierarchy().resolveField(field); assert f != null : "could not resolve referenced global " + field; if (hasNoInterestingUses(lval)) { system.recordImplicitPointsToSet(def); } else { InstanceKey globalObj = getBuilder().getGlobalObject(JavaScriptTypes.jsName); if (directGlobalObjectRef(field)) { // points-to set is just the global object system.newConstraint(def, globalObj); } else { system.findOrCreateIndexForInstanceKey(globalObj); PointerKey p = getPointerKeyForInstanceField(globalObj, f); system.newConstraint(def, assignOperator, p); } } }
@Override public void visitAstGlobalRead(AstGlobalRead instruction) { int lval = instruction.getDef(); FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); PointerKey def = getPointerKeyForLocal(lval); assert def != null; IField f = getClassHierarchy().resolveField(field); assert f != null : "could not resolve referenced global " + field; if (hasNoInterestingUses(lval)) { system.recordImplicitPointsToSet(def); } else { InstanceKey globalObj = getBuilder().getGlobalObject(JavaScriptTypes.jsName); if (directGlobalObjectRef(field)) { // points-to set is just the global object system.newConstraint(def, globalObj); } else { system.findOrCreateIndexForInstanceKey(globalObj); PointerKey p = getPointerKeyForInstanceField(globalObj, f); system.newConstraint(def, assignOperator, p); } } }
@Override public void visitLoadMetadata(SSALoadMetadataInstruction instruction) { PointerKey def = getPointerKeyForLocal(instruction.getDef()); InstanceKey iKey = getInstanceKeyForClassObject(instruction.getToken(), instruction.getType()); if (instruction.getToken() instanceof TypeReference) { IClass klass = getClassHierarchy().lookupClass((TypeReference) instruction.getToken()); if (klass != null) { processClassInitializer(klass); } } if (!contentsAreInvariant(symbolTable, du, instruction.getDef())) { system.newConstraint(def, iKey); } else { system.findOrCreateIndexForInstanceKey(iKey); system.recordImplicitPointsToSet(def); } }
@Override public void visitLoadMetadata(SSALoadMetadataInstruction instruction) { PointerKey def = getPointerKeyForLocal(instruction.getDef()); InstanceKey iKey = getInstanceKeyForClassObject(instruction.getToken(), instruction.getType()); if (instruction.getToken() instanceof TypeReference) { IClass klass = getClassHierarchy().lookupClass((TypeReference) instruction.getToken()); if (klass != null) { processClassInitializer(klass); } } if (!contentsAreInvariant(symbolTable, du, instruction.getDef())) { system.newConstraint(def, iKey); } else { system.findOrCreateIndexForInstanceKey(iKey); system.recordImplicitPointsToSet(def); } }
@Override protected void action(PointerKey lexicalKey, int vn) { PointerKey lval = getPointerKeyForLocal(vn); if (lexicalKey instanceof LocalPointerKey) { CGNode lnode = ((LocalPointerKey) lexicalKey).getNode(); int lvn = ((LocalPointerKey) lexicalKey).getValueNumber(); IRView lir = getBuilder().getCFAContextInterpreter().getIRView(lnode); SymbolTable lsymtab = lir.getSymbolTable(); DefUse ldu = getBuilder().getCFAContextInterpreter().getDU(lnode); // DefUse ldu = getAnalysisCache().getDefUse(lir); if (contentsAreInvariant(lsymtab, ldu, lvn)) { InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn); system.recordImplicitPointsToSet(lexicalKey); for (InstanceKey element : ik) { system.findOrCreateIndexForInstanceKey(element); system.newConstraint(lval, element); } return; } } system.newConstraint(lval, assignOperator, lexicalKey); } });
@Override protected void action(PointerKey lexicalKey, int vn) { PointerKey lval = getPointerKeyForLocal(vn); if (lexicalKey instanceof LocalPointerKey) { CGNode lnode = ((LocalPointerKey) lexicalKey).getNode(); int lvn = ((LocalPointerKey) lexicalKey).getValueNumber(); IRView lir = getBuilder().getCFAContextInterpreter().getIRView(lnode); SymbolTable lsymtab = lir.getSymbolTable(); DefUse ldu = getBuilder().getCFAContextInterpreter().getDU(lnode); // DefUse ldu = getAnalysisCache().getDefUse(lir); if (contentsAreInvariant(lsymtab, ldu, lvn)) { InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn); system.recordImplicitPointsToSet(lexicalKey); for (InstanceKey element : ik) { system.findOrCreateIndexForInstanceKey(element); system.newConstraint(lval, element); } return; } } system.newConstraint(lval, assignOperator, lexicalKey); } });
@Override public void visitAstGlobalWrite(AstGlobalWrite instruction) { int rval = instruction.getVal(); FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); IField f = getClassHierarchy().resolveField(field); assert f != null : "could not resolve referenced global " + field; assert !f.getFieldTypeReference().isPrimitiveType(); InstanceKey globalObj = getBuilder().getGlobalObject(JavaScriptTypes.jsName); system.findOrCreateIndexForInstanceKey(globalObj); PointerKey p = getPointerKeyForInstanceField(globalObj, f); PointerKey rvalKey = getPointerKeyForLocal(rval); if (contentsAreInvariant(symbolTable, du, rval)) { system.recordImplicitPointsToSet(rvalKey); InstanceKey[] ik = getInvariantContents(rval); for (InstanceKey element : ik) { system.newConstraint(p, element); } } else { system.newConstraint(p, assignOperator, rvalKey); } }
@Override public void visitAstGlobalWrite(AstGlobalWrite instruction) { int rval = instruction.getVal(); FieldReference field = makeNonGlobalFieldReference(instruction.getDeclaredField()); IField f = getClassHierarchy().resolveField(field); assert f != null : "could not resolve referenced global " + field; assert !f.getFieldTypeReference().isPrimitiveType(); InstanceKey globalObj = getBuilder().getGlobalObject(JavaScriptTypes.jsName); system.findOrCreateIndexForInstanceKey(globalObj); PointerKey p = getPointerKeyForInstanceField(globalObj, f); PointerKey rvalKey = getPointerKeyForLocal(rval); if (contentsAreInvariant(symbolTable, du, rval)) { system.recordImplicitPointsToSet(rvalKey); InstanceKey[] ik = getInvariantContents(rval); for (InstanceKey element : ik) { system.newConstraint(p, element); } } else { system.newConstraint(p, assignOperator, rvalKey); } }
protected void doVisitArrayLoad(int def, int arrayRef) { PointerKey result = getPointerKeyForLocal(def); PointerKey arrayRefPtrKey = getPointerKeyForLocal(arrayRef); if (hasNoInterestingUses(def)) { system.recordImplicitPointsToSet(result); } else { if (contentsAreInvariant(symbolTable, du, arrayRef)) { system.recordImplicitPointsToSet(arrayRefPtrKey); InstanceKey[] ik = getInvariantContents(arrayRef); for (int i = 0; i < ik.length; i++) { if (!representsNullType(ik[i])) { system.findOrCreateIndexForInstanceKey(ik[i]); PointerKey p = getPointerKeyForArrayContents(ik[i]); if (p == null) { } else { system.newConstraint(result, assignOperator, p); } } } } else { assert !system.isUnified(result); assert !system.isUnified(arrayRefPtrKey); system.newSideEffect(getBuilder().new ArrayLoadOperator(system.findOrCreatePointsToSet(result)), arrayRefPtrKey); } } }
protected void doVisitArrayLoad(int def, int arrayRef) { PointerKey result = getPointerKeyForLocal(def); PointerKey arrayRefPtrKey = getPointerKeyForLocal(arrayRef); if (hasNoInterestingUses(def)) { system.recordImplicitPointsToSet(result); } else { if (contentsAreInvariant(symbolTable, du, arrayRef)) { system.recordImplicitPointsToSet(arrayRefPtrKey); InstanceKey[] ik = getInvariantContents(arrayRef); for (int i = 0; i < ik.length; i++) { if (!representsNullType(ik[i])) { system.findOrCreateIndexForInstanceKey(ik[i]); PointerKey p = getPointerKeyForArrayContents(ik[i]); if (p == null) { } else { system.newConstraint(result, assignOperator, p); } } } } else { assert !system.isUnified(result); assert !system.isUnified(arrayRefPtrKey); system.newSideEffect(getBuilder().new ArrayLoadOperator(system.findOrCreatePointsToSet(result)), arrayRefPtrKey); } } }