[JS BE] Fix DCE to let it remove constant properties
This commit is contained in:
@@ -35,6 +35,10 @@ fun eliminateDeadDeclarations(
|
||||
removeUselessDeclarations(module, usefulDeclarations)
|
||||
}
|
||||
|
||||
private fun IrField.isConstant(): Boolean {
|
||||
return correspondingPropertySymbol?.owner?.isConst ?: false
|
||||
}
|
||||
|
||||
private fun buildRoots(module: IrModuleFragment, context: JsIrBackendContext, mainFunction: IrSimpleFunction?): Iterable<IrDeclaration> {
|
||||
val rootDeclarations =
|
||||
(module.files + context.packageLevelJsModules + context.externalPackageFragment.values).flatMapTo(mutableListOf()) { file ->
|
||||
@@ -44,7 +48,7 @@ private fun buildRoots(module: IrModuleFragment, context: JsIrBackendContext, ma
|
||||
|| it.isEffectivelyExternal()
|
||||
|| it is IrField && it.correspondingPropertySymbol?.owner?.isExported(context) == true
|
||||
|| it is IrSimpleFunction && it.correspondingPropertySymbol?.owner?.isExported(context) == true
|
||||
}
|
||||
}.filter { !(it is IrField && it.isConstant() && !it.isExported(context)) }
|
||||
}
|
||||
|
||||
if (context.hasTests) rootDeclarations += context.testContainer
|
||||
|
||||
@@ -55,8 +55,8 @@ fun hashCode(obj: dynamic): Int {
|
||||
}
|
||||
}
|
||||
|
||||
private var POW_2_32 = 4294967296.0
|
||||
private var OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$"
|
||||
private const val POW_2_32 = 4294967296.0
|
||||
private const val OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$"
|
||||
|
||||
fun getObjectHashCode(obj: dynamic): Int {
|
||||
if (!jsIn(OBJECT_HASH_CODE_PROPERTY_NAME, obj)) {
|
||||
|
||||
@@ -358,18 +358,18 @@ internal fun fromNumber(value: Double): Long {
|
||||
}
|
||||
}
|
||||
|
||||
private val TWO_PWR_16_DBL_ = (1 shl 16).toDouble()
|
||||
private const val TWO_PWR_16_DBL_ = (1 shl 16).toDouble()
|
||||
|
||||
private val TWO_PWR_24_DBL_ = (1 shl 24).toDouble()
|
||||
private const val TWO_PWR_24_DBL_ = (1 shl 24).toDouble()
|
||||
|
||||
//private val TWO_PWR_32_DBL_ = TWO_PWR_16_DBL_ * TWO_PWR_16_DBL_
|
||||
private val TWO_PWR_32_DBL_ = (1 shl 16).toDouble() * (1 shl 16).toDouble()
|
||||
private const val TWO_PWR_32_DBL_ = (1 shl 16).toDouble() * (1 shl 16).toDouble()
|
||||
|
||||
//private val TWO_PWR_64_DBL_ = TWO_PWR_32_DBL_ * TWO_PWR_32_DBL_
|
||||
private val TWO_PWR_64_DBL_ = ((1 shl 16).toDouble() * (1 shl 16).toDouble()) * ((1 shl 16).toDouble() * (1 shl 16).toDouble())
|
||||
private const val TWO_PWR_64_DBL_ = ((1 shl 16).toDouble() * (1 shl 16).toDouble()) * ((1 shl 16).toDouble() * (1 shl 16).toDouble())
|
||||
|
||||
//private val TWO_PWR_63_DBL_ = TWO_PWR_64_DBL_ / 2
|
||||
private val TWO_PWR_63_DBL_ = (((1 shl 16).toDouble() * (1 shl 16).toDouble()) * ((1 shl 16).toDouble() * (1 shl 16).toDouble())) / 2
|
||||
private const val TWO_PWR_63_DBL_ = (((1 shl 16).toDouble() * (1 shl 16).toDouble()) * ((1 shl 16).toDouble() * (1 shl 16).toDouble())) / 2
|
||||
|
||||
private val ZERO = fromInt(0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user