[K/Wasm] Remove custom equals because this kind of equality is lowered in duration of the compilation ^KT-58126 Fixed
This commit is contained in:
@@ -237,8 +237,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri
|
|||||||
override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) {
|
override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) {
|
||||||
val additionalCheck = when (thisKind) {
|
val additionalCheck = when (thisKind) {
|
||||||
PrimitiveType.LONG -> "wasm_i64_eq(this, $parameterName)"
|
PrimitiveType.LONG -> "wasm_i64_eq(this, $parameterName)"
|
||||||
PrimitiveType.FLOAT -> "this.equals(other)"
|
PrimitiveType.FLOAT, PrimitiveType.DOUBLE -> "this.toBits() == other.toBits()"
|
||||||
PrimitiveType.DOUBLE -> "this.toBits() == other.toBits()"
|
|
||||||
else -> {
|
else -> {
|
||||||
"wasm_i32_eq(this${thisKind.castToIfNecessary(PrimitiveType.INT)}, $parameterName${thisKind.castToIfNecessary(PrimitiveType.INT)})"
|
"wasm_i32_eq(this${thisKind.castToIfNecessary(PrimitiveType.INT)}, $parameterName${thisKind.castToIfNecessary(PrimitiveType.INT)})"
|
||||||
}
|
}
|
||||||
@@ -255,7 +254,6 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) {
|
override fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) {
|
||||||
generateCustomEquals(thisKind)
|
|
||||||
generateHashCode(thisKind)
|
generateHashCode(thisKind)
|
||||||
when {
|
when {
|
||||||
thisKind == PrimitiveType.BYTE || thisKind == PrimitiveType.SHORT -> generateReinterpret(PrimitiveType.INT)
|
thisKind == PrimitiveType.BYTE || thisKind == PrimitiveType.SHORT -> generateReinterpret(PrimitiveType.INT)
|
||||||
@@ -283,25 +281,6 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) {
|
|
||||||
method {
|
|
||||||
annotations += "kotlin.internal.IntrinsicConstEvaluation"
|
|
||||||
signature {
|
|
||||||
isInline = thisKind in PrimitiveType.floatingPoint
|
|
||||||
methodName = "equals"
|
|
||||||
parameter {
|
|
||||||
name = "other"
|
|
||||||
type = thisKind.capitalized
|
|
||||||
}
|
|
||||||
returnType = PrimitiveType.BOOLEAN.capitalized
|
|
||||||
}
|
|
||||||
when (thisKind) {
|
|
||||||
in PrimitiveType.floatingPoint -> "toBits() == other.toBits()".addAsSingleLineBody(bodyOnNewLine = false)
|
|
||||||
else -> implementAsIntrinsic(thisKind, methodName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ClassBuilder.generateReinterpret(otherKind: PrimitiveType) {
|
private fun ClassBuilder.generateReinterpret(otherKind: PrimitiveType) {
|
||||||
method {
|
method {
|
||||||
annotations += "WasmNoOpCast"
|
annotations += "WasmNoOpCast"
|
||||||
|
|||||||
@@ -429,11 +429,6 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Byte && wasm_i32_eq(this.toInt(), other.toInt())
|
other is Byte && wasm_i32_eq(this.toInt(), other.toInt())
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
@WasmOp(WasmOp.I32_EQ)
|
|
||||||
public fun equals(other: Byte): Boolean =
|
|
||||||
implementedAsIntrinsic
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = this.toInt()
|
public override fun hashCode(): Int = this.toInt()
|
||||||
|
|
||||||
@WasmNoOpCast
|
@WasmNoOpCast
|
||||||
@@ -858,11 +853,6 @@ public class Short private constructor(private val value: Short) : Number(), Com
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Short && wasm_i32_eq(this.toInt(), other.toInt())
|
other is Short && wasm_i32_eq(this.toInt(), other.toInt())
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
@WasmOp(WasmOp.I32_EQ)
|
|
||||||
public fun equals(other: Short): Boolean =
|
|
||||||
implementedAsIntrinsic
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = this.toInt()
|
public override fun hashCode(): Int = this.toInt()
|
||||||
|
|
||||||
@WasmNoOpCast
|
@WasmNoOpCast
|
||||||
@@ -1351,11 +1341,6 @@ public class Int private constructor(private val value: Int) : Number(), Compara
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Int && wasm_i32_eq(this, other)
|
other is Int && wasm_i32_eq(this, other)
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
@WasmOp(WasmOp.I32_EQ)
|
|
||||||
public fun equals(other: Int): Boolean =
|
|
||||||
implementedAsIntrinsic
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = this
|
public override fun hashCode(): Int = this
|
||||||
|
|
||||||
@WasmNoOpCast
|
@WasmNoOpCast
|
||||||
@@ -1858,11 +1843,6 @@ public class Long private constructor(private val value: Long) : Number(), Compa
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Long && wasm_i64_eq(this, other)
|
other is Long && wasm_i64_eq(this, other)
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
@WasmOp(WasmOp.I64_EQ)
|
|
||||||
public fun equals(other: Long): Boolean =
|
|
||||||
implementedAsIntrinsic
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = ((this ushr 32) xor this).toInt()
|
public override fun hashCode(): Int = ((this ushr 32) xor this).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2254,10 +2234,7 @@ public class Float private constructor(private val value: Float) : Number(), Com
|
|||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Float && this.equals(other)
|
other is Float && this.toBits() == other.toBits()
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
public inline fun equals(other: Float): Boolean = toBits() == other.toBits()
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = toBits()
|
public override fun hashCode(): Int = toBits()
|
||||||
}
|
}
|
||||||
@@ -2654,8 +2631,5 @@ public class Double private constructor(private val value: Double) : Number(), C
|
|||||||
public override fun equals(other: Any?): Boolean =
|
public override fun equals(other: Any?): Boolean =
|
||||||
other is Double && this.toBits() == other.toBits()
|
other is Double && this.toBits() == other.toBits()
|
||||||
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation
|
|
||||||
public inline fun equals(other: Double): Boolean = toBits() == other.toBits()
|
|
||||||
|
|
||||||
public override fun hashCode(): Int = toBits().hashCode()
|
public override fun hashCode(): Int = toBits().hashCode()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user