-
Notifications
You must be signed in to change notification settings - Fork 32
Constraint independence #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
VSharp.SILI.Core/PathCondition.fs
Outdated
let condConsts = discoverConstants [cond] |> PersistentSet.ofSeq | ||
let pufWithNewConsts = | ||
condConsts | ||
|> PersistentSet.filter (fun t -> None = PersistentUnionFind.tryFind t pc.constants) | ||
|> PersistentSet.fold PersistentUnionFind.add pc.constants | ||
let constsWithSources = | ||
Seq.map | ||
(function | ||
| ConstantT(_, src, _) as constant -> constant, src | ||
| _ -> __unreachable__() | ||
) | ||
// Merge sets of constants dependent in terms of ISymbolicConstantSource | ||
let pufMergedByConstantSource = | ||
Seq.allPairs | ||
(condConsts |> PersistentSet.toSeq |> constsWithSources) | ||
(pc.constants |> PersistentUnionFind.toSeq |> constsWithSources) | ||
|> Seq.filter (fun ((_, src1), (_, src2)) -> not <| src1.IndependentWith src2) | ||
|> Seq.fold (fun puf ((const1, _), (const2, _)) -> PersistentUnionFind.union const1 const2 puf) pufWithNewConsts | ||
(* | ||
Merge sets of constants dependent in terms of reachability in graph where | ||
edge between constants means that they are contained in the same condition | ||
*) | ||
let pufMergedByDependentCondition = | ||
condConsts | ||
|> someSetElement | ||
|> function | ||
| Some(parent) -> | ||
PersistentSet.fold (fun puf t -> PersistentUnionFind.union t parent puf) pufMergedByConstantSource condConsts | ||
| None -> pufMergedByConstantSource | ||
{constants = pufMergedByDependentCondition | ||
conditionsWithConstants = | ||
condConsts | ||
|> someSetElement | ||
|> (fun head -> PersistentDict.add cond head pc.conditionsWithConstants)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше это выделить в отдельную функцию
VSharp.SILI.Core/Memory.fs
Outdated
|> function | ||
| Some(fragment) -> fragment | ||
| None -> pc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вероятно, Option.defaultValue здесь будет лучше смотреться
VSharp.SILI.Core/PathCondition.fs
Outdated
let constsWithSources = | ||
Seq.map | ||
(function | ||
| ConstantT(_, src, _) as constant -> constant, src | ||
| _ -> __unreachable__() | ||
) | ||
// Merge sets of constants dependent in terms of ISymbolicConstantSource | ||
let pufMergedByConstantSource = | ||
Seq.allPairs | ||
(condConsts |> PersistentSet.toSeq |> constsWithSources) | ||
(pc.constants |> PersistentUnionFind.toSeq |> constsWithSources) | ||
|> Seq.filter (fun ((_, src1), (_, src2)) -> not <| src1.IndependentWith src2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source из константы не нужен в последствии, поэтому вместо создания последовательности из пар (константа, source), стоит объявить функцию, которая будет принимать пару конастант и сравнивать их source
VSharp.SILI.Core/PathCondition.fs
Outdated
pc.conditionsWithConstants | ||
|> PersistentDict.fold groupConditionsByUnionFindParent PersistentDict.empty | ||
|> PersistentDict.toSeq | ||
|> Seq.map conditionsGroupToPathCondition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Стоит добавить пустую строчку, чтобы гит не ругался
VSharp.SILI.Core/PathCondition.fs
Outdated
|> function | ||
| Some(someConst) -> PersistentUnionFind.tryFind someConst pc.constants | ||
| None -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут можно использовать Option.bind
VSharp.Utils/PersistentUnionFind.fs
Outdated
traverse unwrappedNext updatedDict | ||
else updatedDict | ||
let subsetElements = traverse a PersistentDict.empty | ||
{elements = subsetElements} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно добавить пустую строчку в конец файла
@@ -333,6 +349,20 @@ module internal Memory = | |||
let declaringType = fromDotNetType m.DeclaringType | |||
if isValueType declaringType then __insufficientInformation__ "Can't execute in isolation methods of value types, because we can't be sure where exactly \"this\" is allocated!" | |||
else HeapRef (Constant "this" {baseSource = {key = ThisKey m; time = Some VectorTime.zero}} AddressType) declaringType | |||
|
|||
let fillWithParametersAndThis state (method : System.Reflection.MethodBase) = | |||
let parameters = method.GetParameters() |> Seq.map (fun param -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В этом месте не уверен по поводу того, нужно ли вместе с параметрами добавить что-то в allocatedTypes у state
Сломалась версия runtime, пофикшу |
// let usedPaths = | ||
// pathAtoms | ||
// |> Seq.filter (fun atom -> z3Model.Eval(atom, false).IsTrue) | ||
// |> Seq.map (fun atom -> paths.[atom]) | ||
SmtSat { mdl = model; usedPaths = [](*usedPaths*) } | ||
builder.ClearT2E() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Немного напрягло, что пришлось чистить кэш (иначе в модель попадали лишние константы из кэша)
Перенесено в общий пуллреквест с оптимизациями |
No description provided.