Skip to content

Commit 1b8136a

Browse files
committed
USVM Type Inference as a Service
1 parent c9d843a commit 1b8136a

File tree

38 files changed

+1298
-822
lines changed

38 files changed

+1298
-822
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

21+
- name: Checkout local jacodb
22+
uses: actions/checkout@v4
23+
with:
24+
repository: UnitTestBot/jacodb
25+
ref: lipen/grpc
26+
path: jacodb
27+
2128
- name: Setup Java JDK
2229
uses: actions/setup-java@v4
2330
with:
@@ -45,6 +52,13 @@ jobs:
4552
- name: Checkout repository
4653
uses: actions/checkout@v4
4754

55+
- name: Checkout local jacodb
56+
uses: actions/checkout@v4
57+
with:
58+
repository: UnitTestBot/jacodb
59+
ref: lipen/grpc
60+
path: jacodb
61+
4862
- name: Setup Java JDK
4963
uses: actions/setup-java@v4
5064
with:
@@ -74,6 +88,13 @@ jobs:
7488
# 'usvm-python/cpythonadapter/cpython' is a submodule
7589
submodules: true
7690

91+
- name: Checkout local jacodb
92+
uses: actions/checkout@v4
93+
with:
94+
repository: UnitTestBot/jacodb
95+
ref: lipen/grpc
96+
path: jacodb
97+
7798
- name: Setup Java JDK
7899
uses: actions/setup-java@v4
79100
with:
@@ -107,6 +128,16 @@ jobs:
107128
- name: Checkout repository
108129
uses: actions/checkout@v4
109130

131+
- name: Checkout local jacodb
132+
uses: actions/checkout@v4
133+
with:
134+
repository: UnitTestBot/jacodb
135+
ref: lipen/grpc
136+
path: jacodb
137+
138+
- name: Enable ETS modules in jacodb
139+
run: echo "enableEts=true" >> jacodb/local.properties
140+
110141
- name: Setup Java JDK
111142
uses: actions/setup-java@v4
112143
with:
@@ -127,7 +158,7 @@ jobs:
127158
DEST_DIR="arkanalyzer"
128159
MAX_RETRIES=10
129160
RETRY_DELAY=3 # Delay between retries in seconds
130-
BRANCH="neo/2025-06-16"
161+
BRANCH="neo/2025-06-20"
131162
132163
for ((i=1; i<=MAX_RETRIES; i++)); do
133164
git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break
@@ -149,7 +180,7 @@ jobs:
149180
npm run build
150181
151182
- name: Run TS tests
152-
run: ./gradlew :usvm-ts:check :usvm-ts-dataflow:check
183+
run: ./gradlew :usvm-ts:check :usvm-ts-dataflow:check :usvm-ts-service:check
153184

154185
- name: Upload Gradle reports
155186
if: (!cancelled())
@@ -165,6 +196,16 @@ jobs:
165196
- name: Checkout repository
166197
uses: actions/checkout@v4
167198

199+
- name: Checkout local jacodb
200+
uses: actions/checkout@v4
201+
with:
202+
repository: UnitTestBot/jacodb
203+
ref: lipen/grpc
204+
path: jacodb
205+
206+
- name: Enable ETS modules in jacodb
207+
run: echo "enableEts=true" >> jacodb/local.properties
208+
168209
- name: Setup Java JDK
169210
uses: actions/setup-java@v4
170211
with:
@@ -174,6 +215,9 @@ jobs:
174215
- name: Setup Gradle
175216
uses: gradle/actions/setup-gradle@v4
176217

218+
- name: Show project list
219+
run: ./gradlew projects
220+
177221
- name: Validate Project List
178222
run: ./gradlew validateProjectList
179223

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ tasks.register("validateProjectList") {
1919
project(":usvm-python"),
2020
project(":usvm-ts"),
2121
project(":usvm-ts-dataflow"),
22+
project(":usvm-ts-service"),
2223
)
2324

2425
// Gather the actual subprojects from the current root project.

buildSrc/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
}
44

55
val kotlinVersion = "2.1.0"
6+
val coroutinesVersion = "1.10.2"
67
val detektVersion = "1.23.5"
78
val gjavahVersion = "0.3.1"
89

@@ -14,6 +15,7 @@ repositories {
1415

1516
dependencies {
1617
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
18+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
1719
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion")
1820
implementation("org.glavo:gjavah:$gjavahVersion")
1921
}

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import org.gradle.plugin.use.PluginDependenciesSpec
55
object Versions {
66
const val clikt = "5.0.0"
77
const val detekt = "1.23.7"
8+
const val gradle_protobuf = "0.9.5"
9+
const val grpc = "1.72.0"
10+
const val grpc_kotlin = "1.4.3"
811
const val ini4j = "0.5.4"
912
const val jacodb = "4ff7243d3a"
1013
const val juliet = "1.3.2"
@@ -15,12 +18,16 @@ object Versions {
1518
const val kotlinx_coroutines = "1.10.0"
1619
const val kotlinx_serialization = "1.7.3"
1720
const val ksmt = "0.5.26"
21+
const val ktor = "3.1.3"
1822
const val logback = "1.4.8"
1923
const val mockk = "1.13.4"
24+
const val protobuf = "4.30.2"
2025
const val rd = "2023.2.0"
2126
const val sarif4k = "0.5.0"
2227
const val shadow = "8.3.3"
2328
const val slf4j = "1.6.1"
29+
const val wire = "5.3.1"
30+
const val wire_grpc_server = "1.0.0-alpha04"
2431

2532
// versions for jvm samples
2633
object Samples {
@@ -116,7 +123,8 @@ object Libs {
116123
)
117124

118125
// https://github.com/UnitTestBot/jacodb
119-
private const val jacodbPackage = "com.github.UnitTestBot.jacodb" // use "org.jacodb" with includeBuild
126+
// private const val jacodbPackage = "com.github.UnitTestBot.jacodb" // use "org.jacodb" with includeBuild
127+
private const val jacodbPackage = "org.jacodb"
120128
val jacodb_core = dep(
121129
group = jacodbPackage,
122130
name = "jacodb-core",
@@ -173,14 +181,14 @@ object Libs {
173181
)
174182

175183
// https://github.com/Kotlin/kotlinx.serialization
176-
val kotlinx_serialization_core = dep(
184+
val kotlinx_serialization_json = dep(
177185
group = "org.jetbrains.kotlinx",
178-
name = "kotlinx-serialization-core",
186+
name = "kotlinx-serialization-json",
179187
version = Versions.kotlinx_serialization
180188
)
181-
val kotlinx_serialization_json = dep(
189+
val kotlinx_serialization_protobuf = dep(
182190
group = "org.jetbrains.kotlinx",
183-
name = "kotlinx-serialization-json",
191+
name = "kotlinx-serialization-protobuf",
184192
version = Versions.kotlinx_serialization
185193
)
186194

@@ -248,6 +256,52 @@ object Libs {
248256
name = "clikt",
249257
version = Versions.clikt
250258
)
259+
260+
// https://github.com/grpc/grpc-java
261+
val grpc_api = dep(
262+
group = "io.grpc",
263+
name = "grpc-api",
264+
version = Versions.grpc
265+
)
266+
val grpc_protobuf = dep(
267+
group = "io.grpc",
268+
name = "grpc-protobuf",
269+
version = Versions.grpc
270+
)
271+
val grpc_stub = dep(
272+
group = "io.grpc",
273+
name = "grpc-stub",
274+
version = Versions.grpc
275+
)
276+
val grpc_netty_shaded = dep(
277+
group = "io.grpc",
278+
name = "grpc-netty-shaded",
279+
version = Versions.grpc
280+
)
281+
282+
// https://github.com/square/wire
283+
val wire_runtime = dep(
284+
group = "com.squareup.wire",
285+
name = "wire-runtime",
286+
version = Versions.wire
287+
)
288+
val wire_grpc_client = dep(
289+
group = "com.squareup.wire",
290+
name = "wire-grpc-client",
291+
version = Versions.wire
292+
)
293+
294+
// https://github.com/square/wire-grpc-server
295+
val wire_grpc_server = dep(
296+
group = "com.squareup.wiregrpcserver",
297+
name = "server",
298+
version = Versions.wire_grpc_server
299+
)
300+
val wire_grpc_server_generator = dep(
301+
group = "com.squareup.wiregrpcserver",
302+
name = "server-generator",
303+
version = Versions.wire_grpc_server
304+
)
251305
}
252306

253307
object Plugins {
@@ -271,6 +325,18 @@ object Plugins {
271325
id = "com.gradleup.shadow",
272326
version = Versions.shadow
273327
)
328+
329+
// https://github.com/google/protobuf-gradle-plugin
330+
object GradleProtobuf : ProjectPlugin(
331+
id = "com.google.protobuf",
332+
version = Versions.gradle_protobuf
333+
)
334+
335+
// https://github.com/square/wire
336+
object Wire : ProjectPlugin(
337+
version = Versions.wire,
338+
id = "com.squareup.wire"
339+
)
274340
}
275341

276342
fun PluginDependenciesSpec.id(plugin: Plugins.ProjectPlugin) {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import kotlinx.coroutines.CoroutineScope
2+
import kotlinx.coroutines.Dispatchers
3+
import kotlinx.coroutines.joinAll
4+
import kotlinx.coroutines.launch
5+
import kotlinx.coroutines.runBlocking
6+
import java.io.Reader
7+
import kotlin.time.Duration
8+
import java.util.concurrent.TimeUnit
9+
10+
object ProcessUtil {
11+
data class Result(
12+
val exitCode: Int,
13+
val stdout: String,
14+
val stderr: String,
15+
val isTimeout: Boolean, // true if the process was terminated due to timeout
16+
)
17+
18+
fun run(
19+
command: List<String>,
20+
input: Reader = "".reader(),
21+
timeout: Duration? = null,
22+
builder: ProcessBuilder.() -> Unit = {},
23+
): Result {
24+
val process = ProcessBuilder(command).apply(builder).start()
25+
return communicate(process, input, timeout)
26+
}
27+
28+
private fun communicate(
29+
process: Process,
30+
input: Reader,
31+
timeout: Duration? = null,
32+
): Result {
33+
val stdout = StringBuilder()
34+
val stderr = StringBuilder()
35+
36+
val scope = CoroutineScope(Dispatchers.IO)
37+
38+
// Handle process input
39+
val stdinJob = scope.launch {
40+
process.outputStream.bufferedWriter().use { writer ->
41+
input.copyTo(writer)
42+
}
43+
}
44+
45+
// Launch output capture coroutines
46+
val stdoutJob = scope.launch {
47+
process.inputStream.bufferedReader().useLines { lines ->
48+
lines.forEach { stdout.appendLine(it) }
49+
}
50+
}
51+
val stderrJob = scope.launch {
52+
process.errorStream.bufferedReader().useLines { lines ->
53+
lines.forEach { stderr.appendLine(it) }
54+
}
55+
}
56+
57+
// Wait for completion
58+
val isTimeout = if (timeout != null) {
59+
!process.waitFor(timeout.inWholeNanoseconds, TimeUnit.NANOSECONDS)
60+
} else {
61+
process.waitFor()
62+
false
63+
}
64+
65+
// Wait for all coroutines to finish
66+
runBlocking {
67+
joinAll(stdinJob, stdoutJob, stderrJob)
68+
}
69+
70+
return Result(
71+
exitCode = process.exitValue(),
72+
stdout = stdout.toString(),
73+
stderr = stderr.toString(),
74+
isTimeout = isTimeout,
75+
)
76+
}
77+
}

0 commit comments

Comments
 (0)