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 assertByteEquals(byte expected, byte result)21 public static void assertByteEquals(byte expected, byte result) { 22 if (expected != result) { 23 throw new Error("Expected: " + expected + ", found: " + result); 24 } 25 } 26 assertShortEquals(short expected, short result)27 public static void assertShortEquals(short expected, short result) { 28 if (expected != result) { 29 throw new Error("Expected: " + expected + ", found: " + result); 30 } 31 } 32 assertIntEquals(int expected, int result)33 public static void assertIntEquals(int expected, int result) { 34 if (expected != result) { 35 throw new Error("Expected: " + expected + ", found: " + result); 36 } 37 } 38 assertLongEquals(long expected, long result)39 public static void assertLongEquals(long expected, long result) { 40 if (expected != result) { 41 throw new Error("Expected: " + expected + ", found: " + result); 42 } 43 } 44 assertCharEquals(char expected, char result)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 assertFloatEquals(float expected, float result)53 public static void assertFloatEquals(float expected, float result) { 54 if (expected != result) { 55 throw new Error("Expected: " + expected + ", found: " + result); 56 } 57 } 58 assertDoubleEquals(double expected, double result)59 public static void assertDoubleEquals(double expected, double result) { 60 if (expected != result) { 61 throw new Error("Expected: " + expected + ", found: " + result); 62 } 63 } 64 assertFloatIsNaN(float result)65 public static void assertFloatIsNaN(float result) { 66 if (!Float.isNaN(result)) { 67 throw new Error("Expected: NaN, found: " + result); 68 } 69 } 70 assertDoubleIsNaN(double result)71 public static void assertDoubleIsNaN(double result) { 72 if (!Double.isNaN(result)) { 73 throw new Error("Expected: NaN, found: " + result); 74 } 75 } 76 77 main(String[] args)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 byteToLong()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 shortToLong()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 intToLong()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 charToLong()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 byteToFloat()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 shortToFloat()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 intToFloat()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 charToFloat()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 byteToDouble()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 shortToDouble()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 intToDouble()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 charToDouble()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 longToInt()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 longToFloat()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 longToDouble()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 floatToInt()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 floatToLong()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(0L, $opt$noinline$FloatToLong(Float.NaN)); 394 assertLongEquals(9223372036854775807L, $opt$noinline$FloatToLong(Float.POSITIVE_INFINITY)); 395 assertLongEquals(-9223372036854775808L, $opt$noinline$FloatToLong(Float.NEGATIVE_INFINITY)); 396 } 397 floatToDouble()398 private static void floatToDouble() { 399 assertDoubleEquals(1D, $opt$noinline$FloatToDouble(1F)); 400 assertDoubleEquals(0D, $opt$noinline$FloatToDouble(0F)); 401 assertDoubleEquals(0D, $opt$noinline$FloatToDouble(-0F)); 402 assertDoubleEquals(-1D, $opt$noinline$FloatToDouble(-1F)); 403 assertDoubleEquals(51D, $opt$noinline$FloatToDouble(51F)); 404 assertDoubleEquals(-51D, $opt$noinline$FloatToDouble(-51F)); 405 assertDoubleEquals(0.5D, $opt$noinline$FloatToDouble(0.5F)); 406 assertDoubleEquals(0.49999991059303284D, $opt$noinline$FloatToDouble(0.4999999F)); 407 assertDoubleEquals(-0.49999991059303284D, $opt$noinline$FloatToDouble(-0.4999999F)); 408 assertDoubleEquals(-0.5D, $opt$noinline$FloatToDouble(-0.5F)); 409 assertDoubleEquals(42.19900131225586D, $opt$noinline$FloatToDouble(42.199F)); 410 assertDoubleEquals(-42.19900131225586D, $opt$noinline$FloatToDouble(-42.199F)); 411 assertDoubleEquals(2147483648D, $opt$noinline$FloatToDouble(2147483647F)); // 2^31 - 1 412 assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483647F)); // -(2^31 - 1) 413 assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483648F)); // -(2^31) 414 assertDoubleEquals(2147483648D, $opt$noinline$FloatToDouble(2147483648F)); // (2^31) 415 assertDoubleEquals(-2147483648D, $opt$noinline$FloatToDouble(-2147483649F)); // -(2^31 + 1) 416 assertDoubleEquals(9223372036854775807D, $opt$noinline$FloatToDouble(9223372036854775807F)); // 2^63 - 1 417 assertDoubleEquals(-9223372036854775807D, $opt$noinline$FloatToDouble(-9223372036854775807F)); // -(2^63 - 1) 418 assertDoubleEquals(-9223372036854775808D, $opt$noinline$FloatToDouble(-9223372036854775808F)); // -(2^63) 419 assertDoubleIsNaN($opt$noinline$FloatToDouble(Float.NaN)); 420 assertDoubleEquals(Double.POSITIVE_INFINITY, $opt$noinline$FloatToDouble(Float.POSITIVE_INFINITY)); 421 assertDoubleEquals(Double.NEGATIVE_INFINITY, $opt$noinline$FloatToDouble(Float.NEGATIVE_INFINITY)); 422 } 423 doubleToInt()424 private static void doubleToInt() { 425 assertIntEquals(1, $opt$noinline$DoubleToInt(1D)); 426 assertIntEquals(0, $opt$noinline$DoubleToInt(0D)); 427 assertIntEquals(0, $opt$noinline$DoubleToInt(-0D)); 428 assertIntEquals(-1, $opt$noinline$DoubleToInt(-1D)); 429 assertIntEquals(51, $opt$noinline$DoubleToInt(51D)); 430 assertIntEquals(-51, $opt$noinline$DoubleToInt(-51D)); 431 assertIntEquals(0, $opt$noinline$DoubleToInt(0.5D)); 432 assertIntEquals(0, $opt$noinline$DoubleToInt(0.4999999D)); 433 assertIntEquals(0, $opt$noinline$DoubleToInt(-0.4999999D)); 434 assertIntEquals(0, $opt$noinline$DoubleToInt(-0.5D)); 435 assertIntEquals(42, $opt$noinline$DoubleToInt(42.199D)); 436 assertIntEquals(-42, $opt$noinline$DoubleToInt(-42.199D)); 437 assertIntEquals(2147483647, $opt$noinline$DoubleToInt(2147483647D)); // 2^31 - 1 438 assertIntEquals(-2147483647, $opt$noinline$DoubleToInt(-2147483647D)); // -(2^31 - 1) 439 assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-2147483648D)); // -(2^31) 440 assertIntEquals(2147483647, $opt$noinline$DoubleToInt(2147483648D)); // (2^31) 441 assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-2147483649D)); // -(2^31 + 1) 442 assertIntEquals(2147483647, $opt$noinline$DoubleToInt(9223372036854775807D)); // 2^63 - 1 443 assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-9223372036854775807D)); // -(2^63 - 1) 444 assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(-9223372036854775808D)); // -(2^63) 445 assertIntEquals(0, $opt$noinline$DoubleToInt(Double.NaN)); 446 assertIntEquals(2147483647, $opt$noinline$DoubleToInt(Double.POSITIVE_INFINITY)); 447 assertIntEquals(-2147483648, $opt$noinline$DoubleToInt(Double.NEGATIVE_INFINITY)); 448 } 449 doubleToLong()450 private static void doubleToLong() { 451 assertLongEquals(1L, $opt$noinline$DoubleToLong(1D)); 452 assertLongEquals(0L, $opt$noinline$DoubleToLong(0D)); 453 assertLongEquals(0L, $opt$noinline$DoubleToLong(-0D)); 454 assertLongEquals(-1L, $opt$noinline$DoubleToLong(-1D)); 455 assertLongEquals(51L, $opt$noinline$DoubleToLong(51D)); 456 assertLongEquals(-51L, $opt$noinline$DoubleToLong(-51D)); 457 assertLongEquals(0L, $opt$noinline$DoubleToLong(0.5D)); 458 assertLongEquals(0L, $opt$noinline$DoubleToLong(0.4999999D)); 459 assertLongEquals(0L, $opt$noinline$DoubleToLong(-0.4999999D)); 460 assertLongEquals(0L, $opt$noinline$DoubleToLong(-0.5D)); 461 assertLongEquals(42L, $opt$noinline$DoubleToLong(42.199D)); 462 assertLongEquals(-42L, $opt$noinline$DoubleToLong(-42.199D)); 463 assertLongEquals(2147483647L, $opt$noinline$DoubleToLong(2147483647D)); // 2^31 - 1 464 assertLongEquals(-2147483647L, $opt$noinline$DoubleToLong(-2147483647D)); // -(2^31 - 1) 465 assertLongEquals(-2147483648L, $opt$noinline$DoubleToLong(-2147483648D)); // -(2^31) 466 assertLongEquals(2147483648L, $opt$noinline$DoubleToLong(2147483648D)); // (2^31) 467 assertLongEquals(-2147483649L, $opt$noinline$DoubleToLong(-2147483649D)); // -(2^31 + 1) 468 assertLongEquals(9223372036854775807L, $opt$noinline$DoubleToLong(9223372036854775807D)); // 2^63 - 1 469 assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(-9223372036854775807D)); // -(2^63 - 1) 470 assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(-9223372036854775808D)); // -(2^63) 471 assertLongEquals(0L, $opt$noinline$DoubleToLong(Double.NaN)); 472 assertLongEquals(9223372036854775807L, $opt$noinline$DoubleToLong(Double.POSITIVE_INFINITY)); 473 assertLongEquals(-9223372036854775808L, $opt$noinline$DoubleToLong(Double.NEGATIVE_INFINITY)); 474 } 475 doubleToFloat()476 private static void doubleToFloat() { 477 assertFloatEquals(1F, $opt$noinline$DoubleToFloat(1D)); 478 assertFloatEquals(0F, $opt$noinline$DoubleToFloat(0D)); 479 assertFloatEquals(0F, $opt$noinline$DoubleToFloat(-0D)); 480 assertFloatEquals(-1F, $opt$noinline$DoubleToFloat(-1D)); 481 assertFloatEquals(51F, $opt$noinline$DoubleToFloat(51D)); 482 assertFloatEquals(-51F, $opt$noinline$DoubleToFloat(-51D)); 483 assertFloatEquals(0.5F, $opt$noinline$DoubleToFloat(0.5D)); 484 assertFloatEquals(0.4999999F, $opt$noinline$DoubleToFloat(0.4999999D)); 485 assertFloatEquals(-0.4999999F, $opt$noinline$DoubleToFloat(-0.4999999D)); 486 assertFloatEquals(-0.5F, $opt$noinline$DoubleToFloat(-0.5D)); 487 assertFloatEquals(42.199F, $opt$noinline$DoubleToFloat(42.199D)); 488 assertFloatEquals(-42.199F, $opt$noinline$DoubleToFloat(-42.199D)); 489 assertFloatEquals(2147483648F, $opt$noinline$DoubleToFloat(2147483647D)); // 2^31 - 1 490 assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483647D)); // -(2^31 - 1) 491 assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483648D)); // -(2^31) 492 assertFloatEquals(2147483648F, $opt$noinline$DoubleToFloat(2147483648D)); // (2^31) 493 assertFloatEquals(-2147483648F, $opt$noinline$DoubleToFloat(-2147483649D)); // -(2^31 + 1) 494 assertFloatEquals(9223372036854775807F, $opt$noinline$DoubleToFloat(9223372036854775807D)); // 2^63 - 1 495 assertFloatEquals(-9223372036854775807F, $opt$noinline$DoubleToFloat(-9223372036854775807D)); // -(2^63 - 1) 496 assertFloatEquals(-9223372036854775808F, $opt$noinline$DoubleToFloat(-9223372036854775808D)); // -(2^63) 497 assertFloatIsNaN($opt$noinline$DoubleToFloat(Float.NaN)); 498 assertFloatEquals(Float.POSITIVE_INFINITY, $opt$noinline$DoubleToFloat(Double.POSITIVE_INFINITY)); 499 assertFloatEquals(Float.NEGATIVE_INFINITY, $opt$noinline$DoubleToFloat(Double.NEGATIVE_INFINITY)); 500 } 501 shortToByte()502 private static void shortToByte() { 503 assertByteEquals((byte)1, $opt$noinline$ShortToByte((short)1)); 504 assertByteEquals((byte)0, $opt$noinline$ShortToByte((short)0)); 505 assertByteEquals((byte)-1, $opt$noinline$ShortToByte((short)-1)); 506 assertByteEquals((byte)51, $opt$noinline$ShortToByte((short)51)); 507 assertByteEquals((byte)-51, $opt$noinline$ShortToByte((short)-51)); 508 assertByteEquals((byte)127, $opt$noinline$ShortToByte((short)127)); // 2^7 - 1 509 assertByteEquals((byte)-127, $opt$noinline$ShortToByte((short)-127)); // -(2^7 - 1) 510 assertByteEquals((byte)-128, $opt$noinline$ShortToByte((short)-128)); // -(2^7) 511 assertByteEquals((byte)-128, $opt$noinline$ShortToByte((short)128)); // 2^7 512 assertByteEquals((byte)127, $opt$noinline$ShortToByte((short)-129)); // -(2^7 + 1) 513 assertByteEquals((byte)-1, $opt$noinline$ShortToByte((short)32767)); // 2^15 - 1 514 assertByteEquals((byte)0, $opt$noinline$ShortToByte((short)-32768)); // -(2^15) 515 } 516 intToByte()517 private static void intToByte() { 518 assertByteEquals((byte)1, $opt$noinline$IntToByte(1)); 519 assertByteEquals((byte)0, $opt$noinline$IntToByte(0)); 520 assertByteEquals((byte)-1, $opt$noinline$IntToByte(-1)); 521 assertByteEquals((byte)51, $opt$noinline$IntToByte(51)); 522 assertByteEquals((byte)-51, $opt$noinline$IntToByte(-51)); 523 assertByteEquals((byte)127, $opt$noinline$IntToByte(127)); // 2^7 - 1 524 assertByteEquals((byte)-127, $opt$noinline$IntToByte(-127)); // -(2^7 - 1) 525 assertByteEquals((byte)-128, $opt$noinline$IntToByte(-128)); // -(2^7) 526 assertByteEquals((byte)-128, $opt$noinline$IntToByte(128)); // 2^7 527 assertByteEquals((byte)127, $opt$noinline$IntToByte(-129)); // -(2^7 + 1) 528 assertByteEquals((byte)-1, $opt$noinline$IntToByte(2147483647)); // 2^31 - 1 529 assertByteEquals((byte)0, $opt$noinline$IntToByte(-2147483648)); // -(2^31) 530 } 531 charToByte()532 private static void charToByte() { 533 assertByteEquals((byte)1, $opt$noinline$CharToByte((char)1)); 534 assertByteEquals((byte)0, $opt$noinline$CharToByte((char)0)); 535 assertByteEquals((byte)51, $opt$noinline$CharToByte((char)51)); 536 assertByteEquals((byte)127, $opt$noinline$CharToByte((char)127)); // 2^7 - 1 537 assertByteEquals((byte)-128, $opt$noinline$CharToByte((char)128)); // 2^7 538 assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)32767)); // 2^15 - 1 539 assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)65535)); // 2^16 - 1 540 assertByteEquals((byte)-1, $opt$noinline$CharToByte((char)-1)); 541 assertByteEquals((byte)-51, $opt$noinline$CharToByte((char)-51)); 542 assertByteEquals((byte)-127, $opt$noinline$CharToByte((char)-127)); // -(2^7 - 1) 543 assertByteEquals((byte)-128, $opt$noinline$CharToByte((char)-128)); // -(2^7) 544 assertByteEquals((byte)127, $opt$noinline$CharToByte((char)-129)); // -(2^7 + 1) 545 } 546 byteToShort()547 private static void byteToShort() { 548 assertShortEquals((short)1, $opt$noinline$ByteToShort((byte)1)); 549 assertShortEquals((short)0, $opt$noinline$ByteToShort((byte)0)); 550 assertShortEquals((short)-1, $opt$noinline$ByteToShort((byte)-1)); 551 assertShortEquals((short)51, $opt$noinline$ByteToShort((byte)51)); 552 assertShortEquals((short)-51, $opt$noinline$ByteToShort((byte)-51)); 553 assertShortEquals((short)127, $opt$noinline$ByteToShort((byte)127)); // 2^7 - 1 554 assertShortEquals((short)-127, $opt$noinline$ByteToShort((byte)-127)); // -(2^7 - 1) 555 assertShortEquals((short)-128, $opt$noinline$ByteToShort((byte)-128)); // -(2^7) 556 } 557 intToShort()558 private static void intToShort() { 559 assertShortEquals((short)1, $opt$noinline$IntToShort(1)); 560 assertShortEquals((short)0, $opt$noinline$IntToShort(0)); 561 assertShortEquals((short)-1, $opt$noinline$IntToShort(-1)); 562 assertShortEquals((short)51, $opt$noinline$IntToShort(51)); 563 assertShortEquals((short)-51, $opt$noinline$IntToShort(-51)); 564 assertShortEquals((short)32767, $opt$noinline$IntToShort(32767)); // 2^15 - 1 565 assertShortEquals((short)-32767, $opt$noinline$IntToShort(-32767)); // -(2^15 - 1) 566 assertShortEquals((short)-32768, $opt$noinline$IntToShort(-32768)); // -(2^15) 567 assertShortEquals((short)-32768, $opt$noinline$IntToShort(32768)); // 2^15 568 assertShortEquals((short)32767, $opt$noinline$IntToShort(-32769)); // -(2^15 + 1) 569 assertShortEquals((short)-1, $opt$noinline$IntToShort(2147483647)); // 2^31 - 1 570 assertShortEquals((short)0, $opt$noinline$IntToShort(-2147483648)); // -(2^31) 571 } 572 charToShort()573 private static void charToShort() { 574 assertShortEquals((short)1, $opt$noinline$CharToShort((char)1)); 575 assertShortEquals((short)0, $opt$noinline$CharToShort((char)0)); 576 assertShortEquals((short)51, $opt$noinline$CharToShort((char)51)); 577 assertShortEquals((short)32767, $opt$noinline$CharToShort((char)32767)); // 2^15 - 1 578 assertShortEquals((short)-32768, $opt$noinline$CharToShort((char)32768)); // 2^15 579 assertShortEquals((short)-32767, $opt$noinline$CharToShort((char)32769)); // 2^15 580 assertShortEquals((short)-1, $opt$noinline$CharToShort((char)65535)); // 2^16 - 1 581 assertShortEquals((short)-1, $opt$noinline$CharToShort((char)-1)); 582 assertShortEquals((short)-51, $opt$noinline$CharToShort((char)-51)); 583 assertShortEquals((short)-32767, $opt$noinline$CharToShort((char)-32767)); // -(2^15 - 1) 584 assertShortEquals((short)-32768, $opt$noinline$CharToShort((char)-32768)); // -(2^15) 585 assertShortEquals((short)32767, $opt$noinline$CharToShort((char)-32769)); // -(2^15 + 1) 586 } 587 byteToChar()588 private static void byteToChar() { 589 assertCharEquals((char)1, $opt$noinline$ByteToChar((byte)1)); 590 assertCharEquals((char)0, $opt$noinline$ByteToChar((byte)0)); 591 assertCharEquals((char)65535, $opt$noinline$ByteToChar((byte)-1)); 592 assertCharEquals((char)51, $opt$noinline$ByteToChar((byte)51)); 593 assertCharEquals((char)65485, $opt$noinline$ByteToChar((byte)-51)); 594 assertCharEquals((char)127, $opt$noinline$ByteToChar((byte)127)); // 2^7 - 1 595 assertCharEquals((char)65409, $opt$noinline$ByteToChar((byte)-127)); // -(2^7 - 1) 596 assertCharEquals((char)65408, $opt$noinline$ByteToChar((byte)-128)); // -(2^7) 597 } 598 shortToChar()599 private static void shortToChar() { 600 assertCharEquals((char)1, $opt$noinline$ShortToChar((short)1)); 601 assertCharEquals((char)0, $opt$noinline$ShortToChar((short)0)); 602 assertCharEquals((char)65535, $opt$noinline$ShortToChar((short)-1)); 603 assertCharEquals((char)51, $opt$noinline$ShortToChar((short)51)); 604 assertCharEquals((char)65485, $opt$noinline$ShortToChar((short)-51)); 605 assertCharEquals((char)32767, $opt$noinline$ShortToChar((short)32767)); // 2^15 - 1 606 assertCharEquals((char)32769, $opt$noinline$ShortToChar((short)-32767)); // -(2^15 - 1) 607 assertCharEquals((char)32768, $opt$noinline$ShortToChar((short)-32768)); // -(2^15) 608 } 609 intToChar()610 private static void intToChar() { 611 assertCharEquals((char)1, $opt$noinline$IntToChar(1)); 612 assertCharEquals((char)0, $opt$noinline$IntToChar(0)); 613 assertCharEquals((char)65535, $opt$noinline$IntToChar(-1)); 614 assertCharEquals((char)51, $opt$noinline$IntToChar(51)); 615 assertCharEquals((char)65485, $opt$noinline$IntToChar(-51)); 616 assertCharEquals((char)32767, $opt$noinline$IntToChar(32767)); // 2^15 - 1 617 assertCharEquals((char)32769, $opt$noinline$IntToChar(-32767)); // -(2^15 - 1) 618 assertCharEquals((char)32768, $opt$noinline$IntToChar(32768)); // 2^15 619 assertCharEquals((char)32768, $opt$noinline$IntToChar(-32768)); // -(2^15) 620 assertCharEquals((char)65535, $opt$noinline$IntToChar(65535)); // 2^16 - 1 621 assertCharEquals((char)1, $opt$noinline$IntToChar(-65535)); // -(2^16 - 1) 622 assertCharEquals((char)0, $opt$noinline$IntToChar(65536)); // 2^16 623 assertCharEquals((char)0, $opt$noinline$IntToChar(-65536)); // -(2^16) 624 assertCharEquals((char)65535, $opt$noinline$IntToChar(2147483647)); // 2^31 - 1 625 assertCharEquals((char)0, $opt$noinline$IntToChar(-2147483648)); // -(2^31) 626 } 627 628 // A dummy value to defeat inlining of these routines. 629 static boolean doThrow = false; 630 631 // These methods produce int-to-long Dex instructions. $opt$noinline$ByteToLong(byte a)632 static long $opt$noinline$ByteToLong(byte a) { if (doThrow) throw new Error(); return (long)a; } $opt$noinline$ShortToLong(short a)633 static long $opt$noinline$ShortToLong(short a) { if (doThrow) throw new Error(); return (long)a; } $opt$noinline$IntToLong(int a)634 static long $opt$noinline$IntToLong(int a) { if (doThrow) throw new Error(); return (long)a; } $opt$noinline$CharToLong(int a)635 static long $opt$noinline$CharToLong(int a) { if (doThrow) throw new Error(); return (long)a; } 636 637 // These methods produce int-to-float Dex instructions. $opt$noinline$ByteToFloat(byte a)638 static float $opt$noinline$ByteToFloat(byte a) { if (doThrow) throw new Error(); return (float)a; } $opt$noinline$ShortToFloat(short a)639 static float $opt$noinline$ShortToFloat(short a) { if (doThrow) throw new Error(); return (float)a; } $opt$noinline$IntToFloat(int a)640 static float $opt$noinline$IntToFloat(int a) { if (doThrow) throw new Error(); return (float)a; } $opt$noinline$CharToFloat(char a)641 static float $opt$noinline$CharToFloat(char a) { if (doThrow) throw new Error(); return (float)a; } 642 643 // These methods produce int-to-double Dex instructions. $opt$noinline$ByteToDouble(byte a)644 static double $opt$noinline$ByteToDouble(byte a) { if (doThrow) throw new Error(); return (double)a; } $opt$noinline$ShortToDouble(short a)645 static double $opt$noinline$ShortToDouble(short a) { if (doThrow) throw new Error(); return (double)a; } $opt$noinline$IntToDouble(int a)646 static double $opt$noinline$IntToDouble(int a) { if (doThrow) throw new Error(); return (double)a; } $opt$noinline$CharToDouble(int a)647 static double $opt$noinline$CharToDouble(int a) { if (doThrow) throw new Error(); return (double)a; } 648 649 // These methods produce long-to-int Dex instructions. $opt$noinline$LongToInt(long a)650 static int $opt$noinline$LongToInt(long a) { if (doThrow) throw new Error(); return (int)a; } $opt$noinline$LongLiteralToInt()651 static int $opt$noinline$LongLiteralToInt() { if (doThrow) throw new Error(); return (int)42L; } 652 653 // This method produces a long-to-float Dex instruction. $opt$noinline$LongToFloat(long a)654 static float $opt$noinline$LongToFloat(long a) { if (doThrow) throw new Error(); return (float)a; } 655 656 // This method produces a long-to-double Dex instruction. $opt$noinline$LongToDouble(long a)657 static double $opt$noinline$LongToDouble(long a) { if (doThrow) throw new Error(); return (double)a; } 658 659 // This method produces a float-to-int Dex instruction. $opt$noinline$FloatToInt(float a)660 static int $opt$noinline$FloatToInt(float a) { if (doThrow) throw new Error(); return (int)a; } 661 662 // This method produces a float-to-long Dex instruction. $opt$noinline$FloatToLong(float a)663 static long $opt$noinline$FloatToLong(float a){ if (doThrow) throw new Error(); return (long)a; } 664 665 // This method produces a float-to-double Dex instruction. $opt$noinline$FloatToDouble(float a)666 static double $opt$noinline$FloatToDouble(float a) { if (doThrow) throw new Error(); return (double)a; } 667 668 // This method produces a double-to-int Dex instruction. $opt$noinline$DoubleToInt(double a)669 static int $opt$noinline$DoubleToInt(double a){ if (doThrow) throw new Error(); return (int)a; } 670 671 // This method produces a double-to-long Dex instruction. $opt$noinline$DoubleToLong(double a)672 static long $opt$noinline$DoubleToLong(double a){ if (doThrow) throw new Error(); return (long)a; } 673 674 // This method produces a double-to-float Dex instruction. $opt$noinline$DoubleToFloat(double a)675 static float $opt$noinline$DoubleToFloat(double a) { if (doThrow) throw new Error(); return (float)a; } 676 677 // These methods produce int-to-byte Dex instructions. $opt$noinline$ShortToByte(short a)678 static byte $opt$noinline$ShortToByte(short a) { if (doThrow) throw new Error(); return (byte)a; } $opt$noinline$IntToByte(int a)679 static byte $opt$noinline$IntToByte(int a) { if (doThrow) throw new Error(); return (byte)a; } $opt$noinline$CharToByte(char a)680 static byte $opt$noinline$CharToByte(char a) { if (doThrow) throw new Error(); return (byte)a; } 681 682 // These methods produce int-to-short Dex instructions. $opt$noinline$ByteToShort(byte a)683 static short $opt$noinline$ByteToShort(byte a) { if (doThrow) throw new Error(); return (short)a; } $opt$noinline$IntToShort(int a)684 static short $opt$noinline$IntToShort(int a) { if (doThrow) throw new Error(); return (short)a; } $opt$noinline$CharToShort(char a)685 static short $opt$noinline$CharToShort(char a) { if (doThrow) throw new Error(); return (short)a; } 686 687 // These methods produce int-to-char Dex instructions. $opt$noinline$ByteToChar(byte a)688 static char $opt$noinline$ByteToChar(byte a) { if (doThrow) throw new Error(); return (char)a; } $opt$noinline$ShortToChar(short a)689 static char $opt$noinline$ShortToChar(short a) { if (doThrow) throw new Error(); return (char)a; } $opt$noinline$IntToChar(int a)690 static char $opt$noinline$IntToChar(int a) { if (doThrow) throw new Error(); return (char)a; } 691 } 692