JVM_IR: add test for calling monitorEnter/Exit from serialized code.

This commit is contained in:
Georgy Bronnikov
2021-06-25 17:25:59 +03:00
committed by TeamCityServer
parent dffb22de9d
commit 28bff2ba4f
6 changed files with 50 additions and 0 deletions
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FILE: mySynchronized.kt
import kotlin.jvm.internal.unsafe.*
public inline fun <R> mySynchronized(lock: Any, block: () -> R): R {
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "INVISIBLE_MEMBER")
monitorEnter(lock)
try {
return block()
}
finally {
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "INVISIBLE_MEMBER")
monitorExit(lock)
}
}
// FILE: box.kt
fun box() = mySynchronized(Any()) { "OK" }