diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/Devirtualization.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/Devirtualization.kt index 3f67829cdf2..36f42b5e1eb 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/Devirtualization.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/Devirtualization.kt @@ -820,7 +820,7 @@ internal object Devirtualization { val value = fromId.toLong() or (toId.toLong() shl 32) // This is 64-bit extension of a hashing method from Knuth's "The Art of Computer Programming". // The magic constant is the closest prime to 2^64 * phi, where phi is the golden ratio. - val bucketIdx = ((value.toULong() * 11400714819323198393UL) % bagOfEdges.size.toUInt()).toInt() + val bucketIdx = ((value.toULong() * 11400714819323198393UL) % bagOfEdges.size.toULong()).toInt() val bucket = bagOfEdges[bucketIdx] ?: LongArrayList().also { bagOfEdges[bucketIdx] = it } for (x in bucket) if (x == value) return diff --git a/kotlin-native/build.gradle b/kotlin-native/build.gradle index 281800d9324..8cf97669123 100644 --- a/kotlin-native/build.gradle +++ b/kotlin-native/build.gradle @@ -131,6 +131,15 @@ allprojects { } } + if (findProperty("kotlin.build.useIR") == "true") { + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + useIR = true + freeCompilerArgs += ["-Xir-binary-with-stable-abi"] + } + } + } + setupHostAndTarget() loadCommandLineProperties() loadLocalProperties() diff --git a/kotlin-native/gradle.properties b/kotlin-native/gradle.properties index deb6f429ee0..39e067f0e08 100644 --- a/kotlin-native/gradle.properties +++ b/kotlin-native/gradle.properties @@ -42,5 +42,8 @@ ktorVersion=1.2.1 shadowVersion=5.1.0 metadataVersion=0.0.1-dev-10 +# Uncomment to compile Kotlin/Native backend modules with JVM IR backend. +# kotlin.build.useIR=true + # Uncomment to enable composite build #kotlinProjectPath=