Skip to content

Commit 5e3103c

Browse files
committed
Optimizations
1 parent cb18154 commit 5e3103c

File tree

31 files changed

+884
-669
lines changed

31 files changed

+884
-669
lines changed

utbot-analytics/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ dependencies {
1414
testImplementation project(':utbot-sample')
1515
testImplementation group: 'junit', name: 'junit', version: junit4Version
1616

17-
implementation "org.unittestbot.soot:soot-utbot-fork:${sootVersion}"
17+
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}") {
18+
exclude group:'com.google.guava', module:'guava'
19+
}
1820
implementation group: 'com.github.haifengl', name: 'smile-kotlin', version: '2.6.0'
1921
implementation group: 'com.github.haifengl', name: 'smile-plot', version: '2.6.0'
2022
implementation group: 'com.github.haifengl', name: 'smile-core', version: '2.6.0'

utbot-framework-api/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ dependencies {
1515
api(project(":utbot-rd"))
1616
implementation(group ="com.jetbrains.rd", name = "rd-framework", version = "2022.3.1")
1717
implementation(group ="com.jetbrains.rd", name = "rd-core", version = "2022.3.1")
18-
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}")
18+
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}") {
19+
exclude(group="com.google.guava", module="guava")
20+
}
1921
implementation(group = "io.github.microutils", name = "kotlin-logging", version = kotlinLoggingVersion)
2022
// TODO do we really need apache commons?
2123
implementation(group = "org.apache.commons", name = "commons-lang3", version = commonsLangVersion)

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

399428
/**

utbot-framework-test/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ dependencies {
3232
testImplementation project(":utbot-framework").sourceSets.test.output
3333
testImplementation project(":utbot-core").sourceSets.test.output
3434

35-
implementation "org.unittestbot.soot:soot-utbot-fork:${sootVersion}"
35+
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}") {
36+
exclude group:'com.google.guava', module:'guava'
37+
}
3638

3739
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: jacksonVersion
3840
implementation group: 'org.sosy-lab', name: 'javasmt-solver-z3', version: javasmtSolverZ3Version

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/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ dependencies {
1919
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: '2022.3.1'
2020
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: '2022.3.1'
2121

22-
implementation "org.unittestbot.soot:soot-utbot-fork:${sootVersion}"
22+
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}") {
23+
exclude group:'com.google.guava', module:'guava'
24+
}
25+
implementation group: 'com.google.guava', name: 'guava', version: guavaVersion
2326
implementation group: 'com.esotericsoftware.kryo', name: 'kryo5', version: kryoVersion
2427
// this is necessary for serialization of some collections
2528
implementation group: 'de.javakaffee', name: 'kryo-serializers', version: kryoSerializersVersion

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)