IrBuiltins: refactoring for equality checks
Previously, * Equals performs IEEE 754 equality check for floating points and byte-to-byte checks for other types, including references. * Ieee754Equals performs IEEE 754 for primitive types * TotalOrderEquals performs total order equals to all types, including floating points. Now it is simplified, * Equals performs total order checks for all types. * Ieee754Equals performs IEEE 754 for primitive types. * (TotalOrderEquals is removed.)
This commit is contained in:
committed by
max-kammerer
parent
9ddb64288c
commit
9fc869397d
@@ -848,19 +848,30 @@ public class AsmUtil {
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, v -> {
|
||||
left.put(AsmTypes.OBJECT_TYPE, left.kotlinType, v);
|
||||
right.put(AsmTypes.OBJECT_TYPE, right.kotlinType, v);
|
||||
genAreEqualCall(v);
|
||||
|
||||
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
return genAreEqualCall(v, opToken);
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue genEqualsBoxedOnStack(@NotNull IElementType opToken) {
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, v -> genAreEqualCall(v, opToken));
|
||||
}
|
||||
|
||||
public static void genAreEqualCall(InstructionAdapter v) {
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Unit genAreEqualCall(InstructionAdapter v, @NotNull IElementType opToken) {
|
||||
genAreEqualCall(v);
|
||||
|
||||
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
|
||||
public static void genIEEE754EqualForNullableTypesCall(InstructionAdapter v, Type left, Type right) {
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "areEqual", "(" + left.getDescriptor() + right.getDescriptor() + ")Z", false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user