[JS IR BE] Replace 32bit default String.hashcode with 64bit cityhash for UniqID
Split uniqID space into two part 63 bit each.
This commit is contained in:
+2
-4
@@ -11,11 +11,9 @@ import org.jetbrains.kotlin.backend.common.serialization.DescriptorTable
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
|
||||
class JsDeclarationTable(builtIns: IrBuiltIns, descriptorTable: DescriptorTable)
|
||||
: DeclarationTable(builtIns, descriptorTable, JsMangler) {
|
||||
|
||||
override var currentIndex = 0x1_0000_0000L
|
||||
class JsDeclarationTable(builtIns: IrBuiltIns, descriptorTable: DescriptorTable) : DeclarationTable(builtIns, descriptorTable, JsMangler) {
|
||||
|
||||
override var currentIndex = PUBLIC_LOCAL_UNIQ_ID_EDGE
|
||||
private val FUNCTION_INDEX_START: Long = loadKnownBuiltins()
|
||||
|
||||
init {
|
||||
|
||||
+5
-4
@@ -27,10 +27,11 @@ private val kotlinFqn = FqName("kotlin")
|
||||
private val functionalPackages =
|
||||
listOf(kotlinFqn, kotlinFqn.child(Name.identifier("coroutines")), kotlinFqn.child(Name.identifier("reflect")))
|
||||
|
||||
internal val BUILT_IN_FUNCTION_CLASS_COUNT = 4
|
||||
internal val BUILT_IN_FUNCTION_ARITY_COUNT = 256
|
||||
internal val BUILT_IN_UNIQ_ID_GAP = 2 * BUILT_IN_FUNCTION_ARITY_COUNT * BUILT_IN_FUNCTION_CLASS_COUNT
|
||||
internal val BUILT_IN_UNIQ_ID_CLASS_OFFSET = BUILT_IN_FUNCTION_CLASS_COUNT * BUILT_IN_FUNCTION_ARITY_COUNT
|
||||
internal const val PUBLIC_LOCAL_UNIQ_ID_EDGE = 0x7FFF_FFFF_FFFF_FFFFL + 1L
|
||||
internal const val BUILT_IN_FUNCTION_CLASS_COUNT = 4
|
||||
internal const val BUILT_IN_FUNCTION_ARITY_COUNT = 256
|
||||
internal const val BUILT_IN_UNIQ_ID_GAP = 2 * BUILT_IN_FUNCTION_ARITY_COUNT * BUILT_IN_FUNCTION_CLASS_COUNT
|
||||
internal const val BUILT_IN_UNIQ_ID_CLASS_OFFSET = BUILT_IN_FUNCTION_CLASS_COUNT * BUILT_IN_FUNCTION_ARITY_COUNT
|
||||
|
||||
internal fun isBuiltInFunction(value: IrDeclaration): Boolean = when (value) {
|
||||
is IrSimpleFunction ->
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ class JsIrLinker(
|
||||
logger: LoggingContext,
|
||||
builtIns: IrBuiltIns,
|
||||
symbolTable: SymbolTable
|
||||
) : KotlinIrLinker(logger, builtIns, symbolTable, emptyList(), null, 0x1_0000_0000L),
|
||||
) : KotlinIrLinker(logger, builtIns, symbolTable, emptyList(), null, PUBLIC_LOCAL_UNIQ_ID_EDGE),
|
||||
DescriptorUniqIdAware by JsDescriptorUniqIdAware {
|
||||
|
||||
private val FUNCTION_INDEX_START: Long = indexAfterKnownBuiltins
|
||||
|
||||
+5
-3
@@ -6,12 +6,14 @@
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinManglerImpl
|
||||
import org.jetbrains.kotlin.backend.common.serialization.cityHash64
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.isInlined
|
||||
|
||||
object JsMangler: KotlinManglerImpl() {
|
||||
// TODO: think about this
|
||||
override val String.hashMangle: Long get() = this.hashCode().toLong()
|
||||
object JsMangler : KotlinManglerImpl() {
|
||||
private const val MOD_VALUE = PUBLIC_LOCAL_UNIQ_ID_EDGE
|
||||
|
||||
override val String.hashMangle: Long get() = cityHash64() % MOD_VALUE
|
||||
|
||||
override val IrType.isInlined: Boolean
|
||||
get() = this.isInlined()
|
||||
|
||||
Reference in New Issue
Block a user