Skip to content

Commit 53c5f35

Browse files
MForest7Lipen
andauthored
Add live variables analysis before type inference (#267)
Co-authored-by: Konstantin Chukharev <[email protected]>
1 parent a2242a9 commit 53c5f35

File tree

11 files changed

+424
-129
lines changed

11 files changed

+424
-129
lines changed

Diff for: usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/graph/EtsApplicationGraph.kt

+6-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class EtsApplicationGraphImpl(
104104
.flatMap { it.methods }
105105
.groupByTo(hashMapOf()) { it.name }
106106
}
107+
private val classMethodsByName by lazy {
108+
projectClassesBySignature.mapValues { (_, clazz) ->
109+
clazz.single().methods.groupBy { it.name }
110+
}
111+
}
107112

108113
private val cacheClassWithIdealSignature: MutableMap<EtsClassSignature, Maybe<EtsClass>> = hashMapOf()
109114
private val cacheMethodWithIdealSignature: MutableMap<EtsMethodSignature, Maybe<EtsMethod>> = hashMapOf()
@@ -227,11 +232,8 @@ class EtsApplicationGraphImpl(
227232

228233
// If the complete signature match failed,
229234
// try to find the unique not-the-same neighbour method in the same class:
230-
val neighbors = cls.methods
231-
.asSequence()
232-
.filter { it.name == callee.name }
235+
val neighbors = classMethodsByName[cls.signature].orEmpty()[callee.name].orEmpty()
233236
.filterNot { it.name == node.method.name }
234-
.toList()
235237
if (neighbors.isNotEmpty()) {
236238
val s = neighbors.singleOrNull()
237239
?: error("Multiple methods with the same name: $neighbors")

Diff for: usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/AccessPath.kt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.usvm.dataflow.ts.infer
22

33
import org.jacodb.ets.base.EtsArrayAccess
4+
import org.jacodb.ets.base.EtsAwaitExpr
45
import org.jacodb.ets.base.EtsCastExpr
56
import org.jacodb.ets.base.EtsConstant
67
import org.jacodb.ets.base.EtsEntity
@@ -129,6 +130,8 @@ fun EtsEntity.toPathOrNull(): AccessPath? = when (this) {
129130

130131
is EtsCastExpr -> arg.toPathOrNull()
131132

133+
is EtsAwaitExpr -> arg.toPathOrNull()
134+
132135
else -> null
133136
}
134137

0 commit comments

Comments
 (0)