kotlinx.atomicfu compiler plugin for JS_IR backend (#4581)

* kotlinx.atomicfu compiler plugin for JS_IR

Support transformations of atomic operations introduced by the kotlinx.atomicfu library for the JS_IR backend. Compiler plugin is applied externally by the kotlinx.atomicfu gradle plugin.

* Apply compiler plugin for JS platform only

* New plugin test structure

* testGroupOutputDirPrefix changed
This commit is contained in:
mvicsokolova
2021-12-01 22:33:13 +03:00
committed by GitHub
parent 05695761ec
commit 93561a1a55
45 changed files with 2655 additions and 4 deletions
@@ -0,0 +1,32 @@
import kotlinx.atomicfu.*
import kotlin.test.*
class IndexArrayElementGetterTest {
private val clazz = AtomicArrayClass()
fun fib(a: Int): Int = if (a == 0 || a == 1) a else fib(a - 1) + fib(a - 2)
fun testIndexArrayElementGetting() {
clazz.intArr[8].value = 3
val i = fib(4)
val j = fib(5)
assertEquals(clazz.intArr[i + j].value, 3)
assertEquals(clazz.intArr[fib(4) + fib(5)].value, 3)
clazz.longArr[3].value = 100
assertEquals(clazz.longArr[fib(6) - fib(5)].value, 100)
assertEquals(clazz.longArr[(fib(6) + fib(4)) % 8].value, 100)
assertEquals(clazz.longArr[(fib(6) + fib(4)) % 8].value, 100)
assertEquals(clazz.longArr[(fib(4) + fib(5)) % fib(5)].value, 100)
}
class AtomicArrayClass {
val intArr = AtomicIntArray(10)
val longArr = AtomicLongArray(10)
}
}
fun box(): String {
val testClass = IndexArrayElementGetterTest()
testClass.testIndexArrayElementGetting()
return "OK"
}