File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
utbot-framework/src/main/kotlin/org/utbot/engine Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import kotlinx.collections.immutable.persistentHashMapOf
12
12
import kotlinx.collections.immutable.persistentHashSetOf
13
13
import kotlinx.collections.immutable.persistentListOf
14
14
import kotlinx.collections.immutable.plus
15
+ import org.utbot.engine.pc.UtSolverStatusUNDEFINED
15
16
import soot.SootMethod
16
17
import soot.jimple.Stmt
17
18
@@ -205,6 +206,15 @@ data class ExecutionState(
205
206
)
206
207
}
207
208
209
+ /* *
210
+ * Tell to solver that states with status [UtSolverStatusUNDEFINED] can be created from current state.
211
+ *
212
+ * Note: Solver optimize cloning respect this flag.
213
+ */
214
+ fun expectUndefined () {
215
+ solver.expectUndefined = true
216
+ }
217
+
208
218
override fun close () {
209
219
solver.close()
210
220
}
Original file line number Diff line number Diff line change @@ -1370,6 +1370,7 @@ class UtBotSymbolicEngine(
1370
1370
val negativeCasePathConstraint = mkNot(positiveCasePathConstraint)
1371
1371
1372
1372
positiveCaseEdge?.let { edge ->
1373
+ environment.state.expectUndefined()
1373
1374
val positiveCaseState = environment.state.updateQueued(
1374
1375
edge,
1375
1376
SymbolicStateUpdate (
@@ -1435,6 +1436,9 @@ class UtBotSymbolicEngine(
1435
1436
}
1436
1437
else -> error(" Unknown switch $current " )
1437
1438
}
1439
+ if (successors.size > 1 ) {
1440
+ environment.state.expectUndefined()
1441
+ }
1438
1442
successors.forEach { (target, expr) ->
1439
1443
pathSelector.offer(
1440
1444
environment.state.updateQueued(
@@ -3432,6 +3436,7 @@ class UtBotSymbolicEngine(
3432
3436
3433
3437
val symException = implicitThrown(exception, findNewAddr(), isInNestedMethod())
3434
3438
if (! traverseCatchBlock(environment.state.stmt, symException, conditions)) {
3439
+ environment.state.expectUndefined()
3435
3440
val nextState = environment.state.createExceptionState(
3436
3441
symException,
3437
3442
queuedSymbolicStateUpdates
Original file line number Diff line number Diff line change @@ -161,16 +161,13 @@ data class UtSolver constructor(
161
161
val assertions: Set <UtBoolExpression >
162
162
get(): Set <UtBoolExpression > = constraints.hard
163
163
164
+ var expectUndefined: Boolean = false
165
+
164
166
fun add (hard : HardConstraint , soft : SoftConstraint ): UtSolver {
165
167
// status can implicitly change here to UNDEFINED or UNSAT
166
168
val newConstraints = constraints.with (hard.constraints, soft.constraints)
167
- /*
168
- Always there is at least one new state with SAT status if current status is SAT
169
- Thus we can prioritize states like this to reuse current solver.
170
- */
171
- val isSAT = constraints.status is UtSolverStatusSAT
172
- val wantClone = (isSAT && newConstraints.status is UtSolverStatusSAT )
173
- || (! isSAT && newConstraints !is UnsatQuery )
169
+ val wantClone = (expectUndefined && newConstraints.status is UtSolverStatusUNDEFINED )
170
+ || (! expectUndefined && newConstraints.status !is UtSolverStatusUNSAT )
174
171
175
172
return if (wantClone && canBeCloned) {
176
173
// try to reuse z3 Solver with value SAT when possible
You can’t perform that action at this time.
0 commit comments