Skip to content
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

[Civl] Fix Lheap and add Lmap #825

Merged
merged 5 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions Source/Concurrency/LinearDomainCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,23 @@ private Dictionary<Type, LinearDomain> MakeLinearDomains()
}
if (!permissionTypeToCollectors[permissionType].ContainsKey(type))
{
var typeParamInstantiationMap = new Dictionary<string, Type> { { "V", actualTypeParams[0] } };
var collector =
originalTypeCtorDecl.Name == "Lheap"
? program.monomorphizer.InstantiateFunction("Lheap_Collector", typeParamInstantiationMap) :
originalTypeCtorDecl.Name == "Lset"
? program.monomorphizer.InstantiateFunction("Lset_Collector", typeParamInstantiationMap) :
program.monomorphizer.InstantiateFunction("Lval_Collector", typeParamInstantiationMap);
permissionTypeToCollectors[permissionType].Add(type, collector);
if (originalTypeCtorDecl.Name == "Lmap")
{
var typeParamInstantiationMap = new Dictionary<string, Type> { { "K", actualTypeParams[0] }, { "V", actualTypeParams[1] } };
var collector = program.monomorphizer.InstantiateFunction("Lmap_Collector", typeParamInstantiationMap);
permissionTypeToCollectors[permissionType].Add(type, collector);
}
else
{
var typeParamInstantiationMap = new Dictionary<string, Type> { { "V", actualTypeParams[0] } };
var collector =
originalTypeCtorDecl.Name == "Lheap"
? program.monomorphizer.InstantiateFunction("Lheap_Collector", typeParamInstantiationMap) :
originalTypeCtorDecl.Name == "Lset"
? program.monomorphizer.InstantiateFunction("Lset_Collector", typeParamInstantiationMap) :
program.monomorphizer.InstantiateFunction("Lval_Collector", typeParamInstantiationMap);
permissionTypeToCollectors[permissionType].Add(type, collector);
}
}
}
var permissionTypeToLinearDomain =
Expand Down
4 changes: 2 additions & 2 deletions Source/Concurrency/LinearPermissionInstrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public List<Cmd> ProcDisjointnessAndWellFormedAssumeCmds(Procedure proc, bool at
? FilterInParams(proc.InParams)
: FilterInOutParams(proc.InParams.Union(proc.OutParams));
return DisjointnessExprs(availableVars)
.Union(civlTypeChecker.linearTypeChecker.LheapWellFormedExpressions(availableVars))
.Union(civlTypeChecker.linearTypeChecker.LstoreWellFormedExpressions(availableVars))
.Select(expr => CmdHelper.AssumeCmd(expr)).ToList<Cmd>();
}

public List<Cmd> DisjointnessAndWellFormedAssumeCmds(Absy absy, bool addGlobals)
{
var availableVars = AvailableLinearLocalVars(absy).Union(addGlobals ? LinearGlobalVars() : new List<Variable>());
return DisjointnessExprs(availableVars)
.Union(civlTypeChecker.linearTypeChecker.LheapWellFormedExpressions(availableVars))
.Union(civlTypeChecker.linearTypeChecker.LstoreWellFormedExpressions(availableVars))
.Select(expr => CmdHelper.AssumeCmd(expr)).ToList<Cmd>();
}

Expand Down
Loading
Loading