@@ -19,6 +19,7 @@ private val logger = KotlinLogging.logger {}
19
19
20
20
// TODO usvm-sbft-refactoring: copied from `usvm/usvm-jvm/test`, extract this class back to USVM project
21
21
class JcContainer private constructor(
22
+ usePersistence : Boolean ,
22
23
classpath : List <File >,
23
24
machineOptions : UMachineOptions ,
24
25
builder : JcSettings .() -> Unit ,
@@ -29,8 +30,27 @@ class JcContainer private constructor(
29
30
val runner: UTestConcreteExecutor
30
31
31
32
init {
33
+ val cpPath = classpath.map { it.absolutePath }.sorted()
34
+
35
+ /* *
36
+ * Persist jacodb cp to achieve:
37
+ * 1. Faster concrete executor initialization
38
+ * 2. Faster analysis for classes from the same cp
39
+ * */
40
+ val persistenceLocation = if (usePersistence) {
41
+ " jcdb-persistence-${cpPath.hashCode()} "
42
+ } else {
43
+ null
44
+ }
45
+
32
46
val (db, cp) = runBlocking {
33
- val db = jacodb(builder)
47
+ val db = jacodb {
48
+ builder()
49
+
50
+ if (persistenceLocation != null ) {
51
+ persistent(location = persistenceLocation, clearOnStart = false )
52
+ }
53
+ }
34
54
val cp = db.classpathWithApproximations(classpath, listOf (UnknownClasses ))
35
55
db to cp
36
56
}
@@ -39,8 +59,9 @@ class JcContainer private constructor(
39
59
this .machine = JcMachine (cp, machineOptions)
40
60
this .runner = UTestConcreteExecutor (
41
61
JcRuntimeTraceInstrumenterFactory ::class ,
42
- classpath.map { it.absolutePath } ,
62
+ cpPath ,
43
63
cp,
64
+ persistenceLocation,
44
65
CONTEST_TEST_EXECUTION_TIMEOUT
45
66
)
46
67
runBlocking {
@@ -61,6 +82,7 @@ class JcContainer private constructor(
61
82
private val cache = HashMap <Pair <List <File >, UMachineOptions > , JcContainer > ()
62
83
63
84
operator fun invoke (
85
+ usePersistence : Boolean ,
64
86
classpath : List <File >,
65
87
machineOptions : UMachineOptions ,
66
88
builder : JcSettings .() -> Unit ,
@@ -70,7 +92,7 @@ class JcContainer private constructor(
70
92
// TODO usvm-sbft: right now max cache size is 1, do we need to increase it?
71
93
logger.info { " JcContainer cache miss" }
72
94
close()
73
- JcContainer (classpath, machineOptions, builder).also { cache[cacheKey] = it }
95
+ JcContainer (usePersistence, classpath, machineOptions, builder).also { cache[cacheKey] = it }
74
96
}
75
97
}
76
98
0 commit comments