Skip to content

Commit ef583bf

Browse files
committed
Optimizations
1 parent 145da7d commit ef583bf

File tree

24 files changed

+862
-662
lines changed

24 files changed

+862
-662
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,35 @@ object UtSettings : AbstractSettings(
395395
* therefore, you will be unable to test UtBot classes.
396396
*/
397397
var removeUtBotClassesFromHierarchy by getBooleanProperty(true)
398+
399+
/**
400+
* Use this option to enable calculation and logging of MD5 for dropped states by statistics.
401+
* Example of such logging:
402+
* Dropping state (lastStatus=UNDEFINED) by the distance statistics. MD5: 5d0bccc242e87d53578ca0ef64aa5864
403+
*
404+
* Default value is false.
405+
*/
406+
var enableLoggingForDroppedStates by getBooleanProperty(false)
407+
408+
/**
409+
* If this option set in true, depending on the number of possible types for
410+
* a particular object will be used either type system based on conjunction
411+
* or on bit vectors.
412+
*
413+
* @see useBitVecBasedTypeSystem
414+
*/
415+
var useBitVecBasedTypeSystem by getBooleanProperty(true)
416+
417+
/**
418+
* The number of types on which the choice of the type system depends.
419+
*/
420+
var maxTypeNumberForEnumeration by getIntProperty(64)
421+
422+
/**
423+
* The threshold for numbers of types for which they will be encoded into solver.
424+
* It is used to do not encode big type storages due to significand performance degradation.
425+
*/
426+
var maxNumberOfTypesToEncode by getIntProperty(512)
398427
}
399428

400429
/**

utbot-framework-test/src/test/kotlin/org/utbot/examples/arrays/ArrayOfArraysTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utbot.examples.arrays
22

3+
import org.junit.jupiter.api.Disabled
34
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
45
import org.utbot.tests.infrastructure.DoNotCalculate
56
import org.utbot.tests.infrastructure.atLeast
@@ -268,10 +269,13 @@ internal class ArrayOfArraysTest : UtValueTestCaseChecker(testClass = ArrayOfArr
268269
}
269270

270271
@Test
272+
@Disabled("TODO create a task for it")
271273
fun testArrayWithItselfAnAsElement() {
272274
check(
273275
ArrayOfArrays::arrayWithItselfAnAsElement,
274276
eq(2),
277+
{ a, r -> a !== a[0] && r == null },
278+
{ a, r -> a === a[0] && a.contentDeepEquals(r) },
275279
coverage = atLeast(percents = 94)
276280
// because of the assumption
277281
)

utbot-framework/src/main/kotlin/org/utbot/engine/ArrayObjectWrappers.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import org.utbot.engine.pc.mkInt
1818
import org.utbot.engine.pc.select
1919
import org.utbot.engine.pc.store
2020
import org.utbot.engine.symbolic.asHardConstraint
21+
import org.utbot.engine.types.OBJECT_TYPE
22+
import org.utbot.engine.types.TypeRegistry
2123
import org.utbot.framework.plugin.api.ClassId
2224
import org.utbot.framework.plugin.api.UtArrayModel
2325
import org.utbot.framework.plugin.api.UtCompositeModel

utbot-framework/src/main/kotlin/org/utbot/engine/ConstructedSootMethods.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.utbot.engine
22

3+
import org.utbot.engine.types.OBJECT_TYPE
4+
import org.utbot.engine.types.STRING_TYPE
35
import soot.ArrayType
46
import soot.IntType
57
import soot.PrimType

utbot-framework/src/main/kotlin/org/utbot/engine/DataClasses.kt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package org.utbot.engine
22

3-
import org.utbot.common.WorkaroundReason
4-
import org.utbot.common.workaround
5-
import org.utbot.engine.TypeRegistry.Companion.objectTypeStorage
3+
import org.utbot.api.mock.UtMock
4+
import org.utbot.engine.overrides.UtOverrideMock
5+
import org.utbot.engine.types.TypeRegistry.Companion.objectTypeStorage
66
import org.utbot.engine.pc.UtAddrExpression
77
import org.utbot.engine.pc.UtBoolExpression
8+
import org.utbot.engine.pc.UtFalse
89
import org.utbot.engine.pc.UtInstanceOfExpression
910
import org.utbot.engine.pc.UtIsExpression
1011
import org.utbot.engine.pc.UtTrue
1112
import org.utbot.engine.pc.mkAnd
1213
import org.utbot.engine.pc.mkOr
1314
import org.utbot.engine.symbolic.*
15+
import org.utbot.engine.types.OBJECT_TYPE
16+
import org.utbot.engine.types.TypeResolver
1417
import org.utbot.framework.plugin.api.FieldId
1518
import org.utbot.framework.plugin.api.UtInstrumentation
1619
import soot.RefType
@@ -125,6 +128,9 @@ class TypeStorage private constructor(val leastCommonType: Type, val possibleCon
125128
"(leastCommonType=$leastCommonType, ${possibleConcreteTypes.size} possibleTypes=${possibleConcreteTypes.take(10)})"
126129
}
127130

131+
operator fun component1(): Type = leastCommonType
132+
operator fun component2(): Set<Type> = possibleConcreteTypes
133+
128134
companion object {
129135
/**
130136
* Constructs a type storage with particular leastCommonType and set of possibleConcreteTypes.
@@ -307,7 +313,16 @@ data class TypeConstraint(
307313
/**
308314
* Returns a conjunction of the [isConstraint] and [correctnessConstraint]. Suitable for an object creation.
309315
*/
310-
fun all(): UtBoolExpression = mkAnd(isOrNullConstraint(), correctnessConstraint)
316+
fun all(): UtBoolExpression {
317+
// There is no need in constraint for UtMock and UtOverrideMock instances
318+
val className = (isConstraint.type as? RefType)?.sootClass?.toString()
319+
320+
if (className == utMockClassName || className == utOverrideMockClassName) {
321+
return UtTrue
322+
}
323+
324+
return mkAnd(isOrNullConstraint()/*, correctnessConstraint*/)
325+
}
311326

312327
/**
313328
* Returns a condition that either the object is an instance of the types in [isConstraint], or it is null.
@@ -319,7 +334,13 @@ data class TypeConstraint(
319334
* For example, it is suitable for instanceof checks or negation of equality with some types.
320335
* NOTE: for Object we always return UtTrue.
321336
*/
322-
fun isConstraint(): UtBoolExpression = if (isConstraint.typeStorage.isObjectTypeStorage()) UtTrue else isConstraint
337+
fun isConstraint(): UtBoolExpression {
338+
if (isConstraint.typeStorage.possibleConcreteTypes.isEmpty()) {
339+
return UtFalse
340+
}
341+
342+
return if (isConstraint.typeStorage.isObjectTypeStorage()) UtTrue else isConstraint
343+
}
323344

324345
override fun hashCode(): Int = this.hashcode
325346

@@ -344,3 +365,6 @@ data class TypeConstraint(
344365
* should be initialized. We don't need to initialize fields that are not accessed in the method being tested.
345366
*/
346367
data class InstanceFieldReadOperation(val addr: UtAddrExpression, val fieldId: FieldId)
368+
369+
private val utMockClassName: String = UtMock::class.java.name
370+
private val utOverrideMockClassName: String = UtOverrideMock::class.java.name

utbot-framework/src/main/kotlin/org/utbot/engine/ExecutionState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import soot.SootMethod
1818
import soot.jimple.Stmt
1919
import java.util.Objects
2020
import org.utbot.engine.symbolic.Assumption
21-
import org.utbot.framework.plugin.api.UtSymbolicExecution
2221

2322
const val RETURN_DECISION_NUM = -1
2423
const val CALL_DECISION_NUM = -2

utbot-framework/src/main/kotlin/org/utbot/engine/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import org.utbot.engine.pc.UtFp32Sort
1414
import org.utbot.engine.pc.UtFp64Sort
1515
import org.utbot.engine.pc.UtIntSort
1616
import org.utbot.engine.pc.UtLongSort
17-
import org.utbot.engine.pc.UtSeqSort
1817
import org.utbot.engine.pc.UtShortSort
1918
import org.utbot.engine.pc.UtSolverStatusKind
2019
import org.utbot.engine.pc.UtSolverStatusSAT
@@ -67,6 +66,7 @@ import java.util.Queue
6766
import java.util.concurrent.ConcurrentHashMap
6867
import kotlinx.collections.immutable.PersistentMap
6968
import kotlinx.collections.immutable.persistentHashMapOf
69+
import org.utbot.engine.types.OBJECT_TYPE
7070

7171
val JIdentityStmt.lines: String
7272
get() = tags.joinToString { "$it" }

utbot-framework/src/main/kotlin/org/utbot/engine/Hierarchy.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utbot.engine
22

3+
import org.utbot.engine.types.TypeRegistry
34
import org.utbot.framework.plugin.api.ClassId
45
import org.utbot.framework.plugin.api.id
56
import soot.RefType

0 commit comments

Comments
 (0)