Use bipush, sipush for byte and short constants

This commit is contained in:
Michael Bogdanov
2016-02-12 10:39:31 +03:00
parent 0073257841
commit 384d2ea0d1
6 changed files with 13 additions and 13 deletions
@@ -720,8 +720,8 @@ public abstract class StackValue {
@Override
public void putSelector(@NotNull Type type, @NotNull InstructionAdapter v) {
if (value instanceof Integer) {
v.iconst((Integer) value);
if (value instanceof Integer || value instanceof Byte || value instanceof Short) {
v.iconst(((Number) value).intValue());
}
else if (value instanceof Long) {
v.lconst((Long) value);
+2 -2
View File
@@ -1,3 +1,3 @@
val a: Byte = 1 + 1
val a: Byte = 1 + 10
// 1 I2B
// 1 BIPUSH 11
@@ -1,5 +1,5 @@
val a: Byte? = -1
val b: Short? = -1
val a: Byte? = -10
val b: Short? = -300
// 1 I2B
// 1 I2S
// 1 BIPUSH -10
// 1 SIPUSH -300
+2 -2
View File
@@ -1,3 +1,3 @@
val a: Short = 1 + 1
val a: Short = 1 + 255
// 1 I2S
// 1 SIPUSH 256
@@ -4,7 +4,7 @@ public class JClass {
public final static int PrimitiveInt = 9000;
public final static int BigPrimitiveInt = 59000;
public final static long PrimitiveLong = 100000;
public final static short PrimitiveShort = 900;
public final static short PrimitiveShort = 901;
public final static boolean PrimitiveBool = false;
public final static float PrimitiveFloat = 36.6;
public final static double PrimitiveDouble = 42.4242;
@@ -31,10 +31,10 @@ fun test() {
// 1 LDC 9223372036854775807
// 1 SIPUSH 9000
// 1 LDC 59000
// 1 LDC -8
// 1 BIPUSH -8
// 1 LDC K
// 1 LDC 100000
// 1 LDC 900
// 1 SIPUSH 901
// 1 LDC false
// 1 LDC 36.6
// 1 LDC 42.4242