Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
634f871
Add discover constants recursive function
mxprshn Sep 11, 2021
e110c7e
Try to implement persistent union find
mxprshn Sep 11, 2021
b537708
Fix discover constants to use pset
mxprshn Sep 11, 2021
4c01d0b
Try to implement path condition slicing
mxprshn Sep 13, 2021
8a823f5
Implement IndependentWith method for constant sources
mxprshn Oct 1, 2021
e788dd2
Add conditions grouping by source independence
mxprshn Oct 4, 2021
f0a6581
Move independence logic to pathCondition from pathConditionIndependent
mxprshn Oct 4, 2021
e115574
Rename constraintsWithConstants field
mxprshn Oct 7, 2021
3dcfc0b
Make persistent union-find cyclic
mxprshn Oct 8, 2021
d2d6cee
Add subset function to persistent union find
mxprshn Oct 8, 2021
b0f02e9
Add fragments iterator to pathCondition
mxprshn Oct 8, 2021
147a3bc
Add some comments
mxprshn Oct 8, 2021
e7839b4
Add some persistent union find tests
mxprshn Oct 16, 2021
f91a799
Add with independent by function and some sandbox code
mxprshn Oct 19, 2021
cee9447
Merge branch 'master' into constraint-independence
mxprshn Oct 20, 2021
22b44c1
Update commonStatedConditionalExecutionk to use constraint independence
mxprshn Oct 20, 2021
2ca9dbd
Update model in Z3 module instead of creating it
mxprshn Nov 14, 2021
e247715
Implement SubTerms for heapReading
mxprshn Nov 21, 2021
08d1672
Fix subterms for heapReading and add Slice and Union to discoverConst…
mxprshn Nov 25, 2021
e4f9696
Merge branch 'master' into constraint-independence
mxprshn Dec 1, 2021
0b9188d
Prettify code
mxprshn Dec 1, 2021
66756cc
[style] PR comments fixes
mxprshn Dec 3, 2021
4f3a431
[fix] Fix PC check for False
mxprshn Dec 3, 2021
c9dbb4a
[style] Use Option.defaultValue and rename slice args
mxprshn Dec 3, 2021
8abad91
Add StatedLogger and clear cache after model update
mxprshn Dec 24, 2021
7251d4e
Fill model with this and params
mxprshn Dec 24, 2021
99f366d
[fix] Fix namespace conflict
mxprshn Dec 24, 2021
de31156
[style] Check if pc contains cond more prettily
mxprshn Dec 26, 2021
46c76ba
[feat] Add Stopwatch module for method execution time measurement
mxprshn Feb 9, 2022
c5f1e44
[feat] Add execution time writing to csv
mxprshn Feb 14, 2022
c27b432
[feat] Measure total interpretation time
mxprshn Feb 14, 2022
487457d
Disable coverage and clear stopwatch after execution
mxprshn Feb 15, 2022
ceeea20
Merge branch 'stopwatch' into constraint-independence-time
mxprshn Feb 23, 2022
ab925c5
Measure model update and PC operations time
mxprshn Feb 23, 2022
66e517c
Measure union-find operations time
mxprshn Feb 28, 2022
36a600a
Add new mutable PC class
mxprshn Feb 28, 2022
a709a25
[feat] Implement all members of mutable PC
mxprshn Mar 5, 2022
70abd26
[feat] Replace old PC with new
mxprshn Mar 5, 2022
173fcf8
[fix] Fix empty const sequence bug and enable coverage
mxprshn Mar 6, 2022
4370685
[fix] Fix for the case when there are constraints without constants
mxprshn Mar 7, 2022
453775e
[fix] Disable coverage again
mxprshn Mar 7, 2022
b251e88
[fix] Measure time of Add and Fragments
mxprshn Mar 7, 2022
67d77da
Merge branch 'master' into merge-master-into-new-pc
mxprshn Mar 10, 2022
b325b53
[fix] Fix master merge conflicts with
mxprshn Mar 11, 2022
dc2170c
[temp] Some code for testing purposes, fixme
mxprshn Mar 20, 2022
b6906b0
[fix] Fix Slice folding
mxprshn Mar 20, 2022
4db3cc3
[style] Fix pc namings
mxprshn Mar 20, 2022
b8e663d
[fix] Remove unused persistent union find
mxprshn Mar 20, 2022
25af3e9
[style] Remove commented code
mxprshn Mar 20, 2022
6aa02e7
[style] Add comments to utils and PC
mxprshn Mar 20, 2022
747a36c
[feat] Add functional map and union for PC
mxprshn Mar 20, 2022
fbfcf51
[fix] Remove time measurement
mxprshn Mar 20, 2022
c33fa0b
[fix] Remove tagged logging
mxprshn Mar 20, 2022
f5b6252
[style] Format fixes
mxprshn Mar 20, 2022
545e56c
[fix] Remove changes in regex test
mxprshn Mar 20, 2022
62d99e3
[style] One more format fix
mxprshn Mar 20, 2022
7794e7c
Merge branch 'merge-master-into-new-pc' into constraint-independence
mxprshn Mar 20, 2022
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
23 changes: 15 additions & 8 deletions VSharp.SILI.Core/API.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module API =
| {term = ConcreteHeapAddress _} -> ()
| term -> internalfailf "Unexpected address %O in subtyping constraint!" term

PC.toSeq state.pc |> Seq.iter (term >> function
state.pc.ToSeq() |> Seq.iter (term >> function
| Constant(_, TypeCasting.TypeSubtypeTypeSource _, _) -> __notImplemented__()
| Constant(_, TypeCasting.RefSubtypeTypeSource(address, typ), _) -> add supertypeConstraints address typ
| Constant(_, TypeCasting.TypeSubtypeRefSource(typ, address), _) -> add subtypeConstraints address typ
Expand Down Expand Up @@ -229,10 +229,12 @@ module API =
| _ -> internalfailf "Unboxing: expected heap reference, but got %O" reference

let AddConstraint conditionState condition = Memory.addConstraint conditionState condition
let IsFalsePathCondition conditionState = PC.isFalse conditionState.pc
let Contradicts state condition = PC.add state.pc condition |> PC.isFalse
let PathConditionToSeq (pc : pathCondition) = PC.toSeq pc
let EmptyPathCondition = PC.empty
let IsFalsePathCondition conditionState = conditionState.pc.IsFalse
let Contradicts state condition =
let copy = PC.add condition state.pc
copy.IsFalse
let PathConditionToSeq (pc : PC.PathCondition) = pc.ToSeq()
let EmptyPathCondition() = PC.PathCondition()

module Types =
let Numeric t = Types.Numeric t
Expand Down Expand Up @@ -337,7 +339,7 @@ module API =
let EmptyStack = EvaluationStack.empty

module public Memory =
let EmptyState() = Memory.makeEmpty()
let EmptyState modelState = State.makeEmpty modelState
let PopFrame state = Memory.popFrame state
let ForcePopFrames count state = Memory.forcePopFrames count state
let PopTypeVariables state = Memory.popTypeVariablesSubstitution state
Expand Down Expand Up @@ -447,6 +449,7 @@ module API =

let MakeSymbolicThis m = Memory.makeSymbolicThis m
let MakeSymbolicValue source name typ = Memory.makeSymbolicValue source name typ
let FillWithParametersAndThis state method = Memory.fillWithParametersAndThis state method

let CallStackContainsFunction state method = CallStack.containsFunc state.stack method
let CallStackSize state = CallStack.size state.stack
Expand All @@ -460,6 +463,8 @@ module API =

let InitializeStaticMembers state targetType =
Memory.initializeStaticMembers state targetType

let Allocate state key term = Memory.allocateOnStack state key term

let AllocateTemporaryLocalVariable state typ term =
let tmpKey = TemporaryLocalVariableKey typ
Expand Down Expand Up @@ -579,7 +584,7 @@ module API =
| _ -> internalfailf "constructing string from char array: expected string reference, but got %O" dstRef

let ComposeStates state state' = Memory.composeStates state state'
let WLP state pc' = PC.mapPC (Memory.fillHoles state) pc' |> PC.union state.pc
let WLP state (pc' : PC.PathCondition) = PC.map (Memory.fillHoles state) pc' |> PC.unionWith state.pc

let Merge2States (s1 : state) (s2 : state) = Memory.merge2States s1 s2
let Merge2Results (r1, s1 : state) (r2, s2 : state) = Memory.merge2Results (r1, s1) (r2, s2)
Expand All @@ -602,7 +607,9 @@ module API =
state.lowerBounds <- PersistentDict.update state.lowerBounds typ (MemoryRegion.empty Types.lengthType) (MemoryRegion.fillRegion value)
| StackBufferSort key ->
state.stackBuffers <- PersistentDict.update state.stackBuffers key (MemoryRegion.empty Types.Int8) (MemoryRegion.fillRegion value)

let IsStackEmpty state = CallStack.isEmpty state.stack

module Print =
let Dump state = Memory.dump state
let PrintPC pc = PC.toString pc
let PrintPC (pc : PC.PathCondition) = pc.ToString()
16 changes: 10 additions & 6 deletions VSharp.SILI.Core/API.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module API =
val StatedConditionalExecutionAppendResults : (state -> (state -> (term * state -> 'a) -> 'b) -> (state -> (state list -> 'a) -> 'a) -> (state -> (state list -> 'a) -> 'a) -> (state list -> 'a) -> 'b)

val GuardedApplyExpression : term -> (term -> term) -> term
val GuardedApplyExpressionWithPC : pathCondition -> term -> (term -> term) -> term
val GuardedApplyExpressionWithPC : PC.PathCondition -> term -> (term -> term) -> term
val GuardedStatedApplyStatementK : state -> term -> (state -> term -> (term * state -> 'a) -> 'a) -> ((term * state) list -> 'a) -> 'a
val GuardedStatedApplyk : (state -> term -> ('item -> 'a) -> 'a) -> state -> term -> ('item list -> 'item list) -> ('item list -> 'a) -> 'a

Expand Down Expand Up @@ -105,8 +105,8 @@ module API =
val AddConstraint : state -> term -> unit
val IsFalsePathCondition : state -> bool
val Contradicts : state -> term -> bool
val PathConditionToSeq : pathCondition -> term seq
val EmptyPathCondition : pathCondition
val PathConditionToSeq : PC.PathCondition -> term seq
val EmptyPathCondition : unit -> PC.PathCondition

module Types =
val Numeric : System.Type -> symbolicType
Expand Down Expand Up @@ -208,7 +208,7 @@ module API =
val EmptyStack : evaluationStack

module public Memory =
val EmptyState : unit -> state
val EmptyState : state option -> state
val PopFrame : state -> unit
val ForcePopFrames : int -> state -> unit
val PopTypeVariables : state -> unit
Expand Down Expand Up @@ -241,6 +241,7 @@ module API =

val MakeSymbolicThis : MethodBase -> term
val MakeSymbolicValue : IMemoryAccessConstantSource -> string -> symbolicType -> term
val FillWithParametersAndThis : state -> MethodBase -> unit

val CallStackContainsFunction : state -> MethodBase -> bool
val CallStackSize : state -> int
Expand All @@ -250,6 +251,7 @@ module API =

val InitializeStaticMembers : state -> symbolicType -> unit

val Allocate : state -> stackKey -> term -> unit
val AllocateTemporaryLocalVariable : state -> System.Type -> term -> term
val AllocateDefaultClass : state -> symbolicType -> term
val AllocateDefaultArray : state -> term list -> symbolicType -> term
Expand Down Expand Up @@ -284,16 +286,18 @@ module API =

// TODO: get rid of all unnecessary stuff below!
val ComposeStates : state -> state -> state list
val WLP : state -> pathCondition -> pathCondition
val WLP : state -> PC.PathCondition -> PC.PathCondition

val Merge2States : state -> state -> state list
val Merge2Results : term * state -> term * state -> (term * state) list

val FillRegion : state -> term -> regionSort -> unit

val IsStackEmpty : state -> bool

module Print =
val Dump : state -> string
val PrintPC : pathCondition -> string
val PrintPC : PC.PathCondition -> string

// module Marshalling =
// val Unmarshal : state -> obj -> term * state
Expand Down
8 changes: 7 additions & 1 deletion VSharp.SILI.Core/Copying.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ module internal Copying =
interface INonComposableSymbolicConstantSource with
override x.SubTerms = seq[] :> term seq
override x.Time = VectorTime.zero
override x.IndependentWith otherSource =
match otherSource with
| :? symbolicArrayIndexSource as otherIndex ->
x.lowerBound <> otherIndex.lowerBound || x.upperBound <> otherIndex.upperBound
| _ -> true

let private makeArrayIndexConstant state lowerBound upperBound =
let source = {lowerBound = lowerBound; upperBound = upperBound}
let constant = Constant "i" source Types.Int32
let leftBound = simplifyLessOrEqual lowerBound constant id
let rightBound = simplifyLessOrEqual constant upperBound id
let pcWithBounds = PC.add (PC.add state.pc leftBound) rightBound
let pcWithBounds =
PC.add leftBound state.pc |> PC.add rightBound
state.pc <- pcWithBounds
constant

Expand Down
2 changes: 1 addition & 1 deletion VSharp.SILI.Core/Database.fs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ type path =
sprintf "{path [lvl %s]: %O}" (Level.toString x.lvl) x.state.pc

type query =
{ lvl : level; queryFml : formula } with
{ lvl : level; queryFml : formula; currentModel : model } with
override x.ToString() =
sprintf "{query [lvl %s]: %O}" (Level.toString x.lvl) x.queryFml

Expand Down
Loading