GitHib/Kotlin
| Branch: wasm/intro
| wasm_intro.md
2 groups of tasks:
Tips:
wasmJsBrProdRun
instead of wasmJsBrowserProductionRun
Goals:
Fast round-trip.
Debug experience.
No optimizations.
Incremental Compilation:
kotlin.incremental.wasm=true
to local.properties
or gradle.properties
https://kotlinlang.org/docs/whatsnew-eap.html#support-for-incremental-compilationGoing to use custom formatters by default.
Goals:
Runtime performance.
Size.
Small/local optimizations.
Remove Unreachable Declarations (aka DCE in the code)
Run Binaryen
Simplified Diagram:
[Sources] [Dependencies (.klib files)] | | \ / \ v v \ Kompiler \ | \ v | [.klib file] | | / v v Kompiler (to produce executable) + addition lowrings in Prod, including DCE | | | |<Optional> v | [.wasm, .mjs] [.wat] !! Dev build stops here. | v Binaryen // Run by Gradle plugin | v [.wasm optimized] !! In Prod build.
Simplified Diagram:
[Sources] & [klibs] | v Frontend (new frontend aka K2 aka FIR) | v [FIR] | v FIR2IR | v [IR] <aka backend IR> | v Compiler plugins | v [IR] <IR> !! IR could be serialized to .klib here | .............................................. | v Wasm Backend (Lowerings)¹ | v [IR lowered/simplified] | v ir2wasm² | v [Wasm IR]--------+ | | v | WasmIrToBinary³ WasmIrToText⁴ | | v v [~.wasm] [~.wat]
1: WasmLoweringPhases.kt:538 2: ir2wasm 3: WasmIrToBinary.kt 4: WasmIrToText.kt
TODO Operators.kt
Paths:
Test running infrastructure is generated from files (or directories) located in special places.
fun box() = "OK"
If you add a new test-data file you need to regenerate tests with gradle task generateTests
or run configuration in IDE. ./gradlew generateTests
Example: FirWasmJsCodegenBoxTestGenerated.java
./gradlew :wasm:wasm.tests:test
./gradlew :wasm:wasm.tests:testFir
Try to run something. E.g. size tests.
Kotlin Test data Helper https://github.com/demiurg906/test-data-helper-plugin
TODO Tips:
compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/WasmEnvironmentConfigurationDirectives.kt most popular ones?
#kotlin.test.junit5.maxParallelForks=1 gradle.properties:106
TODO ./gradlew install
defaultSnapshotVersion
gradle.properties:27 2.1.255-SNAPSHOT 2..255-SNAPSHOT
Troubleshooting:
./gradlew --stop
-i
or -d
Tips & tricks