Skip to content

Commit a04e483

Browse files
committed
cleanup
1 parent 2e348fd commit a04e483

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/ForwardAnalyzer.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,26 @@ class ForwardAnalyzer(
3535
}
3636

3737
private val liveVariablesCache = hashMapOf<EtsMethod, LiveVariables>()
38-
private fun liveVariables(method: EtsMethod) =
38+
private fun liveVariables(method: EtsMethod): LiveVariables =
3939
liveVariablesCache.computeIfAbsent(method) {
4040
if (doLiveVariablesAnalysis) LiveVariables.from(method) else AlwaysAlive
4141
}
4242

43+
private fun variableIsDying(fact: ForwardTypeDomainFact, stmt: EtsStmt): Boolean {
44+
if (fact !is ForwardTypeDomainFact.TypedVariable) return false
45+
val base = fact.variable.base
46+
if (base !is AccessPathBase.Local) return false
47+
return !liveVariables(stmt.method).isAliveAt(base.name, stmt)
48+
}
49+
4350
override fun handleNewEdge(edge: Edge<ForwardTypeDomainFact, EtsStmt>): List<AnalyzerEvent> {
4451
val (startVertex, currentVertex) = edge
4552
val (current, currentFact) = currentVertex
4653
val method = graph.methodOf(current)
4754
val currentIsExit = current in graph.exitPoints(method) ||
4855
(current is EtsNopStmt && graph.successors(current).none())
4956

50-
val variableIsDying = (currentFact as? ForwardTypeDomainFact.TypedVariable)?.let {
51-
val base = it.variable.base
52-
base is AccessPathBase.Local && (!liveVariables(method).isAliveAt(base.name, current))
53-
} ?: false
54-
55-
if (currentIsExit || variableIsDying) {
57+
if (currentIsExit || variableIsDying(currentFact, current)) {
5658
return listOf(
5759
ForwardSummaryAnalyzerEvent(
5860
method = method,

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/TypeInferenceManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ class TypeInferenceManager(
344344
.entries.groupByTo(hashMapOf()) { (method, _) -> method.enclosingClass }
345345

346346
return graph.cp.projectClasses.mapNotNull { cls ->
347-
val clsMethods = (cls.methods + cls.ctor).toHashSet()
348-
val combinedBackwardType = clsMethods
347+
val combinedBackwardType = (cls.methods + cls.ctor)
349348
.mapNotNull { methodTypeScheme[it] }
350349
.mapNotNull { facts -> facts[AccessPathBase.This] }.reduceOrNull { acc, type ->
351350
typeProcessor.intersect(acc, type) ?: run {

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/util/EtsTraits.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.jacodb.ets.base.EtsAssignStmt
2727
import org.jacodb.ets.base.EtsBinaryExpr
2828
import org.jacodb.ets.base.EtsBooleanConstant
2929
import org.jacodb.ets.base.EtsCallExpr
30-
import org.jacodb.ets.base.EtsCallStmt
3130
import org.jacodb.ets.base.EtsCastExpr
3231
import org.jacodb.ets.base.EtsClassType
3332
import org.jacodb.ets.base.EtsConstant
@@ -99,11 +98,7 @@ class EtsTraits : Traits<EtsMethod, EtsStmt> {
9998
}
10099

101100
override fun getCallExpr(statement: EtsStmt): EtsCallExpr? {
102-
return when (statement) {
103-
is EtsAssignStmt -> statement.rhv as? EtsCallExpr
104-
is EtsCallStmt -> statement.expr
105-
else -> null
106-
}
101+
return statement.callExpr
107102
}
108103

109104
override fun getValues(expr: CommonExpr): Set<CommonValue> {

usvm-ts-dataflow/src/test/kotlin/org/usvm/dataflow/ts/test/EtsTypeResolverPerformanceTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import java.io.File
2828
@Disabled
2929
class EtsTypeResolverPerformanceTest {
3030
companion object {
31-
const val WARMUP_ITERATIONS = 0
32-
const val TEST_ITERATIONS = 10
31+
const val WARMUP_ITERATIONS = 5
32+
const val TEST_ITERATIONS = 5
3333
const val OUTPUT_FILE = "performance_report.md"
3434

3535
@JvmStatic

0 commit comments

Comments
 (0)