@Override public byte evaluate(final PointsToSetVariable lhs, PointsToSetVariable rhs) { class Op implements IntSetAction { private boolean changed = false; @Override public void act(int x) { InstanceKey protoObj = system.getInstanceKey(x); PointerKey protoObjKey = new TransitivePrototypeKey(protoObj); changed |= system.newStatement(lhs, assignOperator, system.findOrCreatePointsToSet(protoObjKey), true, true); } } if (rhs.getValue() != null) { Op op = new Op(); rhs.getValue().foreach(op); return (op.changed? CHANGED: NOT_CHANGED); } return NOT_CHANGED; }
@Override public byte evaluate(final PointsToSetVariable lhs, PointsToSetVariable rhs) { class Op implements IntSetAction { private boolean changed = false; @Override public void act(int x) { InstanceKey protoObj = system.getInstanceKey(x); PointerKey protoObjKey = new TransitivePrototypeKey(protoObj); changed |= system.newStatement(lhs, assignOperator, system.findOrCreatePointsToSet(protoObjKey), true, true); } } if (rhs.getValue() != null) { Op op = new Op(); rhs.getValue().foreach(op); return (op.changed? CHANGED: NOT_CHANGED); } return NOT_CHANGED; }
private String printRHSInstances(AbstractStatement s) { if (s instanceof UnaryStatement) { UnaryStatement u = (UnaryStatement) s; PointsToSetVariable rhs = (PointsToSetVariable) u.getRightHandSide(); IntSet value = rhs.getValue(); final int[] topFive = new int[5]; value.foreach(x -> { System.arraycopy(topFive, 1, topFive, 0, 4); topFive[4] = x; }); StringBuilder result = new StringBuilder(); for (int i = 0; i < 5; i++) { int p = topFive[i]; if (p != 0) { InstanceKey ik = getInstanceKey(p); result.append(p).append(" ").append(ik).append('\n'); } } return result.toString(); } else { return s.getClass().toString(); } }
private String printRHSInstances(AbstractStatement s) { if (s instanceof UnaryStatement) { UnaryStatement u = (UnaryStatement) s; PointsToSetVariable rhs = (PointsToSetVariable) u.getRightHandSide(); IntSet value = rhs.getValue(); final int[] topFive = new int[5]; value.foreach(x -> { System.arraycopy(topFive, 1, topFive, 0, 4); topFive[4] = x; }); StringBuilder result = new StringBuilder(); for (int i = 0; i < 5; i++) { int p = topFive[i]; if (p != 0) { InstanceKey ik = getInstanceKey(p); result.append(p).append(" ").append(ik).append('\n'); } } return result.toString(); } else { return s.getClass().toString(); } }
protected IntSet getParamObjects(int paramIndex, @SuppressWarnings("unused") int rhsi) { int paramVn = call.getUse(paramIndex); PointerKey var = getPointerKeyForLocal(caller, paramVn); IntSet s = system.findOrCreatePointsToSet(var).getValue(); return s; } }
protected IntSet getParamObjects(int paramIndex, @SuppressWarnings("unused") int rhsi) { int paramVn = call.getUse(paramIndex); PointerKey var = getPointerKeyForLocal(caller, paramVn); IntSet s = system.findOrCreatePointsToSet(var).getValue(); return s; } }
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = system.getInstanceKeysForClass(concreteType); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = bits(system); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = system.getInstanceKeysForClass(concreteType); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = bits(system); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
@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); } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
/** * Simply add the instance to each relevant points-to set. */ @Override public byte evaluate(PointsToSetVariable dummyLHS, PointsToSetVariable var) { PointsToSetVariable ref = var; if (ref.size() == 0) { return NOT_CHANGED; } IntSet value = ref.getValue(); final MutableBoolean sideEffect = new MutableBoolean(); IntSetAction action = i -> { InstanceKey I = system.getInstanceKey(i); if (!representsNullType(I)) { PointerKey p = getPointerKeyForInstanceField(I, field); if (p != null) { sideEffect.b |= system.newConstraint(p, instance); } } }; if (priorInstances != null) { value.foreachExcluding(priorInstances, action); priorInstances.addAll(value); } else { value.foreach(action); } byte sideEffectMask = sideEffect.b ? (byte) SIDE_EFFECT_MASK : 0; return (byte) (NOT_CHANGED | sideEffectMask); }
/** * Simply add the instance to each relevant points-to set. */ @Override public byte evaluate(PointsToSetVariable dummyLHS, PointsToSetVariable var) { PointsToSetVariable ref = var; if (ref.size() == 0) { return NOT_CHANGED; } IntSet value = ref.getValue(); final MutableBoolean sideEffect = new MutableBoolean(); IntSetAction action = i -> { InstanceKey I = system.getInstanceKey(i); if (!representsNullType(I)) { PointerKey p = getPointerKeyForInstanceField(I, field); if (p != null) { sideEffect.b |= system.newConstraint(p, instance); } } }; if (priorInstances != null) { value.foreachExcluding(priorInstances, action); priorInstances.addAll(value); } else { value.foreach(action); } byte sideEffectMask = sideEffect.b ? (byte) SIDE_EFFECT_MASK : 0; return (byte) (NOT_CHANGED | sideEffectMask); }