1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 6934604 27 * 28 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox 29 * compiler.eliminateAutobox.TestByteBoxing 30 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox 31 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::dummy 32 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::foo 33 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::foob 34 * compiler.eliminateAutobox.TestByteBoxing 35 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox 36 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::dummy 37 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::foo 38 * -XX:CompileCommand=exclude,compiler.eliminateAutobox.TestByteBoxing::foob 39 * compiler.eliminateAutobox.TestByteBoxing 40 */ 41 42 package compiler.eliminateAutobox; 43 44 public class TestByteBoxing { 45 46 static final Byte ibc = new Byte((byte)1); 47 48 //=============================================== 49 // Non-inlined methods to test deoptimization info 50 static void dummy() { } 51 static byte foo(byte i) { return i; } 52 static Byte foob(byte i) { return Byte.valueOf(i); } 53 54 55 static byte simple(byte i) { 56 Byte ib = new Byte(i); 57 return ib; 58 } 59 60 static byte simpleb(byte i) { 61 Byte ib = Byte.valueOf(i); 62 return ib; 63 } 64 65 static byte simplec() { 66 Byte ib = ibc; 67 return ib; 68 } 69 70 static byte simplef(byte i) { 71 Byte ib = foob(i); 72 return ib; 73 } 74 75 static byte simplep(Byte ib) { 76 return ib; 77 } 78 79 static byte simple2(byte i) { 80 Byte ib1 = new Byte(i); 81 Byte ib2 = new Byte((byte)(i+1)); 82 return (byte)(ib1 + ib2); 83 } 84 85 static byte simpleb2(byte i) { 86 Byte ib1 = Byte.valueOf(i); 87 Byte ib2 = Byte.valueOf((byte)(i+1)); 88 return (byte)(ib1 + ib2); 89 } 90 91 static byte simplem2(byte i) { 92 Byte ib1 = new Byte(i); 93 Byte ib2 = Byte.valueOf((byte)(i+1)); 94 return (byte)(ib1 + ib2); 95 } 96 97 static byte simplep2(byte i, Byte ib1) { 98 Byte ib2 = Byte.valueOf((byte)(i+1)); 99 return (byte)(ib1 + ib2); 100 } 101 102 static byte simplec2(byte i) { 103 Byte ib1 = ibc; 104 Byte ib2 = Byte.valueOf((byte)(i+1)); 105 return (byte)(ib1 + ib2); 106 } 107 108 //=============================================== 109 static byte test(byte i) { 110 Byte ib = new Byte(i); 111 if ((i&1) == 0) 112 ib = (byte)(i+1); 113 return ib; 114 } 115 116 static byte testb(byte i) { 117 Byte ib = i; 118 if ((i&1) == 0) 119 ib = (byte)(i+1); 120 return ib; 121 } 122 123 static byte testm(byte i) { 124 Byte ib = i; 125 if ((i&1) == 0) 126 ib = new Byte((byte)(i+1)); 127 return ib; 128 } 129 130 static byte testp(byte i, Byte ib) { 131 if ((i&1) == 0) 132 ib = new Byte((byte)(i+1)); 133 return ib; 134 } 135 136 static byte testc(byte i) { 137 Byte ib = ibc; 138 if ((i&1) == 0) 139 ib = new Byte((byte)(i+1)); 140 return ib; 141 } 142 143 static byte test2(byte i) { 144 Byte ib1 = new Byte(i); 145 Byte ib2 = new Byte((byte)(i+1)); 146 if ((i&1) == 0) { 147 ib1 = new Byte((byte)(i+1)); 148 ib2 = new Byte((byte)(i+2)); 149 } 150 return (byte)(ib1+ib2); 151 } 152 153 static byte testb2(byte i) { 154 Byte ib1 = i; 155 Byte ib2 = (byte)(i+1); 156 if ((i&1) == 0) { 157 ib1 = (byte)(i+1); 158 ib2 = (byte)(i+2); 159 } 160 return (byte)(ib1 + ib2); 161 } 162 163 static byte testm2(byte i) { 164 Byte ib1 = new Byte(i); 165 Byte ib2 = (byte)(i+1); 166 if ((i&1) == 0) { 167 ib1 = new Byte((byte)(i+1)); 168 ib2 = (byte)(i+2); 169 } 170 return (byte)(ib1 + ib2); 171 } 172 173 static byte testp2(byte i, Byte ib1) { 174 Byte ib2 = (byte)(i+1); 175 if ((i&1) == 0) { 176 ib1 = new Byte((byte)(i+1)); 177 ib2 = (byte)(i+2); 178 } 179 return (byte)(ib1 + ib2); 180 } 181 182 static byte testc2(byte i) { 183 Byte ib1 = ibc; 184 Byte ib2 = (byte)(i+1); 185 if ((i&1) == 0) { 186 ib1 = (byte)(ibc+1); 187 ib2 = (byte)(i+2); 188 } 189 return (byte)(ib1 + ib2); 190 } 191 192 //=============================================== 193 static byte sum(byte[] a) { 194 byte result = 1; 195 for (Byte i : a) 196 result += i; 197 return result; 198 } 199 200 static byte sumb(byte[] a) { 201 Byte result = 1; 202 for (Byte i : a) 203 result = (byte)(result + i); 204 return result; 205 } 206 207 static byte sumc(byte[] a) { 208 Byte result = ibc; 209 for (Byte i : a) 210 result = (byte)(result + i); 211 return result; 212 } 213 214 static byte sumf(byte[] a) { 215 Byte result = foob((byte)1); 216 for (Byte i : a) 217 result = (byte)(result + i); 218 return result; 219 } 220 221 static byte sump(byte[] a, Byte result) { 222 for (Byte i : a) 223 result = (byte)(result + i); 224 return result; 225 } 226 227 static byte sum2(byte[] a) { 228 byte result1 = 1; 229 byte result2 = 1; 230 for (Byte i : a) { 231 result1 += i; 232 result2 += i + 1; 233 } 234 return (byte)(result1 + result2); 235 } 236 237 static byte sumb2(byte[] a) { 238 Byte result1 = 1; 239 Byte result2 = 1; 240 for (Byte i : a) { 241 result1 = (byte)(result1 + i); 242 result2 = (byte)(result2 + i + 1); 243 } 244 return (byte)(result1 + result2); 245 } 246 247 static byte summ2(byte[] a) { 248 Byte result1 = 1; 249 Byte result2 = new Byte((byte)1); 250 for (Byte i : a) { 251 result1 = (byte)(result1 + i); 252 result2 = (byte)(result2 + new Byte((byte)(i + 1))); 253 } 254 return (byte)(result1 + result2); 255 } 256 257 static byte sump2(byte[] a, Byte result2) { 258 Byte result1 = 1; 259 for (Byte i : a) { 260 result1 = (byte)(result1 + i); 261 result2 = (byte)(result2 + i + 1); 262 } 263 return (byte)(result1 + result2); 264 } 265 266 static byte sumc2(byte[] a) { 267 Byte result1 = 1; 268 Byte result2 = ibc; 269 for (Byte i : a) { 270 result1 = (byte)(result1 + i); 271 result2 = (byte)(result2 + i + ibc); 272 } 273 return (byte)(result1 + result2); 274 } 275 276 //=============================================== 277 static byte remi_sum() { 278 Byte j = new Byte((byte)1); 279 for (int i = 0; i< 1000; i++) { 280 j = new Byte((byte)(j + 1)); 281 } 282 return j; 283 } 284 285 static byte remi_sumb() { 286 Byte j = Byte.valueOf((byte)1); 287 for (int i = 0; i< 1000; i++) { 288 j = (byte)(j + 1); 289 } 290 return j; 291 } 292 293 static byte remi_sumf() { 294 Byte j = foob((byte)1); 295 for (int i = 0; i< 1000; i++) { 296 j = (byte)(j + 1); 297 } 298 return j; 299 } 300 301 static byte remi_sump(Byte j) { 302 for (int i = 0; i< 1000; i++) { 303 j = new Byte((byte)(j + 1)); 304 } 305 return j; 306 } 307 308 static byte remi_sumc() { 309 Byte j = ibc; 310 for (int i = 0; i< 1000; i++) { 311 j = (byte)(j + ibc); 312 } 313 return j; 314 } 315 316 static byte remi_sum2() { 317 Byte j1 = new Byte((byte)1); 318 Byte j2 = new Byte((byte)1); 319 for (int i = 0; i< 1000; i++) { 320 j1 = new Byte((byte)(j1 + 1)); 321 j2 = new Byte((byte)(j2 + 2)); 322 } 323 return (byte)(j1 + j2); 324 } 325 326 static byte remi_sumb2() { 327 Byte j1 = Byte.valueOf((byte)1); 328 Byte j2 = Byte.valueOf((byte)1); 329 for (int i = 0; i< 1000; i++) { 330 j1 = (byte)(j1 + 1); 331 j2 = (byte)(j2 + 2); 332 } 333 return (byte)(j1 + j2); 334 } 335 336 static byte remi_summ2() { 337 Byte j1 = new Byte((byte)1); 338 Byte j2 = Byte.valueOf((byte)1); 339 for (int i = 0; i< 1000; i++) { 340 j1 = new Byte((byte)(j1 + 1)); 341 j2 = (byte)(j2 + 2); 342 } 343 return (byte)(j1 + j2); 344 } 345 346 static byte remi_sump2(Byte j1) { 347 Byte j2 = Byte.valueOf((byte)1); 348 for (int i = 0; i< 1000; i++) { 349 j1 = new Byte((byte)(j1 + 1)); 350 j2 = (byte)(j2 + 2); 351 } 352 return (byte)(j1 + j2); 353 } 354 355 static byte remi_sumc2() { 356 Byte j1 = ibc; 357 Byte j2 = Byte.valueOf((byte)1); 358 for (int i = 0; i< 1000; i++) { 359 j1 = (byte)(j1 + ibc); 360 j2 = (byte)(j2 + 2); 361 } 362 return (byte)(j1 + j2); 363 } 364 365 366 //=============================================== 367 // Safepointa and debug info for deoptimization 368 static byte simple_deop(byte i) { 369 Byte ib = new Byte(foo(i)); 370 dummy(); 371 return ib; 372 } 373 374 static byte simpleb_deop(byte i) { 375 Byte ib = Byte.valueOf(foo(i)); 376 dummy(); 377 return ib; 378 } 379 380 static byte simplef_deop(byte i) { 381 Byte ib = foob(i); 382 dummy(); 383 return ib; 384 } 385 386 static byte simplep_deop(Byte ib) { 387 dummy(); 388 return ib; 389 } 390 391 static byte simplec_deop(byte i) { 392 Byte ib = ibc; 393 dummy(); 394 return ib; 395 } 396 397 static byte test_deop(byte i) { 398 Byte ib = new Byte(foo(i)); 399 if ((i&1) == 0) 400 ib = foo((byte)(i+1)); 401 dummy(); 402 return ib; 403 } 404 405 static byte testb_deop(byte i) { 406 Byte ib = foo(i); 407 if ((i&1) == 0) 408 ib = foo((byte)(i+1)); 409 dummy(); 410 return ib; 411 } 412 413 static byte testf_deop(byte i) { 414 Byte ib = foob(i); 415 if ((i&1) == 0) 416 ib = foo((byte)(i+1)); 417 dummy(); 418 return ib; 419 } 420 421 static byte testp_deop(byte i, Byte ib) { 422 if ((i&1) == 0) 423 ib = foo((byte)(i+1)); 424 dummy(); 425 return ib; 426 } 427 428 static byte testc_deop(byte i) { 429 Byte ib = ibc; 430 if ((i&1) == 0) 431 ib = foo((byte)(i+1)); 432 dummy(); 433 return ib; 434 } 435 436 static byte sum_deop(byte[] a) { 437 byte result = 1; 438 for (Byte i : a) 439 result += foo(i); 440 dummy(); 441 return result; 442 } 443 444 static byte sumb_deop(byte[] a) { 445 Byte result = 1; 446 for (Byte i : a) 447 result = (byte)(result + foo(i)); 448 dummy(); 449 return result; 450 } 451 452 static byte sumf_deop(byte[] a) { 453 Byte result = 1; 454 for (Byte i : a) 455 result = (byte)(result + foob(i)); 456 dummy(); 457 return result; 458 } 459 460 static byte sump_deop(byte[] a, Byte result) { 461 for (Byte i : a) 462 result = (byte)(result + foob(i)); 463 dummy(); 464 return result; 465 } 466 467 static byte sumc_deop(byte[] a) { 468 Byte result = ibc; 469 for (Byte i : a) 470 result = (byte)(result + foo(i)); 471 dummy(); 472 return result; 473 } 474 475 static byte remi_sum_deop() { 476 Byte j = new Byte(foo((byte)1)); 477 for (int i = 0; i< 1000; i++) { 478 j = new Byte(foo((byte)(j + 1))); 479 } 480 dummy(); 481 return j; 482 } 483 484 static byte remi_sumb_deop() { 485 Byte j = Byte.valueOf(foo((byte)1)); 486 for (int i = 0; i< 1000; i++) { 487 j = foo((byte)(j + 1)); 488 } 489 dummy(); 490 return j; 491 } 492 493 static byte remi_sumf_deop() { 494 Byte j = foob((byte)1); 495 for (int i = 0; i< 1000; i++) { 496 j = foo((byte)(j + 1)); 497 } 498 dummy(); 499 return j; 500 } 501 502 static byte remi_sump_deop(Byte j) { 503 for (int i = 0; i< 1000; i++) { 504 j = foo((byte)(j + 1)); 505 } 506 dummy(); 507 return j; 508 } 509 510 static byte remi_sumc_deop() { 511 Byte j = ibc; 512 for (int i = 0; i< 1000; i++) { 513 j = foo((byte)(j + 1)); 514 } 515 dummy(); 516 return j; 517 } 518 519 //=============================================== 520 // Conditional increment 521 static byte remi_sum_cond() { 522 Byte j = new Byte((byte)1); 523 for (int i = 0; i< 1000; i++) { 524 if ((i&1) == 0) { 525 j = new Byte((byte)(j + 1)); 526 } 527 } 528 return j; 529 } 530 531 static byte remi_sumb_cond() { 532 Byte j = Byte.valueOf((byte)1); 533 for (int i = 0; i< 1000; i++) { 534 if ((i&1) == 0) { 535 j = (byte)(j + 1); 536 } 537 } 538 return j; 539 } 540 541 static byte remi_sumf_cond() { 542 Byte j = foob((byte)1); 543 for (int i = 0; i< 1000; i++) { 544 if ((i&1) == 0) { 545 j = (byte)(j + 1); 546 } 547 } 548 return j; 549 } 550 551 static byte remi_sump_cond(Byte j) { 552 for (int i = 0; i< 1000; i++) { 553 if ((i&1) == 0) { 554 j = (byte)(j + 1); 555 } 556 } 557 return j; 558 } 559 560 static byte remi_sumc_cond() { 561 Byte j = ibc; 562 for (int i = 0; i< 1000; i++) { 563 if ((i&1) == 0) { 564 j = (byte)(j + ibc); 565 } 566 } 567 return j; 568 } 569 570 static byte remi_sum2_cond() { 571 Byte j1 = new Byte((byte)1); 572 Byte j2 = new Byte((byte)1); 573 for (int i = 0; i< 1000; i++) { 574 if ((i&1) == 0) { 575 j1 = new Byte((byte)(j1 + 1)); 576 } else { 577 j2 = new Byte((byte)(j2 + 2)); 578 } 579 } 580 return (byte)(j1 + j2); 581 } 582 583 static byte remi_sumb2_cond() { 584 Byte j1 = Byte.valueOf((byte)1); 585 Byte j2 = Byte.valueOf((byte)1); 586 for (int i = 0; i< 1000; i++) { 587 if ((i&1) == 0) { 588 j1 = (byte)(j1 + 1); 589 } else { 590 j2 = (byte)(j2 + 2); 591 } 592 } 593 return (byte)(j1 + j2); 594 } 595 596 static byte remi_summ2_cond() { 597 Byte j1 = new Byte((byte)1); 598 Byte j2 = Byte.valueOf((byte)1); 599 for (int i = 0; i< 1000; i++) { 600 if ((i&1) == 0) { 601 j1 = new Byte((byte)(j1 + 1)); 602 } else { 603 j2 = (byte)(j2 + 2); 604 } 605 } 606 return (byte)(j1 + j2); 607 } 608 609 static byte remi_sump2_cond(Byte j1) { 610 Byte j2 = Byte.valueOf((byte)1); 611 for (int i = 0; i< 1000; i++) { 612 if ((i&1) == 0) { 613 j1 = new Byte((byte)(j1 + 1)); 614 } else { 615 j2 = (byte)(j2 + 2); 616 } 617 } 618 return (byte)(j1 + j2); 619 } 620 621 static byte remi_sumc2_cond() { 622 Byte j1 = ibc; 623 Byte j2 = Byte.valueOf((byte)1); 624 for (int i = 0; i< 1000; i++) { 625 if ((i&1) == 0) { 626 j1 = (byte)(j1 + ibc); 627 } else { 628 j2 = (byte)(j2 + 2); 629 } 630 } 631 return (byte)(j1 + j2); 632 } 633 634 635 public static void main(String[] args) { 636 final int ntests = 70; 637 638 String[] test_name = new String[] { 639 "simple", "simpleb", "simplec", "simplef", "simplep", 640 "simple2", "simpleb2", "simplec2", "simplem2", "simplep2", 641 "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop", 642 "test", "testb", "testc", "testm", "testp", 643 "test2", "testb2", "testc2", "testm2", "testp2", 644 "test_deop", "testb_deop", "testc_deop", "testf_deop", "testp_deop", 645 "sum", "sumb", "sumc", "sumf", "sump", 646 "sum2", "sumb2", "sumc2", "summ2", "sump2", 647 "sum_deop", "sumb_deop", "sumc_deop", "sumf_deop", "sump_deop", 648 "remi_sum", "remi_sumb", "remi_sumc", "remi_sumf", "remi_sump", 649 "remi_sum2", "remi_sumb2", "remi_sumc2", "remi_summ2", "remi_sump2", 650 "remi_sum_deop", "remi_sumb_deop", "remi_sumc_deop", "remi_sumf_deop", "remi_sump_deop", 651 "remi_sum_cond", "remi_sumb_cond", "remi_sumc_cond", "remi_sumf_cond", "remi_sump_cond", 652 "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond" 653 }; 654 655 final int[] val = new int[] { 656 -5488, -5488, 12000, -5488, -5488, 657 1024, 1024, -5552, 1024, 1024, 658 -5488, -5488, 12000, -5488, -5488, 659 512, 512, 6256, 512, 512, 660 13024, 13024, -5584, 13024, 13024, 661 512, 512, 6256, 512, 512, 662 45, 45, 45, 45, 45, 663 66, 66, 66, 66, 66, 664 45, 45, 45, 45, 45, 665 -23, -23, -23, -23, -23, 666 -70, -70, -70, -70, -70, 667 -23, -23, -23, -23, -23, 668 -11, -11, -11, -11, -11, 669 -34, -34, -34, -34, -34 670 }; 671 672 int[] res = new int[ntests]; 673 for (int i = 0; i < ntests; i++) { 674 res[i] = 0; 675 } 676 677 678 for (int i = 0; i < 12000; i++) { 679 res[0] += simple((byte)i); 680 res[1] += simpleb((byte)i); 681 res[2] += simplec(); 682 res[3] += simplef((byte)i); 683 res[4] += simplep((byte)i); 684 685 res[5] += simple2((byte)i); 686 res[6] += simpleb2((byte)i); 687 res[7] += simplec2((byte)i); 688 res[8] += simplem2((byte)i); 689 res[9] += simplep2((byte)i, (byte)i); 690 691 res[10] += simple_deop((byte)i); 692 res[11] += simpleb_deop((byte)i); 693 res[12] += simplec_deop((byte)i); 694 res[13] += simplef_deop((byte)i); 695 res[14] += simplep_deop((byte)i); 696 697 res[15] += test((byte)i); 698 res[16] += testb((byte)i); 699 res[17] += testc((byte)i); 700 res[18] += testm((byte)i); 701 res[19] += testp((byte)i, (byte)i); 702 703 res[20] += test2((byte)i); 704 res[21] += testb2((byte)i); 705 res[22] += testc2((byte)i); 706 res[23] += testm2((byte)i); 707 res[24] += testp2((byte)i, (byte)i); 708 709 res[25] += test_deop((byte)i); 710 res[26] += testb_deop((byte)i); 711 res[27] += testc_deop((byte)i); 712 res[28] += testf_deop((byte)i); 713 res[29] += testp_deop((byte)i, (byte)i); 714 } 715 716 byte[] ia = new byte[1000]; 717 for (int i = 0; i < 1000; i++) { 718 ia[i] = (byte)i; 719 } 720 721 for (int i = 0; i < 100; i++) { 722 res[30] = sum(ia); 723 res[31] = sumb(ia); 724 res[32] = sumc(ia); 725 res[33] = sumf(ia); 726 res[34] = sump(ia, (byte)1); 727 728 res[35] = sum2(ia); 729 res[36] = sumb2(ia); 730 res[37] = sumc2(ia); 731 res[38] = summ2(ia); 732 res[39] = sump2(ia, (byte)1); 733 734 res[40] = sum_deop(ia); 735 res[41] = sumb_deop(ia); 736 res[42] = sumc_deop(ia); 737 res[43] = sumf_deop(ia); 738 res[44] = sump_deop(ia, (byte)1); 739 740 res[45] = remi_sum(); 741 res[46] = remi_sumb(); 742 res[47] = remi_sumc(); 743 res[48] = remi_sumf(); 744 res[49] = remi_sump((byte)1); 745 746 res[50] = remi_sum2(); 747 res[51] = remi_sumb2(); 748 res[52] = remi_sumc2(); 749 res[53] = remi_summ2(); 750 res[54] = remi_sump2((byte)1); 751 752 res[55] = remi_sum_deop(); 753 res[56] = remi_sumb_deop(); 754 res[57] = remi_sumc_deop(); 755 res[58] = remi_sumf_deop(); 756 res[59] = remi_sump_deop((byte)1); 757 758 res[60] = remi_sum_cond(); 759 res[61] = remi_sumb_cond(); 760 res[62] = remi_sumc_cond(); 761 res[63] = remi_sumf_cond(); 762 res[64] = remi_sump_cond((byte)1); 763 764 res[65] = remi_sum2_cond(); 765 res[66] = remi_sumb2_cond(); 766 res[67] = remi_sumc2_cond(); 767 res[68] = remi_summ2_cond(); 768 res[69] = remi_sump2_cond((byte)1); 769 } 770 771 int failed = 0; 772 for (int i = 0; i < ntests; i++) { 773 if (res[i] != val[i]) { 774 System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]); 775 failed++; 776 } 777 } 778 if (failed > 0) { 779 System.err.println("Failed " + failed + " tests."); 780 throw new InternalError(); 781 } else { 782 System.out.println("Passed."); 783 } 784 } 785 }