You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Native IR transformations are now available: compiler plugin implements atomic operations via K/N stdlib atomic intrinsics. Atomic arrays, delegated properties and traces are supported by the compiler plugin as well.
To enable Native IR transformations, set the flag `kotlinx.atomicfu.enableNativeIrTransformations=true` in the `gradle.properties` file.
Copy file name to clipboardExpand all lines: README.md
+10-12
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
>We do provide a compatibility of atomicfu-transformed artifacts between releases, but we do not provide
10
10
>strict compatibility guarantees on plugin API and its general stability between Kotlin versions.
11
11
12
-
**Atomicfu** is a multiplatform library that provides the idiomatic and effective way of using atomic operations in Kotlin.
12
+
**Atomicfu** is a multiplatform library that provides the idiomatic and efficient way of using atomic operations in Kotlin.
13
13
14
14
## Table of contents
15
15
-[Requirements](#requirements)
@@ -46,7 +46,8 @@ Starting from version `0.22.0` of the library your project is required to use:
46
46
* Code it like a boxed value `atomic(0)`, but run it in production efficiently:
47
47
* For **JVM**: an atomic value is represented as a plain value atomically updated with `java.util.concurrent.atomic.AtomicXxxFieldUpdater` from the Java standard library.
48
48
* For **JS**: an atomic value is represented as a plain value.
49
-
* For **Native** and **Wasm**: an atomic value is not transformed, it remains boxed, and `kotlinx-atomicfu` library is used as a runtime dependency.
49
+
* For **Native**: atomic operations are delegated to Kotlin/Native atomic intrinsics.
50
+
* For **Wasm**: an atomic value is not transformed, it remains boxed, and `kotlinx-atomicfu` library is used as a runtime dependency.
50
51
* Use Kotlin-specific extensions (e.g. inline `loop`, `update`, `updateAndGet` functions).
51
52
* Use atomic arrays, user-defined extensions on atomics and locks (see [more features](#more-features)).
52
53
*[Tracing operations](#tracing-operations) for debugging.
@@ -247,17 +248,13 @@ public var foo: T by _foo // public delegated property (val/var)
247
248
(more specifically, `complex_expression` should not have branches in its compiled representation).
248
249
Extract `complex_expression` into a variable when needed.
249
250
250
-
## Transformation modes
251
+
## Atomicfu compiler plugin
251
252
252
-
Basically, Atomicfu library provides an effective usage of atomic values by performing the transformations of the compiled code.
253
-
For JVM and JS there 2 transformation modes available:
254
-
***Post-compilation transformation** that modifies the compiled bytecode or `*.js` files.
255
-
***IR transformation** that is performed by the atomicfu compiler plugin.
256
-
257
-
### Atomicfu compiler plugin
258
-
259
-
Compiler plugin transformation is less fragile than transformation of the compiled sources
260
-
as it depends on the compiler IR tree.
253
+
To provide a user-friendly atomic API on the frontend and efficient usage of atomic values on the backend kotlinx-atomicfu library uses the compiler plugin to transform
254
+
IR for all the target backends:
255
+
***JVM**: atomics are replaced with `java.util.concurrent.atomic.AtomicXxxFieldUpdater`.
256
+
***Native**: atomics are implemented via atomic intrinsics on Kotlin/Native.
257
+
***JS**: atomics are unboxed and represented as plain values.
261
258
262
259
To turn on IR transformation set these properties in your `gradle.properties` file:
263
260
@@ -266,6 +263,7 @@ To turn on IR transformation set these properties in your `gradle.properties` fi
266
263
267
264
```groovy
268
265
kotlinx.atomicfu.enableJvmIrTransformation=true // for JVM IR transformation
266
+
kotlinx.atomicfu.enableNativeIrTransformation=true // for Native IR transformation
269
267
kotlinx.atomicfu.enableJsIrTransformation=true // for JS IR transformation
Copy file name to clipboardExpand all lines: integration-testing/src/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/checker/ArtifactChecker.kt
Copy file name to clipboardExpand all lines: integration-testing/src/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/checker/DependenciesChecker.kt
+13
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,19 @@ internal fun GradleBuild.checkMppWasmWasiImplementationDependencies() {
0 commit comments