Skip to content

Commit

Permalink
Merge pull request #120 from nevillegrech/unsoundness_global_experiment
Browse files Browse the repository at this point in the history
Introduce `incompleteGlobal` analysis round, other changes
  • Loading branch information
sifislag authored Dec 18, 2023
2 parents 02c8f5b + fd45249 commit 5338247
Show file tree
Hide file tree
Showing 16 changed files with 491 additions and 211 deletions.
47 changes: 35 additions & 12 deletions logic/context-sensitivity/abstract_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
.input InputMaxContextDepth(filename="MaxContextDepth.csv")

MaxContextDepth(sigHash, d) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
InputMaxContextDepth(d).


MaxContextDepth(sigHash, 10) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
!InputMaxContextDepth(_).
}
Expand Down Expand Up @@ -280,21 +280,44 @@
*/

#ifndef NO_PUBLIC_CONTEXT
MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
// MergeContext(ctx, caller, ctx) :-
// ReachableContext(ctx, caller),
// local.PublicFunctionJump(caller, sigHash, _),
// !MaxContextDepth(sigHash, -1),
// DecomposeContext(ctx, prevSigHash, _),
// prevSigHash != FALLBACK_FUNCTION_SIGHASH.
// .plan 1:(3,1,2)
// MergeContext(ctx, caller, newContext):-
// ReachableContext(ctx, caller),
// local.PublicFunctionJump(caller, sigHash, _),
// !MaxContextDepth(sigHash, -1),
// DecomposeContext(ctx, prevSigHash, pri),
// prevSigHash = FALLBACK_FUNCTION_SIGHASH,
// newContext = [sigHash, pri].
// .plan 1:(3,1,2)

MergeContextResponse(ctx, caller, funcStart, ctx) :-
MergeContextRequest(ctx, caller, funcStart),
local.PublicFunctionJump(caller, sigHash, _),
local.PublicFunction(funcStart, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, _),
prevSigHash != FALLBACK_FUNCTION_SIGHASH.
.plan 1:(3,1,2)
MergeContext(ctx, caller, newContext):-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
.plan 1:(4,1,2,3)
MergeContextResponse(ctx, caller, funcStart, newContext) :-
MergeContextRequest(ctx, caller, funcStart),
local.PublicFunctionJump(caller, sigHash, _),
local.PublicFunction(funcStart, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, pri),
prevSigHash = FALLBACK_FUNCTION_SIGHASH,
DecomposeContext(ctx, FALLBACK_FUNCTION_SIGHASH, pri),
newContext = [sigHash, pri].
.plan 1:(3,1,2)
.plan 1:(4,1,2,3)
MergeContextResponse(ctx, caller, funcStart, ctx) :-
MergeContextRequest(ctx, caller, funcStart),
local.PublicFunctionJump(caller, sigHash, _),
!local.PublicFunction(funcStart, sigHash, _),
!MaxContextDepth(sigHash, -1).

#endif
}

2 changes: 1 addition & 1 deletion logic/context-sensitivity/callsite_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ReachableContext(ctx, caller),
DecomposeContext(ctx, pub, pri),
TruncateContextIfNeeded(pub, pri, cutDownPri),
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
newPrivateContext = [caller, cutDownPri].
.plan 1:(2,1,3), 2:(3,2,1)
}
14 changes: 7 additions & 7 deletions logic/context-sensitivity/finite_precise_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
.input InputMaxContextDepth(filename="MaxContextDepth.csv")

MaxContextDepth(sigHash, d) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
InputMaxContextDepth(d).

// HERE: much deeper
MaxContextDepth(sigHash, 27) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
!InputMaxContextDepth(_).

Expand Down Expand Up @@ -135,14 +135,14 @@
#ifndef NO_PUBLIC_CONTEXT
MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, _),
prevSigHash != FALLBACK_FUNCTION_SIGHASH.
.plan 1:(3,1,2)
MergeContext(ctx, caller, newContext):-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, pri),
prevSigHash = FALLBACK_FUNCTION_SIGHASH,
Expand All @@ -163,14 +163,14 @@
MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
!local.PrivateFunctionCallOrReturn(caller).

MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
DecomposeContext(ctx, pub, _),
MaxContextDepth(pub, 0).
Expand All @@ -184,7 +184,7 @@
DecomposeContext(ctx, pub, pri),
TruncateContextIfNeeded(pub, pri, cutDownPri),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
newPrivateContext = [caller, cutDownPri].
.plan 1:(3,1,2,4), 2:(4,3,1,2)
Expand Down
18 changes: 9 additions & 9 deletions logic/context-sensitivity/finite_shrinking_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
.input InputMaxContextDepth(filename="MaxContextDepth.csv")

MaxContextDepth(sigHash, d) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
InputMaxContextDepth(d).

// HERE: much deeper
MaxContextDepth(sigHash, 10) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
!InputMaxContextDepth(_).

Expand Down Expand Up @@ -97,14 +97,14 @@
#ifndef NO_PUBLIC_CONTEXT
MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, _),
prevSigHash != FALLBACK_FUNCTION_SIGHASH.
.plan 1:(3,1,2)
MergeContext(ctx, caller, newContext):-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, pri),
prevSigHash = FALLBACK_FUNCTION_SIGHASH,
Expand All @@ -123,12 +123,12 @@
// Split into two rules to add plan.
MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
!local.PrivateFunctionCallOrReturn(caller).

MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
DecomposeContext(ctx, pub, _),
MaxContextDepth(pub, 0).
.plan 1:(2,3,1)
Expand All @@ -147,7 +147,7 @@
ReachableContext(ctx, caller),
local.PrivateFunctionCall(caller, _, _, _),
DecomposeAndTruncateIfNeeded(ctx, pub, cutDownAtEndPri),
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
newPrivateContext = [caller, cutDownAtEndPri].
.plan 1:(3,1,2)

Expand Down Expand Up @@ -196,7 +196,7 @@
MergeContextRequest(ctx, block, cont),
PrivateFunctionReturn(block),
DecomposeContext(ctx, pub, priCtx),
!local.PublicFunction(block, _),
!local.PublicFunction(block, _, _),
CutToCaller(priCtx, cont, cutPri).
.plan 1:(3,1,2,4), 2:(4,3,1,2)

Expand All @@ -207,7 +207,7 @@
DecomposeContext(ctx, pub, priCtx),
DecomposeAndTruncateIfNeeded(ctx, pub, cutDownAtEndPri),
NoCutToCaller(priCtx, cont),
!local.PublicFunction(block, _),
!local.PublicFunction(block, _, _),
newPrivateContext = [block, cutDownAtEndPri].
.plan 1:(3,1,2,4,5), 2:(4,3,1,2,5), 3:(5,3,1,2,4)

Expand Down
16 changes: 8 additions & 8 deletions logic/context-sensitivity/hybrid_precise_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
.input InputMaxImpreciseContextDepth(filename="MaxContextDepth.csv")

MaxImpreciseContextDepth(sigHash, d) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
InputMaxImpreciseContextDepth(d).

MaxImpreciseContextDepth(sigHash, 7) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH),
!InputMaxImpreciseContextDepth(_).

// Not yet configurable via input file
.decl MaxPreciseContextDepth(sigHash: symbol, d: number)
MaxPreciseContextDepth(sigHash, 27) :-
(local.PublicFunction(_, sigHash);
(local.PublicFunction(_, sigHash, _);
sigHash = FALLBACK_FUNCTION_SIGHASH).

//
Expand Down Expand Up @@ -253,14 +253,14 @@
#ifndef NO_PUBLIC_CONTEXT
MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxImpreciseContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, _),
prevSigHash != FALLBACK_FUNCTION_SIGHASH.
.plan 1:(3,1,2)
MergeContext(ctx, caller, newContext) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunction(caller, sigHash, _),
!MaxImpreciseContextDepth(sigHash, -1),
DecomposeContext(ctx, prevSigHash, pri),
prevSigHash = FALLBACK_FUNCTION_SIGHASH,
Expand All @@ -280,14 +280,14 @@
MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
!local.PrivateFunctionCallOrReturn(caller).

MergeContext(ctx, caller, ctx) :-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
DecomposeContext(ctx, pub, _),
MaxImpreciseContextDepth(pub, 0).
Expand All @@ -301,7 +301,7 @@
DecomposeContext(ctx, pub, pri),
TruncateContextIfNeeded(pub, pri, cutDownPri),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunction(caller, _, _),
#endif
newPrivateContext = [caller, cutDownPri].
.plan 1:(3,1,2,4), 2:(4,3,1,2)
Expand Down
6 changes: 3 additions & 3 deletions logic/context-sensitivity/selective_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
local.BlockHasTrivialControl(caller),
!local.PublicFunction(caller, _).
!local.PublicFunctionJump(caller, _, _).

MergeContext(ctx, caller, [pub, newPrivateContext]):-
ReachableContext(ctx, caller),
DecomposeContext(ctx, pub, pri),
TruncateContextIfNeeded(pub, pri, cutDownPri),
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
!local.BlockHasTrivialControl(caller),
newPrivateContext = [caller, cutDownPri].
.plan 1:(2,1,3), 2:(3,2,1)

MergeContext(ctx, caller, newContext) :-
ReachableContext(ctx, caller),
local.PublicFunction(caller, sigHash),
local.PublicFunctionJump(caller, sigHash, _),
!MaxContextDepth(sigHash, -1),
DecomposeContext(ctx, _, callCtx),
newContext = [sigHash, callCtx].
Expand Down
6 changes: 3 additions & 3 deletions logic/context-sensitivity/transactional_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
#endif
!local.PrivateFunctionCallOrReturn(caller).

MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
#endif
DecomposeContext(ctx, pub, _),
MaxContextDepth(pub, 0).
Expand All @@ -26,7 +26,7 @@
DecomposeContext(ctx, pub, pri),
TruncateContextIfNeeded(pub, pri, cutDownPri),
#ifndef NO_PUBLIC_CONTEXT
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
#endif
newPrivateContext = [caller, cutDownPri].
.plan 1:(3,1,2,4), 2:(4,3,1,2)
Expand Down
10 changes: 5 additions & 5 deletions logic/context-sensitivity/transactional_shrinking_context.dl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// Split into two rules to add plan.
MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
!local.PrivateFunctionCallOrReturn(caller).

MergeContext(ctx, caller, ctx):-
ReachableContext(ctx, caller),
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
DecomposeContext(ctx, pub, _),
MaxContextDepth(pub, 0).
.plan 1:(2,3,1)
Expand All @@ -29,7 +29,7 @@
ReachableContext(ctx, caller),
local.PrivateFunctionCall(caller, _, _, _),
DecomposeAndTruncateIfNeeded(ctx, pub, cutDownAtEndPri),
!local.PublicFunction(caller, _),
!local.PublicFunctionJump(caller, _, _),
newPrivateContext = [caller, cutDownAtEndPri].
.plan 1:(3,1,2)

Expand Down Expand Up @@ -78,7 +78,7 @@
MergeContextRequest(ctx, block, cont),
PrivateFunctionReturn(block),
DecomposeContext(ctx, pub, priCtx),
!local.PublicFunction(block, _),
!local.PublicFunctionJump(block, _, _),
CutToCaller(priCtx, cont, cutPri).
.plan 1:(3,1,2,4), 2:(4,3,1,2)

Expand All @@ -89,7 +89,7 @@
DecomposeContext(ctx, pub, priCtx),
DecomposeAndTruncateIfNeeded(ctx, pub, cutDownAtEndPri),
NoCutToCaller(priCtx, cont),
!local.PublicFunction(block, _),
!local.PublicFunctionJump(block, _, _),
newPrivateContext = [block, cutDownAtEndPri].
.plan 1:(3,1,2,4,5), 2:(4,3,1,2,5), 3:(5,3,1,2,4)

Expand Down
Loading

0 comments on commit 5338247

Please sign in to comment.