Skip to content

Commit

Permalink
optimizing contexts (the "no cut" case)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanniss committed Feb 5, 2025
1 parent 82fd3fa commit f68d1f9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
21 changes: 19 additions & 2 deletions logic/context-sensitivity/finite_shrinking_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
PrivateContextDepth(ctx, depth),
MaxContextDepth(pubFun, maxDepth),
depth < maxDepth.

.plan 1:(2,1,3)

Context_PublicFunction(ctx, pubFun):-
ReachableContext(ctx, _),
ctx = [pubFun, callCtx],
Expand Down Expand Up @@ -171,6 +172,21 @@
MergeContextRequest(_, retBlock, continuation),
PrivateFunctionReturn(retBlock).

// This is just a filtering/optimization predicate, to avoid worst-case blowup of NoCutToCaller.
// Eliminating it only affects performance.
.decl InterestingContinuationForPrivateCtx(priCtx: PrivateContext, continuation: Block)
InterestingContinuationForPrivateCtx(priCtx, cont) :-
MergeContextRequest(ctx, block, cont),
PrivateFunctionReturn(block),
DecomposeContext(ctx, _, priCtx).
.plan 1:(3,1,2)

InterestingContinuationForPrivateCtx(nextPriCtx, continuation) :-
InterestingContinuationForPrivateCtx(priCtx, continuation),
DecomposePrivateContext(priCtx, _, nextPriCtx).
.plan 1:(2,1)


.decl NoCutToCaller(priCtx: PrivateContext, continuation: Block) overridable
NoCutToCaller(initPriCtx, cont) :-
PossibleContinuationFromReturn(cont),
Expand All @@ -179,8 +195,9 @@
NoCutToCaller(priCtx, cont) :-
NoCutToCaller(nextPriCtx, cont),
DecomposePrivateContext(priCtx, head, nextPriCtx),
InterestingContinuationForPrivateCtx(priCtx, cont),
!local.PrivateFunctionCall(head, _, cont, cont).
.plan 1:(2,1)
.plan 1:(2,1,3), 2:(3,2,1)

NoCutToCaller(priCtx, cont) :-
CutToCaller(nextPriCtx, cont, _),
Expand Down
20 changes: 18 additions & 2 deletions logic/context-sensitivity/transactional_shrinking_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,22 @@
PossibleContinuationFromReturn(continuation) :-
MergeContextRequest(_, retBlock, continuation),
PrivateFunctionReturn(retBlock).


// This is just a filtering/optimization predicate, to avoid worst-case blowup of NoCutToCaller.
// Eliminating it only affects performance.
.decl InterestingContinuationForPrivateCtx(priCtx: PrivateContext, continuation: Block)
InterestingContinuationForPrivateCtx(priCtx, cont) :-
MergeContextRequest(ctx, block, cont),
PrivateFunctionReturn(block),
DecomposeContext(ctx, _, priCtx).
.plan 1:(3,1,2)

InterestingContinuationForPrivateCtx(nextPriCtx, continuation) :-
InterestingContinuationForPrivateCtx(priCtx, continuation),
DecomposePrivateContext(priCtx, _, nextPriCtx).
.plan 1:(2,1)


.decl NoCutToCaller(priCtx: PrivateContext, continuation: Block) overridable
NoCutToCaller(initPriCtx, cont) :-
PossibleContinuationFromReturn(cont),
Expand All @@ -74,8 +89,9 @@
NoCutToCaller(priCtx, cont) :-
NoCutToCaller(nextPriCtx, cont),
DecomposePrivateContext(priCtx, head, nextPriCtx),
InterestingContinuationForPrivateCtx(priCtx, cont),
!local.PrivateFunctionCall(head, _, cont, cont).
.plan 1:(2,1)
.plan 1:(2,1,3), 2:(3,2,1)

NoCutToCaller(priCtx, cont) :-
CutToCaller(nextPriCtx, cont, _),
Expand Down

0 comments on commit f68d1f9

Please sign in to comment.