Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 // Note that $opt$ is a marker for the optimizing compiler to test
     18 // it does compile the method.
     19 public class Main {
     20 
     21   public static void assertByteEquals(byte expected, byte result) {
     22     if (expected != result) {
     23       throw new Error("Expected: " + expected + ", found: " + result);
     24     }
     25   }
     26 
     27   public static void assertShortEquals(short expected, short result) {
     28     if (expected != result) {
     29       throw new Error("Expected: " + expected + ", found: " + result);
     30     }
     31   }
     32 
     33   public static void assertIntEquals(int expected, int result) {
     34     if (expected != result) {
     35       throw new Error("Expected: " + expected + ", found: " + result);
     36     }
     37   }
     38 
     39   public static void assertLongEquals(long expected, long result) {
     40     if (expected != result) {
     41       throw new Error("Expected: " + expected + ", found: " + result);
     42     }
     43   }
     44 
     45   public static void assertCharEquals(char expected, char result) {
     46     if (expected != result) {
     47       // Values are cast to int to display numeric values instead of
     48       // (UTF-16 encoded) characters.
     49       throw new Error("Expected: " + (int)expected + ", found: " + (int)result);
     50     }
     51   }
     52 
     53   public static void assertFloatEquals(float expected, float result) {
     54     if (expected != result) {
     55       throw new Error("Expected: " + expected + ", found: " + result);
     56     }
     57   }
     58 
     59   public static void assertDoubleEquals(double expected, double result) {
     60     if (expected != result) {
     61       throw new Error("Expected: " + expected + ", found: " + result);
     62     }
     63   }
     64 
     65   public static void assertFloatIsNaN(float result) {
     66     if (!Float.isNaN(result)) {
     67       throw new Error("Expected: NaN, found: " + result);
     68     }
     69   }
     70 
     71   public static void assertDoubleIsNaN(double result) {
     72     if (!Double.isNaN(result)) {
     73       throw new Error("Expected: NaN, found: " + result);
     74     }
     75   }
     76 
     77 
     78   public static void main(String[] args) {
     79     // Generate, compile and check int-to-long Dex instructions.
     80     byteToLong();
     81     shortToLong();
     82     intToLong();
     83     charToLong();
     84 
     85     // Generate, compile and check int-to-float Dex instructions.
     86     byteToFloat();
     87     shortToFloat();
     88     intToFloat();
     89     charToFloat();
     90 
     91     // Generate, compile and check int-to-double Dex instructions.
     92     byteToDouble();
     93     shortToDouble();
     94     intToDouble();
     95     charToDouble();
     96 
     97     // Generate, compile and check long-to-int Dex instructions.
     98     longToInt();
     99 
    100     // Generate, compile and check long-to-float Dex instructions.
    101     longToFloat();
    102 
    103     // Generate, compile and check long-to-double Dex instructions.
    104     longToDouble();
    105 
    106     // Generate, compile and check float-to-int Dex instructions.
    107     floatToInt();
    108 
    109     // Generate, compile and check float-to-long Dex instructions.
    110     floatToLong();
    111 
    112     // Generate, compile and check float-to-double Dex instructions.
    113     floatToDouble();
    114 
    115     // Generate, compile and check double-to-int Dex instructions.
    116     doubleToInt();
    117 
    118     // Generate, compile and check double-to-long Dex instructions.
    119     doubleToLong();
    120 
    121     // Generate, compile and check double-to-float Dex instructions.
    122     doubleToFloat();
    123 
    124     // Generate, compile and check int-to-byte Dex instructions.
    125     shortToByte();
    126     intToByte();
    127     charToByte();
    128 
    129     // Generate, compile and check int-to-short Dex instructions.
    130     byteToShort();
    131     intToShort();
    132     charToShort();
    133 
    134     // Generate, compile and check int-to-char Dex instructions.
    135     byteToChar();
    136     shortToChar();
    137     intToChar();
    138   }
    139 
    140   private static void byteToLong() {
    141     assertLongEquals(1L, $opt$noinline$ByteToLong((byte)1));
    142     assertLongEquals(0L, $opt$noinline$ByteToLong((byte)0));
    143     assertLongEquals(-1L, $opt$noinline$ByteToLong((byte)-1));
    144     assertLongEquals(51L, $opt$noinline$ByteToLong((byte)51));
    145     assertLongEquals(-51L, $opt$noinline$ByteToLong((byte)-51));
    146     assertLongEquals(127L, $opt$noinline$ByteToLong((byte)127));  // 2^7 - 1
    147     assertLongEquals(-127L, $opt$noinline$ByteToLong((byte)-127));  // -(2^7 - 1)
    148     assertLongEquals(-128L, $opt$noinline$ByteToLong((byte)-128));  // -(2^7)
    149   }
    150 
    151   private static void shortToLong() {
    152     assertLongEquals(1L, $opt$noinline$ShortToLong((short)1));
    153     assertLongEquals(0L, $opt$noinline$ShortToLong((short)0));
    154     assertLongEquals(-1L, $opt$noinline$ShortToLong((short)-1));
    155     assertLongEquals(51L, $opt$noinline$ShortToLong((short)51));
    156     assertLongEquals(-51L, $opt$noinline$ShortToLong((short)-51));
    157     assertLongEquals(32767L, $opt$noinline$ShortToLong((short)32767));  // 2^15 - 1
    158     assertLongEquals(-32767L, $opt$noinline$ShortToLong((short)-32767));  // -(2^15 - 1)
    159     assertLongEquals(-32768L, $opt$noinline$ShortToLong((short)-32768));  // -(2^15)
    160   }
    161 
    162   private static void intToLong() {
    163     assertLongEquals(1L, $opt$noinline$IntToLong(1));
    164     assertLongEquals(0L, $opt$noinline$IntToLong(0));
    165     assertLongEquals(-1L, $opt$noinline$IntToLong(-1));
    166     assertLongEquals(51L, $opt$noinline$IntToLong(51));
    167     assertLongEquals(-51L, $opt$noinline$IntToLong(-51));
    168     assertLongEquals(2147483647L, $opt$noinline$IntToLong(2147483647));  // 2^31 - 1
    169     assertLongEquals(-2147483647L, $opt$noinline$IntToLong(-2147483647));  // -(2^31 - 1)
    170     assertLongEquals(-2147483648L, $opt$noinline$IntToLong(-2147483648));  // -(2^31)
    171   }
    172 
    173   private static void charToLong() {
    174     assertLongEquals(1L, $opt$noinline$CharToLong((char)1));
    175     assertLongEquals(0L, $opt$noinline$CharToLong((char)0));
    176     assertLongEquals(51L, $opt$noinline$CharToLong((char)51));
    177     assertLongEquals(32767L, $opt$noinline$CharToLong((char)32767));  // 2^15 - 1
    178     assertLongEquals(65535L, $opt$noinline$CharToLong((char)65535));  // 2^16 - 1
    179     assertLongEquals(65535L, $opt$noinline$CharToLong((char)-1));
    180     assertLongEquals(65485L, $opt$noinline$CharToLong((char)-51));
    181     assertLongEquals(32769L, $opt$noinline$CharToLong((char)-32767));  // -(2^15 - 1)
    182     assertLongEquals(32768L, $opt$noinline$CharToLong((char)-32768));  // -(2^15)
    183   }
    184 
    185   private static void byteToFloat() {
    186     assertFloatEquals(1F, $opt$noinline$ByteToFloat((byte)1));
    187     assertFloatEquals(0F, $opt$noinline$ByteToFloat((byte)0));
    188     assertFloatEquals(-1F, $opt$noinline$ByteToFloat((byte)-1));
    189     assertFloatEquals(51F, $opt$noinline$ByteToFloat((byte)51));
    190     assertFloatEquals(-51F, $opt$noinline$ByteToFloat((byte)-51));
    191     assertFloatEquals(127F, $opt$noinline$ByteToFloat((byte)127));  // 2^7 - 1
    192     assertFloatEquals(-127F, $opt$noinline$ByteToFloat((byte)-127));  // -(2^7 - 1)
    193     assertFloatEquals(-128F, $opt$noinline$ByteToFloat((byte)-128));  // -(2^7)
    194   }
    195 
    196   private static void shortToFloat() {
    197     assertFloatEquals(1F, $opt$noinline$ShortToFloat((short)1));
    198     assertFloatEquals(0F, $opt$noinline$ShortToFloat((short)0));
    199     assertFloatEquals(-1F, $opt$noinline$ShortToFloat((short)-1));
    200     assertFloatEquals(51F, $opt$noinline$ShortToFloat((short)51));
    201     assertFloatEquals(-51F, $opt$noinline$ShortToFloat((short)-51));
    202     assertFloatEquals(32767F, $opt$noinline$ShortToFloat((short)32767));  // 2^15 - 1
    203     assertFloatEquals(-32767F, $opt$noinline$ShortToFloat((short)-32767));  // -(2^15 - 1)
    204     assertFloatEquals(-32768F, $opt$noinline$ShortToFloat((short)-32768));  // -(2^15)
    205   }
    206 
    207   private static void intToFloat() {
    208     assertFloatEquals(1F, $opt$noinline$IntToFloat(1));
    209     assertFloatEquals(0F, $opt$noinline$IntToFloat(0));
    210     assertFloatEquals(-1F, $opt$noinline$IntToFloat(-1));
    211     assertFloatEquals(51F, $opt$noinline$IntToFloat(51));
    212     assertFloatEquals(-51F, $opt$noinline$IntToFloat(-51));
    213     assertFloatEquals(16777215F, $opt$noinline$IntToFloat(16777215));  // 2^24 - 1
    214     assertFloatEquals(-16777215F, $opt$noinline$IntToFloat(-16777215));  // -(2^24 - 1)
    215     assertFloatEquals(16777216F, $opt$noinline$IntToFloat(16777216));  // 2^24
    216     assertFloatEquals(-16777216F, $opt$noinline$IntToFloat(-16777216));  // -(2^24)
    217     assertFloatEquals(2147483647F, $opt$noinline$IntToFloat(2147483647));  // 2^31 - 1
    218     assertFloatEquals(-2147483648F, $opt$noinline$IntToFloat(-2147483648));  // -(2^31)
    219   }
    220 
    221   private static void charToFloat() {
    222     assertFloatEquals(1F, $opt$noinline$CharToFloat((char)1));
    223     assertFloatEquals(0F, $opt$noinline$CharToFloat((char)0));
    224     assertFloatEquals(51F, $opt$noinline$CharToFloat((char)51));
    225     assertFloatEquals(32767F, $opt$noinline$CharToFloat((char)32767));  // 2^15 - 1
    226     assertFloatEquals(65535F, $opt$noinline$CharToFloat((char)65535));  // 2^16 - 1
    227     assertFloatEquals(65535F, $opt$noinline$CharToFloat((char)-1));
    228     assertFloatEquals(65485F, $opt$noinline$CharToFloat((char)-51));
    229     assertFloatEquals(32769F, $opt$noinline$CharToFloat((char)-32767));  // -(2^15 - 1)
    230     assertFloatEquals(32768F, $opt$noinline$CharToFloat((char)-32768));  // -(2^15)
    231   }
    232 
    233   private static void byteToDouble() {
    234     assertDoubleEquals(1D, $opt$noinline$ByteToDouble((byte)1));
    235     assertDoubleEquals(0D, $opt$noinline$ByteToDouble((byte)0));
    236     assertDoubleEquals(-1D, $opt$noinline$ByteToDouble((byte)-1));
    237     assertDoubleEquals(51D, $opt$noinline$ByteToDouble((byte)51));
    238     assertDoubleEquals(-51D, $opt$noinline$ByteToDouble((byte)-51));
    239     assertDoubleEquals(127D, $opt$noinline$ByteToDouble((byte)127));  // 2^7 - 1
    240     assertDoubleEquals(-127D, $opt$noinline$ByteToDouble((byte)-127));  // -(2^7 - 1)
    241     assertDoubleEquals(-128D, $opt$noinline$ByteToDouble((byte)-128));  // -(2^7)
    242   }
    243 
    244   private static void shortToDouble() {
    245     assertDoubleEquals(1D, $opt$noinline$ShortToDouble((short)1));
    246     assertDoubleEquals(0D, $opt$noinline$ShortToDouble((short)0));
    247     assertDoubleEquals(-1D, $opt$noinline$ShortToDouble((short)-1));
    248     assertDoubleEquals(51D, $opt$noinline$ShortToDouble((short)51));
    249     assertDoubleEquals(-51D, $opt$noinline$ShortToDouble((short)-51));
    250     assertDoubleEquals(32767D, $opt$noinline$ShortToDouble((short)32767));  // 2^15 - 1
    251     assertDoubleEquals(-32767D, $opt$noinline$ShortToDouble((short)-32767));  // -(2^15 - 1)
    252     assertDoubleEquals(-32768D, $opt$noinline$ShortToDouble((short)-32768));  // -(2^15)
    253   }
    254 
    255   private static void intToDouble() {
    256     assertDoubleEquals(1D, $opt$noinline$IntToDouble(1));
    257     assertDoubleEquals(0D, $opt$noinline$IntToDouble(0));
    258     assertDoubleEquals(-1D, $opt$noinline$IntToDouble(-1));
    259     assertDoubleEquals(51D, $opt$noinline$IntToDouble(51));
    260     assertDoubleEquals(-51D, $opt$noinline$IntToDouble(-51));
    261     assertDoubleEquals(16777216D, $opt$noinline$IntToDouble(16777216));  // 2^24
    262     assertDoubleEquals(-16777216D, $opt$noinline$IntToDouble(-16777216));  // -(2^24)
    263     assertDoubleEquals(2147483647D, $opt$noinline$IntToDouble(2147483647));  // 2^31 - 1
    264     assertDoubleEquals(-2147483648D, $opt$noinline$IntToDouble(-2147483648));  // -(2^31)
    265   }
    266 
    267   private static void charToDouble() {
    268     assertDoubleEquals(1D, $opt$noinline$CharToDouble((char)1));
    269     assertDoubleEquals(0D, $opt$noinline$CharToDouble((char)0));
    270     assertDoubleEquals(51D, $opt$noinline$CharToDouble((char)51));
    271     assertDoubleEquals(32767D, $opt$noinline$CharToDouble((char)32767));  // 2^15 - 1
    272     assertDoubleEquals(65535D, $opt$noinline$CharToDouble((char)65535));  // 2^16 - 1
    273     assertDoubleEquals(65535D, $opt$noinline$CharToDouble((char)-1));
    274     assertDoubleEquals(65485D, $opt$noinline$CharToDouble((char)-51));
    275     assertDoubleEquals(32769D, $opt$noinline$CharToDouble((char)-32767));  // -(2^15 - 1)
    276     assertDoubleEquals(32768D, $opt$noinline$CharToDouble((char)-32768));  // -(2^15)
    277   }
    278 
    279   private static void longToInt() {
    280     assertIntEquals(1, $opt$noinline$LongToInt(1L));
    281     assertIntEquals(0, $opt$noinline$LongToInt(0L));
    282     assertIntEquals(-1, $opt$noinline$LongToInt(-1L));
    283     assertIntEquals(51, $opt$noinline$LongToInt(51L));
    284     assertIntEquals(-51, $opt$noinline$LongToInt(-51L));
    285     assertIntEquals(2147483647, $opt$noinline$LongToInt(2147483647L));  // 2^31 - 1
    286     assertIntEquals(-2147483647, $opt$noinline$LongToInt(-2147483647L));  // -(2^31 - 1)
    287     assertIntEquals(-2147483648, $opt$noinline$LongToInt(-2147483648L));  // -(2^31)
    288     assertIntEquals(-2147483648, $opt$noinline$LongToInt(2147483648L));  // (2^31)
    289     assertIntEquals(2147483647, $opt$noinline$LongToInt(-2147483649L));  // -(2^31 + 1)
    290     assertIntEquals(-1, $opt$noinline$LongToInt(9223372036854775807L));  // 2^63 - 1
    291     assertIntEquals(1, $opt$noinline$LongToInt(-9223372036854775807L));  // -(2^63 - 1)
    292     assertIntEquals(0, $opt$noinline$LongToInt(-9223372036854775808L));  // -(2^63)
    293 
    294     assertIntEquals(42, $opt$noinline$LongLiteralToInt());
    295 
    296     // Ensure long-to-int conversions truncates values as expected.
    297     assertLongEquals(1L, $opt$noinline$IntToLong($opt$noinline$LongToInt(4294967297L)));  // 2^32 + 1
    298     assertLongEquals(0L, $opt$noinline$IntToLong($opt$noinline$LongToInt(4294967296L)));  // 2^32
    299     assertLongEquals(-1L, $opt$noinline$IntToLong($opt$noinline$LongToInt(4294967295L)));  // 2^32 - 1
    300     assertLongEquals(0L, $opt$noinline$IntToLong($opt$noinline$LongToInt(0L)));
    301     assertLongEquals(1L, $opt$noinline$IntToLong($opt$noinline$LongToInt(-4294967295L)));  // -(2^32 - 1)
    302     assertLongEquals(0L, $opt$noinline$IntToLong($opt$noinline$LongToInt(-4294967296L)));  // -(2^32)
    303     assertLongEquals(-1, $opt$noinline$IntToLong($opt$noinline$LongToInt(-4294967297L)));  // -(2^32 + 1)
    304   }
    305 
    306   private static void longToFloat() {
    307     assertFloatEquals(1F, $opt$noinline$LongToFloat(1L));
    308     assertFloatEquals(0F, $opt$noinline$LongToFloat(0L));
    309     assertFloatEquals(-1F, $opt$noinline$LongToFloat(-1L));
    310     assertFloatEquals(51F, $opt$noinline$LongToFloat(51L));
    311     assertFloatEquals(-51F, $opt$noinline$LongToFloat(-51L));
    312     assertFloatEquals(2147483647F, $opt$noinline$LongToFloat(2147483647L));  // 2^31 - 1
    313     assertFloatEquals(-2147483647F, $opt$noinline$LongToFloat(-2147483647L));  // -(2^31 - 1)
    314     assertFloatEquals(-2147483648F, $opt$noinline$LongToFloat(-2147483648L));  // -(2^31)
    315     assertFloatEquals(2147483648F, $opt$noinline$LongToFloat(2147483648L));  // (2^31)
    316     assertFloatEquals(-2147483649F, $opt$noinline$LongToFloat(-2147483649L));  // -(2^31 + 1)
    317     assertFloatEquals(4294967296F, $opt$noinline$LongToFloat(4294967296L));  // (2^32)
    318     assertFloatEquals(-4294967296F, $opt$noinline$LongToFloat(-4294967296L));  // -(2^32)
    319     assertFloatEquals(140739635871745F, $opt$noinline$LongToFloat(140739635871745L));  // 1 + 2^15 + 2^31 + 2^47
    320     assertFloatEquals(-140739635871745F, $opt$noinline$LongToFloat(-140739635871745L));  // -(1 + 2^15 + 2^31 + 2^47)
    321     assertFloatEquals(9223372036854775807F, $opt$noinline$LongToFloat(9223372036854775807L));  // 2^63 - 1
    322     assertFloatEquals(-9223372036854775807F, $opt$noinline$LongToFloat(-9223372036854775807L));  // -(2^63 - 1)
    323     assertFloatEquals(-9223372036854775808F, $opt$noinline$LongToFloat(-9223372036854775808L));  // -(2^63)
    324   }
    325 
    326   private static void longToDouble() {
    327     assertDoubleEquals(1D, $opt$noinline$LongToDouble(1L));
    328     assertDoubleEquals(0D, $opt$noinline$LongToDouble(0L));
    329     assertDoubleEquals(-1D, $opt$noinline$LongToDouble(-1L));
    330     assertDoubleEquals(51D, $opt$noinline$LongToDouble(51L));
    331     assertDoubleEquals(-51D, $opt$noinline$LongToDouble(-51L));
    332     assertDoubleEquals(2147483647D, $opt$noinline$LongToDouble(2147483647L));  // 2^31 - 1
    333     assertDoubleEquals(-2147483647D, $opt$noinline$LongToDouble(-2147483647L));  // -(2^31 - 1)
    334     assertDoubleEquals(-2147483648D, $opt$noinline$LongToDouble(-2147483648L));  // -(2^31)
    335     assertDoubleEquals(2147483648D, $opt$noinline$LongToDouble(2147483648L));  // (2^31)
    336     assertDoubleEquals(-2147483649D, $opt$noinline$LongToDouble(-2147483649L));  // -(2^31 + 1)
    337     assertDoubleEquals(4294967296D, $opt$noinline$LongToDouble(4294967296L));  // (2^32)
    338     assertDoubleEquals(-4294967296D, $opt$noinline$LongToDouble(-4294967296L));  // -(2^32)
    339     assertDoubleEquals(140739635871745D, $opt$noinline$LongToDouble(140739635871745L));  // 1 + 2^15 + 2^31 + 2^47
    340     assertDoubleEquals(-140739635871745D, $opt$noinline$LongToDouble(-140739635871745L));  // -(1 + 2^15 + 2^31 + 2^47)
    341     assertDoubleEquals(9223372036854775807D, $opt$noinline$LongToDouble(9223372036854775807L));  // 2^63 - 1
    342     assertDoubleEquals(-9223372036854775807D, $opt$noinline$LongToDouble(-9223372036854775807L));  // -(2^63 - 1)
    343     assertDoubleEquals(-9223372036854775808D, $opt$noinline$LongToDouble(-9223372036854775808L));  // -(2^63)
    344   }
    345 
    346   private static void floatToInt() {
    347     assertIntEquals(1, $opt$noinline$FloatToInt(1F));
    348     assertIntEquals(0, $opt$noinline$FloatToInt(0F));
    349     assertIntEquals(0, $opt$noinline$FloatToInt(-0F));
    350     assertIntEquals(-1, $opt$noinline$FloatToInt(-1F));
    351     assertIntEquals(51, $opt$noinline$FloatToInt(51F));
    352     assertIntEquals(-51, $opt$noinline$FloatToInt(-51F));
    353     assertIntEquals(0, $opt$noinline$FloatToInt(0.5F));
    354     assertIntEquals(0, $opt$noinline$FloatToInt(0.4999999F));
    355     assertIntEquals(0, $opt$noinline$FloatToInt(-0.4999999F));
    356     assertIntEquals(0, $opt$noinline$FloatToInt(-0.5F));
    357     assertIntEquals(42, $opt$noinline$FloatToInt(42.199F));
    358     assertIntEquals(-42, $opt$noinline$FloatToInt(-42.199F));
    359     assertIntEquals(2147483647, $opt$noinline$FloatToInt(2147483647F));  // 2^31 - 1
    360     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(-2147483647F));  // -(2^31 - 1)
    361     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(-2147483648F));  // -(2^31)
    362     assertIntEquals(2147483647, $opt$noinline$FloatToInt(2147483648F));  // (2^31)
    363     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(-2147483649F));  // -(2^31 + 1)
    364     assertIntEquals(2147483647, $opt$noinline$FloatToInt(9223372036854775807F));  // 2^63 - 1
    365     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(-9223372036854775807F));  // -(2^63 - 1)
    366     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(-9223372036854775808F));  // -(2^63)
    367     assertIntEquals(0, $opt$noinline$FloatToInt(Float.NaN));
    368     assertIntEquals(2147483647, $opt$noinline$FloatToInt(Float.POSITIVE_INFINITY));
    369     assertIntEquals(-2147483648, $opt$noinline$FloatToInt(Float.NEGATIVE_INFINITY));
    370   }
    371 
    372   private static void floatToLong() {
    373     assertLongEquals(1L, $opt$noinline$FloatToLong(1F));
    374     assertLongEquals(0L, $opt$noinline$FloatToLong(0F));
    375     assertLongEquals(0L, $opt$noinline$FloatToLong(-0F));
    376     assertLongEquals(-1L, $opt$noinline$FloatToLong(-1F));
    377     assertLongEquals(51L, $opt$noinline$FloatToLong(51F));
    378     assertLongEquals(-51L, $opt$noinline$FloatToLong(-51F));
    379     assertLongEquals(0L, $opt$noinline$FloatToLong(0.5F));
    380     assertLongEquals(0L, $opt$noinline$FloatToLong(0.4999999F));
    381     assertLongEquals(0L, $opt$noinline$FloatToLong(-0.4999999F));
    382     assertLongEquals(0L, $opt$noinline$FloatToLong(-0.5F));
    383     assertLongEquals(42L, $opt$noinline$FloatToLong(42.199F));
    384     assertLongEquals(-42L, $opt$noinline$FloatToLong(-42.199F));
    385     assertLongEquals(2147483648L, $opt$noinline$FloatToLong(2147483647F));  // 2^31 - 1
    386     assertLongEquals(-2147483648L, $opt$noinline$FloatToLong(-2147483647F));  // -(2^31 - 1)
    387     assertLongEquals(-2147483648L, $opt$noinline$FloatToLong(-2147483648F));  // -(2^31)
    388     assertLongEquals(2147483648L, $opt$noinline$FloatToLong(2147483648F));  // (2^31)
    389     assertLongEquals(-2147483648L, $opt$noinline$FloatToLong(-2147483649F));  // -(2^31 + 1)
    390     assertLongEquals(9223372036854775807L, $opt$noinline$FloatToLong(9223372036854775807F));  // 2^63 - 1
    391     assertLongEquals(-9223372036854775808L, $opt$noinline$FloatToLong(-9223372036854775807F));  // -(2^63 - 1)
    392     assertLongEquals(-9223372036854775808L, $opt$noinline$FloatToLong(-9223372036854775808F));  // -(2^63)
    393     assertLongEquals(9223371487098961920L, $opt$noinline$FloatToLong(9223371487098961920F));  // Math.nextAfter(2F^63, 0)
    394     assertLongEquals(-9223371487098961920L, $opt$noinline$FloatToLong(-9223371487098961920F));  // Math.nextAfter(-2F^63, 0)
    395     assertLongEquals(0L, $opt$noinline$FloatToLong(Float.NaN));
    396     assertLongEquals(9223372036854775807L, $opt$noinline$FloatToLong(Float.POSITIVE_INFINITY));
    397     assertLongEquals(-9223372036854775808L, $opt$noinline$FloatToLong(Float.NEGATIVE_INFINITY));
    398   }
    399 
    400   private static void floatToDouble() {
    401     assertDoubleEquals(1D, $opt$noinline$FloatToDouble(1F));
    402     assertDoubleEquals(0D, $opt$noinline$FloatToDouble(0F));
    403     assertDoubleEquals(0D, $opt$noinline$FloatToDouble(-0F));
    404     assertDoubleEquals(-1D, $opt$noinline$FloatToDouble(-1F));
    405     assertDoubleEquals(51D, $opt$noinline$FloatToDouble(51F));
    406     assertDoubleEquals(-51D, $opt$noinline$FloatToDouble(-51F));
    407     assertDoubleEquals(0.5D, $opt$noinline$FloatToDouble(0.5F));
    408     assertDoubleEquals(0.49999991059303284D, $opt$noinline$FloatToDouble(0.4999999F));
    409     assertDoubleEquals(-0.49999991059303284D, $opt$noinline$FloatToDouble(-0.4999999F));
    410     assertDoubleEquals(-0.5D, $opt$noinline$FloatToDouble(-0.5F));
    411     assertDoubleEquals(42.19900131225586D, $opt$noinline$FloatToDouble(42.199F));
    412     assertDoubleEquals(-42.19900131225586D, $opt$noinline$FloatToDouble(-42.199F));
    413     assertDoubleEquals(2147483648D, $opt$noinline$FloatToDouble(2147483647F));  // 2^31 - 1
    414     assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483647F));  // -(2^31 - 1)
    415     assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483648F));  // -(2^31)
    416     assertDoubleEquals(2147483648D, $opt$noinline$FloatToDouble(2147483648F));  // (2^31)
    417     assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483649F));  // -(2^31 + 1)
    418     assertDoubleEquals(9223372036854775807D, $opt$noinline$FloatToDouble(9223372036854775807F));  // 2^63 - 1
    419     assertDoubleEquals(-9223372036854775807D, $opt$noinline$FloatToDouble(-9223372036854775807F));  // -(2^63 - 1)
    420     assertDoubleEquals(-9223372036854775808D, $opt$noinline$FloatToDouble(-9223372036854775808F));  // -(2^63)
    421     assertDoubleIsNaN($opt$noinline$FloatToDouble(Float.NaN));
    422     assertDoubleEquals(Double.POSITIVE_INFINITY, $opt$noinline$FloatToDouble(Float.POSITIVE_INFINITY));
    423     assertDoubleEquals(Double.NEGATIVE_INFINITY, $opt$noinline$FloatToDouble(Float.NEGATIVE_INFINITY));
    424   }
    425 
    426   private static void doubleToInt() {
    427     assertIntEquals(1, $opt$noinline$DoubleToInt(1D));
    428     assertIntEquals(0, $opt$noinline$DoubleToInt(0D));
    429     assertIntEquals(0, $opt$noinline$DoubleToInt(-0D));
    430     assertIntEquals(-1, $opt$noinline$DoubleToInt(-1D));
    431     assertIntEquals(51, $opt$noinline$DoubleToInt(51D));
    432     assertIntEquals(-51, $opt$noinline$DoubleToInt(-51D));
    433     assertIntEquals(0, $opt$noinline$DoubleToInt(0.5D));
    434     assertIntEquals(0, $opt$noinline$DoubleToInt(0.4999999D));
    435     assertIntEquals(0, $opt$noinline$DoubleToInt(-0.4999999D));
    436     assertIntEquals(0, $opt$noinline$DoubleToInt(-0.5D));
    437     assertIntEquals(42, $opt$noinline$DoubleToInt(42.199D));
    438     assertIntEquals(-42, $opt$noinline$DoubleToInt(-42.199D));
    439     assertIntEquals(2147483647, $opt$noinline$DoubleToInt(2147483647D));  // 2^31 - 1
    440     assertIntEquals(-2147483647, $opt$noinline$DoubleToInt(-2147483647D));  // -(2^31 - 1)
    441     assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-2147483648D));  // -(2^31)
    442     assertIntEquals(2147483647, $opt$noinline$DoubleToInt(2147483648D));  // (2^31)
    443     assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-2147483649D));  // -(2^31 + 1)
    444     assertIntEquals(2147483647, $opt$noinline$DoubleToInt(9223372036854775807D));  // 2^63 - 1
    445     assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-9223372036854775807D));  // -(2^63 - 1)
    446     assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-9223372036854775808D));  // -(2^63)
    447     assertIntEquals(0, $opt$noinline$DoubleToInt(Double.NaN));
    448     assertIntEquals(2147483647, $opt$noinline$DoubleToInt(Double.POSITIVE_INFINITY));
    449     assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(Double.NEGATIVE_INFINITY));
    450   }
    451 
    452   private static void doubleToLong() {
    453     assertLongEquals(1L, $opt$noinline$DoubleToLong(1D));
    454     assertLongEquals(0L, $opt$noinline$DoubleToLong(0D));
    455     assertLongEquals(0L, $opt$noinline$DoubleToLong(-0D));
    456     assertLongEquals(-1L, $opt$noinline$DoubleToLong(-1D));
    457     assertLongEquals(51L, $opt$noinline$DoubleToLong(51D));
    458     assertLongEquals(-51L, $opt$noinline$DoubleToLong(-51D));
    459     assertLongEquals(0L, $opt$noinline$DoubleToLong(0.5D));
    460     assertLongEquals(0L, $opt$noinline$DoubleToLong(0.4999999D));
    461     assertLongEquals(0L, $opt$noinline$DoubleToLong(-0.4999999D));
    462     assertLongEquals(0L, $opt$noinline$DoubleToLong(-0.5D));
    463     assertLongEquals(42L, $opt$noinline$DoubleToLong(42.199D));
    464     assertLongEquals(-42L, $opt$noinline$DoubleToLong(-42.199D));
    465     assertLongEquals(2147483647L, $opt$noinline$DoubleToLong(2147483647D));  // 2^31 - 1
    466     assertLongEquals(-2147483647L, $opt$noinline$DoubleToLong(-2147483647D));  // -(2^31 - 1)
    467     assertLongEquals(-2147483648L, $opt$noinline$DoubleToLong(-2147483648D));  // -(2^31)
    468     assertLongEquals(2147483648L, $opt$noinline$DoubleToLong(2147483648D));  // (2^31)
    469     assertLongEquals(-2147483649L, $opt$noinline$DoubleToLong(-2147483649D));  // -(2^31 + 1)
    470     assertLongEquals(9223372036854775807L, $opt$noinline$DoubleToLong(9223372036854775807D));  // 2^63 - 1
    471     assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(-9223372036854775807D));  // -(2^63 - 1)
    472     assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(-9223372036854775808D));  // -(2^63)
    473     assertLongEquals(0L, $opt$noinline$DoubleToLong(Double.NaN));
    474     assertLongEquals(9223372036854774784L, $opt$noinline$DoubleToLong(9223372036854774784D));  // Math.nextAfter(2D^63, 0)
    475     assertLongEquals(-9223372036854774784L, $opt$noinline$DoubleToLong(-9223372036854774784D));  // Math.nextAfter(-2D^63, 0)
    476     assertLongEquals(9223372036854775807L, $opt$noinline$DoubleToLong(Double.POSITIVE_INFINITY));
    477     assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(Double.NEGATIVE_INFINITY));
    478   }
    479 
    480   private static void doubleToFloat() {
    481     assertFloatEquals(1F, $opt$noinline$DoubleToFloat(1D));
    482     assertFloatEquals(0F, $opt$noinline$DoubleToFloat(0D));
    483     assertFloatEquals(0F, $opt$noinline$DoubleToFloat(-0D));
    484     assertFloatEquals(-1F, $opt$noinline$DoubleToFloat(-1D));
    485     assertFloatEquals(51F, $opt$noinline$DoubleToFloat(51D));
    486     assertFloatEquals(-51F, $opt$noinline$DoubleToFloat(-51D));
    487     assertFloatEquals(0.5F, $opt$noinline$DoubleToFloat(0.5D));
    488     assertFloatEquals(0.4999999F, $opt$noinline$DoubleToFloat(0.4999999D));
    489     assertFloatEquals(-0.4999999F, $opt$noinline$DoubleToFloat(-0.4999999D));
    490     assertFloatEquals(-0.5F, $opt$noinline$DoubleToFloat(-0.5D));
    491     assertFloatEquals(42.199F, $opt$noinline$DoubleToFloat(42.199D));
    492     assertFloatEquals(-42.199F, $opt$noinline$DoubleToFloat(-42.199D));
    493     assertFloatEquals(2147483648F, $opt$noinline$DoubleToFloat(2147483647D));  // 2^31 - 1
    494     assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483647D));  // -(2^31 - 1)
    495     assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483648D));  // -(2^31)
    496     assertFloatEquals(2147483648F, $opt$noinline$DoubleToFloat(2147483648D));  // (2^31)
    497     assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483649D));  // -(2^31 + 1)
    498     assertFloatEquals(9223372036854775807F, $opt$noinline$DoubleToFloat(9223372036854775807D));  // 2^63 - 1
    499     assertFloatEquals(-9223372036854775807F, $opt$noinline$DoubleToFloat(-9223372036854775807D));  // -(2^63 - 1)
    500     assertFloatEquals(-9223372036854775808F, $opt$noinline$DoubleToFloat(-9223372036854775808D));  // -(2^63)
    501     assertFloatIsNaN($opt$noinline$DoubleToFloat(Float.NaN));
    502     assertFloatEquals(Float.POSITIVE_INFINITY, $opt$noinline$DoubleToFloat(Double.POSITIVE_INFINITY));
    503     assertFloatEquals(Float.NEGATIVE_INFINITY, $opt$noinline$DoubleToFloat(Double.NEGATIVE_INFINITY));
    504   }
    505 
    506   private static void shortToByte() {
    507     assertByteEquals((byte)1, $opt$noinline$ShortToByte((short)1));
    508     assertByteEquals((byte)0, $opt$noinline$ShortToByte((short)0));
    509     assertByteEquals((byte)-1, $opt$noinline$ShortToByte((short)-1));
    510     assertByteEquals((byte)51, $opt$noinline$ShortToByte((short)51));
    511     assertByteEquals((byte)-51, $opt$noinline$ShortToByte((short)-51));
    512     assertByteEquals((byte)127, $opt$noinline$ShortToByte((short)127));  // 2^7 - 1
    513     assertByteEquals((byte)-127, $opt$noinline$ShortToByte((short)-127));  // -(2^7 - 1)
    514     assertByteEquals((byte)-128, $opt$noinline$ShortToByte((short)-128));  // -(2^7)
    515     assertByteEquals((byte)-128, $opt$noinline$ShortToByte((short)128));  // 2^7
    516     assertByteEquals((byte)127, $opt$noinline$ShortToByte((short)-129));  // -(2^7 + 1)
    517     assertByteEquals((byte)-1, $opt$noinline$ShortToByte((short)32767));  // 2^15 - 1
    518     assertByteEquals((byte)0, $opt$noinline$ShortToByte((short)-32768));  // -(2^15)
    519   }
    520 
    521   private static void intToByte() {
    522     assertByteEquals((byte)1, $opt$noinline$IntToByte(1));
    523     assertByteEquals((byte)0, $opt$noinline$IntToByte(0));
    524     assertByteEquals((byte)-1, $opt$noinline$IntToByte(-1));
    525     assertByteEquals((byte)51, $opt$noinline$IntToByte(51));
    526     assertByteEquals((byte)-51, $opt$noinline$IntToByte(-51));
    527     assertByteEquals((byte)127, $opt$noinline$IntToByte(127));  // 2^7 - 1
    528     assertByteEquals((byte)-127, $opt$noinline$IntToByte(-127));  // -(2^7 - 1)
    529     assertByteEquals((byte)-128, $opt$noinline$IntToByte(-128));  // -(2^7)
    530     assertByteEquals((byte)-128, $opt$noinline$IntToByte(128));  // 2^7
    531     assertByteEquals((byte)127, $opt$noinline$IntToByte(-129));  // -(2^7 + 1)
    532     assertByteEquals((byte)-1, $opt$noinline$IntToByte(2147483647));  // 2^31 - 1
    533     assertByteEquals((byte)0, $opt$noinline$IntToByte(-2147483648));  // -(2^31)
    534   }
    535 
    536   private static void charToByte() {
    537     assertByteEquals((byte)1, $opt$noinline$CharToByte((char)1));
    538     assertByteEquals((byte)0, $opt$noinline$CharToByte((char)0));
    539     assertByteEquals((byte)51, $opt$noinline$CharToByte((char)51));
    540     assertByteEquals((byte)127, $opt$noinline$CharToByte((char)127));  // 2^7 - 1
    541     assertByteEquals((byte)-128, $opt$noinline$CharToByte((char)128));  // 2^7
    542     assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)32767));  // 2^15 - 1
    543     assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)65535));  // 2^16 - 1
    544     assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)-1));
    545     assertByteEquals((byte)-51, $opt$noinline$CharToByte((char)-51));
    546     assertByteEquals((byte)-127, $opt$noinline$CharToByte((char)-127));  // -(2^7 - 1)
    547     assertByteEquals((byte)-128, $opt$noinline$CharToByte((char)-128));  // -(2^7)
    548     assertByteEquals((byte)127, $opt$noinline$CharToByte((char)-129));  // -(2^7 + 1)
    549   }
    550 
    551   private static void byteToShort() {
    552     assertShortEquals((short)1, $opt$noinline$ByteToShort((byte)1));
    553     assertShortEquals((short)0, $opt$noinline$ByteToShort((byte)0));
    554     assertShortEquals((short)-1, $opt$noinline$ByteToShort((byte)-1));
    555     assertShortEquals((short)51, $opt$noinline$ByteToShort((byte)51));
    556     assertShortEquals((short)-51, $opt$noinline$ByteToShort((byte)-51));
    557     assertShortEquals((short)127, $opt$noinline$ByteToShort((byte)127));  // 2^7 - 1
    558     assertShortEquals((short)-127, $opt$noinline$ByteToShort((byte)-127));  // -(2^7 - 1)
    559     assertShortEquals((short)-128, $opt$noinline$ByteToShort((byte)-128));  // -(2^7)
    560   }
    561 
    562   private static void intToShort() {
    563     assertShortEquals((short)1, $opt$noinline$IntToShort(1));
    564     assertShortEquals((short)0, $opt$noinline$IntToShort(0));
    565     assertShortEquals((short)-1, $opt$noinline$IntToShort(-1));
    566     assertShortEquals((short)51, $opt$noinline$IntToShort(51));
    567     assertShortEquals((short)-51, $opt$noinline$IntToShort(-51));
    568     assertShortEquals((short)32767, $opt$noinline$IntToShort(32767));  // 2^15 - 1
    569     assertShortEquals((short)-32767, $opt$noinline$IntToShort(-32767));  // -(2^15 - 1)
    570     assertShortEquals((short)-32768, $opt$noinline$IntToShort(-32768));  // -(2^15)
    571     assertShortEquals((short)-32768, $opt$noinline$IntToShort(32768));  // 2^15
    572     assertShortEquals((short)32767, $opt$noinline$IntToShort(-32769));  // -(2^15 + 1)
    573     assertShortEquals((short)-1, $opt$noinline$IntToShort(2147483647));  // 2^31 - 1
    574     assertShortEquals((short)0, $opt$noinline$IntToShort(-2147483648));  // -(2^31)
    575   }
    576 
    577   private static void charToShort() {
    578     assertShortEquals((short)1, $opt$noinline$CharToShort((char)1));
    579     assertShortEquals((short)0, $opt$noinline$CharToShort((char)0));
    580     assertShortEquals((short)51, $opt$noinline$CharToShort((char)51));
    581     assertShortEquals((short)32767, $opt$noinline$CharToShort((char)32767));  // 2^15 - 1
    582     assertShortEquals((short)-32768, $opt$noinline$CharToShort((char)32768));  // 2^15
    583     assertShortEquals((short)-32767, $opt$noinline$CharToShort((char)32769));  // 2^15
    584     assertShortEquals((short)-1, $opt$noinline$CharToShort((char)65535));  // 2^16 - 1
    585     assertShortEquals((short)-1, $opt$noinline$CharToShort((char)-1));
    586     assertShortEquals((short)-51, $opt$noinline$CharToShort((char)-51));
    587     assertShortEquals((short)-32767, $opt$noinline$CharToShort((char)-32767));  // -(2^15 - 1)
    588     assertShortEquals((short)-32768, $opt$noinline$CharToShort((char)-32768));  // -(2^15)
    589     assertShortEquals((short)32767, $opt$noinline$CharToShort((char)-32769));  // -(2^15 + 1)
    590   }
    591 
    592   private static void byteToChar() {
    593     assertCharEquals((char)1, $opt$noinline$ByteToChar((byte)1));
    594     assertCharEquals((char)0, $opt$noinline$ByteToChar((byte)0));
    595     assertCharEquals((char)65535, $opt$noinline$ByteToChar((byte)-1));
    596     assertCharEquals((char)51, $opt$noinline$ByteToChar((byte)51));
    597     assertCharEquals((char)65485, $opt$noinline$ByteToChar((byte)-51));
    598     assertCharEquals((char)127, $opt$noinline$ByteToChar((byte)127));  // 2^7 - 1
    599     assertCharEquals((char)65409, $opt$noinline$ByteToChar((byte)-127));  // -(2^7 - 1)
    600     assertCharEquals((char)65408, $opt$noinline$ByteToChar((byte)-128));  // -(2^7)
    601   }
    602 
    603   private static void shortToChar() {
    604     assertCharEquals((char)1, $opt$noinline$ShortToChar((short)1));
    605     assertCharEquals((char)0, $opt$noinline$ShortToChar((short)0));
    606     assertCharEquals((char)65535, $opt$noinline$ShortToChar((short)-1));
    607     assertCharEquals((char)51, $opt$noinline$ShortToChar((short)51));
    608     assertCharEquals((char)65485, $opt$noinline$ShortToChar((short)-51));
    609     assertCharEquals((char)32767, $opt$noinline$ShortToChar((short)32767));  // 2^15 - 1
    610     assertCharEquals((char)32769, $opt$noinline$ShortToChar((short)-32767));  // -(2^15 - 1)
    611     assertCharEquals((char)32768, $opt$noinline$ShortToChar((short)-32768));  // -(2^15)
    612   }
    613 
    614   private static void intToChar() {
    615     assertCharEquals((char)1, $opt$noinline$IntToChar(1));
    616     assertCharEquals((char)0, $opt$noinline$IntToChar(0));
    617     assertCharEquals((char)65535, $opt$noinline$IntToChar(-1));
    618     assertCharEquals((char)51, $opt$noinline$IntToChar(51));
    619     assertCharEquals((char)65485, $opt$noinline$IntToChar(-51));
    620     assertCharEquals((char)32767, $opt$noinline$IntToChar(32767));  // 2^15 - 1
    621     assertCharEquals((char)32769, $opt$noinline$IntToChar(-32767));  // -(2^15 - 1)
    622     assertCharEquals((char)32768, $opt$noinline$IntToChar(32768));  // 2^15
    623     assertCharEquals((char)32768, $opt$noinline$IntToChar(-32768));  // -(2^15)
    624     assertCharEquals((char)65535, $opt$noinline$IntToChar(65535));  // 2^16 - 1
    625     assertCharEquals((char)1, $opt$noinline$IntToChar(-65535));  // -(2^16 - 1)
    626     assertCharEquals((char)0, $opt$noinline$IntToChar(65536));  // 2^16
    627     assertCharEquals((char)0, $opt$noinline$IntToChar(-65536));  // -(2^16)
    628     assertCharEquals((char)65535, $opt$noinline$IntToChar(2147483647));  // 2^31 - 1
    629     assertCharEquals((char)0, $opt$noinline$IntToChar(-2147483648));  // -(2^31)
    630   }
    631 
    632   // A dummy value to defeat inlining of these routines.
    633   static boolean doThrow = false;
    634 
    635   // These methods produce int-to-long Dex instructions.
    636   static long $opt$noinline$ByteToLong(byte a) { if (doThrow) throw new Error(); return (long)a; }
    637   static long $opt$noinline$ShortToLong(short a) { if (doThrow) throw new Error(); return (long)a; }
    638   static long $opt$noinline$IntToLong(int a) { if (doThrow) throw new Error(); return (long)a; }
    639   static long $opt$noinline$CharToLong(int a) { if (doThrow) throw new Error(); return (long)a; }
    640 
    641   // These methods produce int-to-float Dex instructions.
    642   static float $opt$noinline$ByteToFloat(byte a) { if (doThrow) throw new Error(); return (float)a; }
    643   static float $opt$noinline$ShortToFloat(short a) { if (doThrow) throw new Error(); return (float)a; }
    644   static float $opt$noinline$IntToFloat(int a) { if (doThrow) throw new Error(); return (float)a; }
    645   static float $opt$noinline$CharToFloat(char a) { if (doThrow) throw new Error(); return (float)a; }
    646 
    647   // These methods produce int-to-double Dex instructions.
    648   static double $opt$noinline$ByteToDouble(byte a) { if (doThrow) throw new Error(); return (double)a; }
    649   static double $opt$noinline$ShortToDouble(short a) { if (doThrow) throw new Error(); return (double)a; }
    650   static double $opt$noinline$IntToDouble(int a) { if (doThrow) throw new Error(); return (double)a; }
    651   static double $opt$noinline$CharToDouble(int a) { if (doThrow) throw new Error(); return (double)a; }
    652 
    653   // These methods produce long-to-int Dex instructions.
    654   static int $opt$noinline$LongToInt(long a) { if (doThrow) throw new Error(); return (int)a; }
    655   static int $opt$noinline$LongLiteralToInt() { if (doThrow) throw new Error(); return (int)42L; }
    656 
    657   // This method produces a long-to-float Dex instruction.
    658   static float $opt$noinline$LongToFloat(long a) { if (doThrow) throw new Error(); return (float)a; }
    659 
    660   // This method produces a long-to-double Dex instruction.
    661   static double $opt$noinline$LongToDouble(long a) { if (doThrow) throw new Error(); return (double)a; }
    662 
    663   // This method produces a float-to-int Dex instruction.
    664   static int $opt$noinline$FloatToInt(float a) { if (doThrow) throw new Error(); return (int)a; }
    665 
    666   // This method produces a float-to-long Dex instruction.
    667   static long $opt$noinline$FloatToLong(float a){ if (doThrow) throw new Error(); return (long)a; }
    668 
    669   // This method produces a float-to-double Dex instruction.
    670   static double $opt$noinline$FloatToDouble(float a) { if (doThrow) throw new Error(); return (double)a; }
    671 
    672   // This method produces a double-to-int Dex instruction.
    673   static int $opt$noinline$DoubleToInt(double a){ if (doThrow) throw new Error(); return (int)a; }
    674 
    675   // This method produces a double-to-long Dex instruction.
    676   static long $opt$noinline$DoubleToLong(double a){ if (doThrow) throw new Error(); return (long)a; }
    677 
    678   // This method produces a double-to-float Dex instruction.
    679   static float $opt$noinline$DoubleToFloat(double a) { if (doThrow) throw new Error(); return (float)a; }
    680 
    681   // These methods produce int-to-byte Dex instructions.
    682   static byte $opt$noinline$ShortToByte(short a) { if (doThrow) throw new Error(); return (byte)a; }
    683   static byte $opt$noinline$IntToByte(int a) { if (doThrow) throw new Error(); return (byte)a; }
    684   static byte $opt$noinline$CharToByte(char a) { if (doThrow) throw new Error(); return (byte)a; }
    685 
    686   // These methods produce int-to-short Dex instructions.
    687   static short $opt$noinline$ByteToShort(byte a) { if (doThrow) throw new Error(); return (short)a; }
    688   static short $opt$noinline$IntToShort(int a) { if (doThrow) throw new Error(); return (short)a; }
    689   static short $opt$noinline$CharToShort(char a) { if (doThrow) throw new Error(); return (short)a; }
    690 
    691   // These methods produce int-to-char Dex instructions.
    692   static char $opt$noinline$ByteToChar(byte a) { if (doThrow) throw new Error(); return (char)a; }
    693   static char $opt$noinline$ShortToChar(short a) { if (doThrow) throw new Error(); return (char)a; }
    694   static char $opt$noinline$IntToChar(int a) { if (doThrow) throw new Error(); return (char)a; }
    695 }
    696