diff --git a/compiler/ir/serialization.common/src/KotlinIr.proto b/compiler/ir/serialization.common/src/KotlinIr.proto
index 7fd6182dbb3..3bc94fc6e6e 100644
--- a/compiler/ir/serialization.common/src/KotlinIr.proto
+++ b/compiler/ir/serialization.common/src/KotlinIr.proto
@@ -170,8 +170,8 @@ message IrConst {
int32 short = 5;
int32 int = 6;
int64 long = 7;
- float float = 8;
- double double = 9;
+ fixed32 float_bits = 8; // float/double is stored via fixed 32/64 bit value to avoid raw bit conversion
+ fixed64 double_bits = 9;
int32 string = 10;
}
}
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
index 2a7b82e295a..091cb5844cf 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
@@ -835,10 +835,10 @@ abstract class IrFileDeserializer(val logger: LoggingContext, val builtIns: IrBu
-> IrConstImpl.long(start, end, type, proto.long)
STRING
-> IrConstImpl.string(start, end, type, deserializeString(proto.string))
- FLOAT
- -> IrConstImpl.float(start, end, type, proto.float)
- DOUBLE
- -> IrConstImpl.double(start, end, type, proto.double)
+ FLOAT_BITS
+ -> IrConstImpl.float(start, end, type, Float.fromBits(proto.floatBits))
+ DOUBLE_BITS
+ -> IrConstImpl.double(start, end, type, Double.fromBits(proto.doubleBits))
VALUE_NOT_SET
-> error("Const deserialization error: ${proto.valueCase} ")
}
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
index 70bf003ed13..57e478bb1eb 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
@@ -585,8 +585,8 @@ open class IrFileSerializer(
IrConstKind.Int -> proto.int = value.value as Int
IrConstKind.Long -> proto.long = value.value as Long
IrConstKind.String -> proto.string = serializeString(value.value as String)
- IrConstKind.Float -> proto.float = value.value as Float
- IrConstKind.Double -> proto.double = value.value as Double
+ IrConstKind.Float -> proto.floatBits = (value.value as Float).toBits()
+ IrConstKind.Double -> proto.doubleBits = (value.value as Double).toBits()
}
return proto.build()
}
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConst.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConst.java
index 3524e052b41..31a564bf1b6 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConst.java
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConst.java
@@ -90,12 +90,12 @@ public final class IrConst extends
}
case 69: {
valueCase_ = 8;
- value_ = input.readFloat();
+ value_ = input.readFixed32();
break;
}
case 73: {
valueCase_ = 9;
- value_ = input.readDouble();
+ value_ = input.readFixed64();
break;
}
case 80: {
@@ -148,8 +148,8 @@ public final class IrConst extends
SHORT(5),
INT(6),
LONG(7),
- FLOAT(8),
- DOUBLE(9),
+ FLOAT_BITS(8),
+ DOUBLE_BITS(9),
STRING(10),
VALUE_NOT_SET(0);
private int value = 0;
@@ -165,8 +165,8 @@ public final class IrConst extends
case 5: return SHORT;
case 6: return INT;
case 7: return LONG;
- case 8: return FLOAT;
- case 9: return DOUBLE;
+ case 8: return FLOAT_BITS;
+ case 9: return DOUBLE_BITS;
case 10: return STRING;
case 0: return VALUE_NOT_SET;
default: throw new java.lang.IllegalArgumentException(
@@ -303,38 +303,46 @@ public final class IrConst extends
return 0L;
}
- public static final int FLOAT_FIELD_NUMBER = 8;
+ public static final int FLOAT_BITS_FIELD_NUMBER = 8;
/**
- * optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ *
+ * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public boolean hasFloat() { + public boolean hasFloatBits() { return valueCase_ == 8; } /** - *
optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public float getFloat() { + public int getFloatBits() { if (valueCase_ == 8) { - return (java.lang.Float) value_; + return (java.lang.Integer) value_; } - return 0F; + return 0; } - public static final int DOUBLE_FIELD_NUMBER = 9; + public static final int DOUBLE_BITS_FIELD_NUMBER = 9; /** - *
optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public boolean hasDouble() {
+ public boolean hasDoubleBits() {
return valueCase_ == 9;
}
/**
- * optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public double getDouble() {
+ public long getDoubleBits() {
if (valueCase_ == 9) {
- return (java.lang.Double) value_;
+ return (java.lang.Long) value_;
}
- return 0D;
+ return 0L;
}
public static final int STRING_FIELD_NUMBER = 10;
@@ -398,12 +406,12 @@ public final class IrConst extends
7, (long)((java.lang.Long) value_));
}
if (valueCase_ == 8) {
- output.writeFloat(
- 8, (float)((java.lang.Float) value_));
+ output.writeFixed32(
+ 8, (int)((java.lang.Integer) value_));
}
if (valueCase_ == 9) {
- output.writeDouble(
- 9, (double)((java.lang.Double) value_));
+ output.writeFixed64(
+ 9, (long)((java.lang.Long) value_));
}
if (valueCase_ == 10) {
output.writeInt32(
@@ -455,13 +463,13 @@ public final class IrConst extends
}
if (valueCase_ == 8) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
- .computeFloatSize(
- 8, (float)((java.lang.Float) value_));
+ .computeFixed32Size(
+ 8, (int)((java.lang.Integer) value_));
}
if (valueCase_ == 9) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
- .computeDoubleSize(
- 9, (double)((java.lang.Double) value_));
+ .computeFixed64Size(
+ 9, (long)((java.lang.Long) value_));
}
if (valueCase_ == 10) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
@@ -653,12 +661,12 @@ public final class IrConst extends
setLong(other.getLong());
break;
}
- case FLOAT: {
- setFloat(other.getFloat());
+ case FLOAT_BITS: {
+ setFloatBits(other.getFloatBits());
break;
}
- case DOUBLE: {
- setDouble(other.getDouble());
+ case DOUBLE_BITS: {
+ setDoubleBits(other.getDoubleBits());
break;
}
case STRING: {
@@ -964,33 +972,49 @@ public final class IrConst extends
}
/**
- * optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public boolean hasFloat() { + public boolean hasFloatBits() { return valueCase_ == 8; } /** - *
optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public float getFloat() { + public int getFloatBits() { if (valueCase_ == 8) { - return (java.lang.Float) value_; + return (java.lang.Integer) value_; } - return 0F; + return 0; } /** - *
optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public Builder setFloat(float value) { + public Builder setFloatBits(int value) { valueCase_ = 8; value_ = value; return this; } /** - *
optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - public Builder clearFloat() { + public Builder clearFloatBits() { if (valueCase_ == 8) { valueCase_ = 0; value_ = null; @@ -1000,33 +1024,33 @@ public final class IrConst extends } /** - *
optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public boolean hasDouble() {
+ public boolean hasDoubleBits() {
return valueCase_ == 9;
}
/**
- * optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public double getDouble() {
+ public long getDoubleBits() {
if (valueCase_ == 9) {
- return (java.lang.Double) value_;
+ return (java.lang.Long) value_;
}
- return 0D;
+ return 0L;
}
/**
- * optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public Builder setDouble(double value) {
+ public Builder setDoubleBits(long value) {
valueCase_ = 9;
value_ = value;
return this;
}
/**
- * optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- public Builder clearDouble() {
+ public Builder clearDoubleBits() {
if (valueCase_ == 9) {
valueCase_ = 0;
value_ = null;
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConstOrBuilder.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConstOrBuilder.java
index 56a2bdbcba7..41f11dbee00 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConstOrBuilder.java
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrConstOrBuilder.java
@@ -71,22 +71,30 @@ public interface IrConstOrBuilder extends
long getLong();
/**
- * optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - boolean hasFloat(); + boolean hasFloatBits(); /** - *
optional float float = 8;
+ * optional fixed32 float_bits = 8;
+ *
+ * + * float/double is stored via fixed 32/64 bit value to avoid raw bit conversion + **/ - float getFloat(); + int getFloatBits(); /** - *
optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- boolean hasDouble();
+ boolean hasDoubleBits();
/**
- * optional double double = 9;
+ * optional fixed64 double_bits = 9;
*/
- double getDouble();
+ long getDoubleBits();
/**
* optional int32 string = 10;