test/compiler/6934604/TestShortBoxing.java

changeset 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/compiler/6934604/TestShortBoxing.java	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,777 @@
     1.4 +/*
     1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * @test
    1.29 + * @bug 6934604
    1.30 + * @summary enable parts of EliminateAutoBox by default
    1.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestShortBoxing
    1.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
    1.33 + * -XX:CompileCommand=exclude,TestShortBoxing.dummy -XX:CompileCommand=exclude,TestShortBoxing.foo -XX:CompileCommand=exclude,TestShortBoxing.foob TestShortBoxing
    1.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
    1.35 + * -XX:CompileCommand=exclude,TestShortBoxing.dummy -XX:CompileCommand=exclude,TestShortBoxing.foo -XX:CompileCommand=exclude,TestShortBoxing.foob TestShortBoxing
    1.36 + *
    1.37 + */
    1.38 +
    1.39 +public class TestShortBoxing {
    1.40 +
    1.41 +  static final Short ibc = new Short((short)1);
    1.42 +
    1.43 +  //===============================================
    1.44 +  // Non-inlined methods to test deoptimization info
    1.45 +  static void dummy()      { }
    1.46 +  static short foo(short i)  { return i; }
    1.47 +  static Short foob(short i) { return Short.valueOf(i); }
    1.48 +
    1.49 +
    1.50 +  static short simple(short i) {
    1.51 +    Short ib = new Short(i);
    1.52 +    return ib;
    1.53 +  }
    1.54 +
    1.55 +  static short simpleb(short i) {
    1.56 +    Short ib = Short.valueOf(i);
    1.57 +    return ib;
    1.58 +  }
    1.59 +
    1.60 +  static short simplec() {
    1.61 +    Short ib = ibc;
    1.62 +    return ib;
    1.63 +  }
    1.64 +
    1.65 +  static short simplef(short i) {
    1.66 +    Short ib = foob(i);
    1.67 +    return ib;
    1.68 +  }
    1.69 +
    1.70 +  static short simplep(Short ib) {
    1.71 +    return ib;
    1.72 +  }
    1.73 +
    1.74 +  static short simple2(short i) {
    1.75 +    Short ib1 = new Short(i);
    1.76 +    Short ib2 = new Short((short)(i+1));
    1.77 +    return (short)(ib1 + ib2);
    1.78 +  }
    1.79 +
    1.80 +  static short simpleb2(short i) {
    1.81 +    Short ib1 = Short.valueOf(i);
    1.82 +    Short ib2 = Short.valueOf((short)(i+1));
    1.83 +    return (short)(ib1 + ib2);
    1.84 +  }
    1.85 +
    1.86 +  static short simplem2(short i) {
    1.87 +    Short ib1 = new Short(i);
    1.88 +    Short ib2 = Short.valueOf((short)(i+1));
    1.89 +    return (short)(ib1 + ib2);
    1.90 +  }
    1.91 +
    1.92 +  static short simplep2(short i, Short ib1) {
    1.93 +    Short ib2 = Short.valueOf((short)(i+1));
    1.94 +    return (short)(ib1 + ib2);
    1.95 +  }
    1.96 +
    1.97 +  static short simplec2(short i) {
    1.98 +    Short ib1 = ibc;
    1.99 +    Short ib2 = Short.valueOf((short)(i+1));
   1.100 +    return (short)(ib1 + ib2);
   1.101 +  }
   1.102 +
   1.103 +  //===============================================
   1.104 +  static short test(short i) {
   1.105 +    Short ib = new Short(i);
   1.106 +    if ((i&1) == 0)
   1.107 +      ib = (short)(i+1);
   1.108 +    return ib;
   1.109 +  }
   1.110 +
   1.111 +  static short testb(short i) {
   1.112 +    Short ib = i;
   1.113 +    if ((i&1) == 0)
   1.114 +      ib = (short)(i+1);
   1.115 +    return ib;
   1.116 +  }
   1.117 +
   1.118 +  static short testm(short i) {
   1.119 +    Short ib = i;
   1.120 +    if ((i&1) == 0)
   1.121 +      ib = new Short((short)(i+1));
   1.122 +    return ib;
   1.123 +  }
   1.124 +
   1.125 +  static short testp(short i, Short ib) {
   1.126 +    if ((i&1) == 0)
   1.127 +      ib = new Short((short)(i+1));
   1.128 +    return ib;
   1.129 +  }
   1.130 +
   1.131 +  static short testc(short i) {
   1.132 +    Short ib = ibc;
   1.133 +    if ((i&1) == 0)
   1.134 +      ib = new Short((short)(i+1));
   1.135 +    return ib;
   1.136 +  }
   1.137 +
   1.138 +  static short test2(short i) {
   1.139 +    Short ib1 = new Short(i);
   1.140 +    Short ib2 = new Short((short)(i+1));
   1.141 +    if ((i&1) == 0) {
   1.142 +      ib1 = new Short((short)(i+1));
   1.143 +      ib2 = new Short((short)(i+2));
   1.144 +    }
   1.145 +    return (short)(ib1+ib2);
   1.146 +  }
   1.147 +
   1.148 +  static short testb2(short i) {
   1.149 +    Short ib1 = i;
   1.150 +    Short ib2 = (short)(i+1);
   1.151 +    if ((i&1) == 0) {
   1.152 +      ib1 = (short)(i+1);
   1.153 +      ib2 = (short)(i+2);
   1.154 +    }
   1.155 +    return (short)(ib1 + ib2);
   1.156 +  }
   1.157 +
   1.158 +  static short testm2(short i) {
   1.159 +    Short ib1 = new Short(i);
   1.160 +    Short ib2 = (short)(i+1);
   1.161 +    if ((i&1) == 0) {
   1.162 +      ib1 = new Short((short)(i+1));
   1.163 +      ib2 = (short)(i+2);
   1.164 +    }
   1.165 +    return (short)(ib1 + ib2);
   1.166 +  }
   1.167 +
   1.168 +  static short testp2(short i, Short ib1) {
   1.169 +    Short ib2 = (short)(i+1);
   1.170 +    if ((i&1) == 0) {
   1.171 +      ib1 = new Short((short)(i+1));
   1.172 +      ib2 = (short)(i+2);
   1.173 +    }
   1.174 +    return (short)(ib1 + ib2);
   1.175 +  }
   1.176 +
   1.177 +  static short testc2(short i) {
   1.178 +    Short ib1 = ibc;
   1.179 +    Short ib2 = (short)(i+1);
   1.180 +    if ((i&1) == 0) {
   1.181 +      ib1 = (short)(ibc+1);
   1.182 +      ib2 = (short)(i+2);
   1.183 +    }
   1.184 +    return (short)(ib1 + ib2);
   1.185 +  }
   1.186 +
   1.187 +  //===============================================
   1.188 +  static short sum(short[] a) {
   1.189 +    short result = 1;
   1.190 +    for (Short i : a)
   1.191 +        result += i;
   1.192 +    return result;
   1.193 +  }
   1.194 +
   1.195 +  static short sumb(short[] a) {
   1.196 +    Short result = 1;
   1.197 +    for (Short i : a)
   1.198 +        result = (short)(result + i);
   1.199 +    return result;
   1.200 +  }
   1.201 +
   1.202 +  static short sumc(short[] a) {
   1.203 +    Short result = ibc;
   1.204 +    for (Short i : a)
   1.205 +        result = (short)(result + i);
   1.206 +    return result;
   1.207 +  }
   1.208 +
   1.209 +  static short sumf(short[] a) {
   1.210 +    Short result = foob((short)1);
   1.211 +    for (Short i : a)
   1.212 +        result = (short)(result + i);
   1.213 +    return result;
   1.214 +  }
   1.215 +
   1.216 +  static short sump(short[] a, Short result) {
   1.217 +    for (Short i : a)
   1.218 +        result = (short)(result + i);
   1.219 +    return result;
   1.220 +  }
   1.221 +
   1.222 +  static short sum2(short[] a) {
   1.223 +    short result1 = 1;
   1.224 +    short result2 = 1;
   1.225 +    for (Short i : a) {
   1.226 +        result1 += i;
   1.227 +        result2 += i + 1;
   1.228 +    }
   1.229 +    return (short)(result1 + result2);
   1.230 +  }
   1.231 +
   1.232 +  static short sumb2(short[] a) {
   1.233 +    Short result1 = 1;
   1.234 +    Short result2 = 1;
   1.235 +    for (Short i : a) {
   1.236 +        result1 = (short)(result1 + i);
   1.237 +        result2 = (short)(result2 + i + 1);
   1.238 +    }
   1.239 +    return (short)(result1 + result2);
   1.240 +  }
   1.241 +
   1.242 +  static short summ2(short[] a) {
   1.243 +    Short result1 = 1;
   1.244 +    Short result2 = new Short((short)1);
   1.245 +    for (Short i : a) {
   1.246 +        result1 = (short)(result1 + i);
   1.247 +        result2 = (short)(result2 + new Short((short)(i + 1)));
   1.248 +    }
   1.249 +    return (short)(result1 + result2);
   1.250 +  }
   1.251 +
   1.252 +  static short sump2(short[] a, Short result2) {
   1.253 +    Short result1 = 1;
   1.254 +    for (Short i : a) {
   1.255 +        result1 = (short)(result1 + i);
   1.256 +        result2 = (short)(result2 + i + 1);
   1.257 +    }
   1.258 +    return (short)(result1 + result2);
   1.259 +  }
   1.260 +
   1.261 +  static short sumc2(short[] a) {
   1.262 +    Short result1 = 1;
   1.263 +    Short result2 = ibc;
   1.264 +    for (Short i : a) {
   1.265 +        result1 = (short)(result1 + i);
   1.266 +        result2 = (short)(result2 + i + ibc);
   1.267 +    }
   1.268 +    return (short)(result1 + result2);
   1.269 +  }
   1.270 +
   1.271 +  //===============================================
   1.272 +  static short remi_sum() {
   1.273 +    Short j = new Short((short)1);
   1.274 +    for (int i = 0; i< 1000; i++) {
   1.275 +      j = new Short((short)(j + 1));
   1.276 +    }
   1.277 +    return j;
   1.278 +  }
   1.279 +
   1.280 +  static short remi_sumb() {
   1.281 +    Short j = Short.valueOf((short)1);
   1.282 +    for (int i = 0; i< 1000; i++) {
   1.283 +      j = (short)(j + 1);
   1.284 +    }
   1.285 +    return j;
   1.286 +  }
   1.287 +
   1.288 +  static short remi_sumf() {
   1.289 +    Short j = foob((short)1);
   1.290 +    for (int i = 0; i< 1000; i++) {
   1.291 +      j = (short)(j + 1);
   1.292 +    }
   1.293 +    return j;
   1.294 +  }
   1.295 +
   1.296 +  static short remi_sump(Short j) {
   1.297 +    for (int i = 0; i< 1000; i++) {
   1.298 +      j = new Short((short)(j + 1));
   1.299 +    }
   1.300 +    return j;
   1.301 +  }
   1.302 +
   1.303 +  static short remi_sumc() {
   1.304 +    Short j = ibc;
   1.305 +    for (int i = 0; i< 1000; i++) {
   1.306 +      j = (short)(j + ibc);
   1.307 +    }
   1.308 +    return j;
   1.309 +  }
   1.310 +
   1.311 +  static short remi_sum2() {
   1.312 +    Short j1 = new Short((short)1);
   1.313 +    Short j2 = new Short((short)1);
   1.314 +    for (int i = 0; i< 1000; i++) {
   1.315 +      j1 = new Short((short)(j1 + 1));
   1.316 +      j2 = new Short((short)(j2 + 2));
   1.317 +    }
   1.318 +    return (short)(j1 + j2);
   1.319 +  }
   1.320 +
   1.321 +  static short remi_sumb2() {
   1.322 +    Short j1 = Short.valueOf((short)1);
   1.323 +    Short j2 = Short.valueOf((short)1);
   1.324 +    for (int i = 0; i< 1000; i++) {
   1.325 +      j1 = (short)(j1 + 1);
   1.326 +      j2 = (short)(j2 + 2);
   1.327 +    }
   1.328 +    return (short)(j1 + j2);
   1.329 +  }
   1.330 +
   1.331 +  static short remi_summ2() {
   1.332 +    Short j1 = new Short((short)1);
   1.333 +    Short j2 = Short.valueOf((short)1);
   1.334 +    for (int i = 0; i< 1000; i++) {
   1.335 +      j1 = new Short((short)(j1 + 1));
   1.336 +      j2 = (short)(j2 + 2);
   1.337 +    }
   1.338 +    return (short)(j1 + j2);
   1.339 +  }
   1.340 +
   1.341 +  static short remi_sump2(Short j1) {
   1.342 +    Short j2 = Short.valueOf((short)1);
   1.343 +    for (int i = 0; i< 1000; i++) {
   1.344 +      j1 = new Short((short)(j1 + 1));
   1.345 +      j2 = (short)(j2 + 2);
   1.346 +    }
   1.347 +    return (short)(j1 + j2);
   1.348 +  }
   1.349 +
   1.350 +  static short remi_sumc2() {
   1.351 +    Short j1 = ibc;
   1.352 +    Short j2 = Short.valueOf((short)1);
   1.353 +    for (int i = 0; i< 1000; i++) {
   1.354 +      j1 = (short)(j1 + ibc);
   1.355 +      j2 = (short)(j2 + 2);
   1.356 +    }
   1.357 +    return (short)(j1 + j2);
   1.358 +  }
   1.359 +
   1.360 +
   1.361 +  //===============================================
   1.362 +  // Safepointa and debug info for deoptimization
   1.363 +  static short simple_deop(short i) {
   1.364 +    Short ib = new Short(foo(i));
   1.365 +    dummy();
   1.366 +    return ib;
   1.367 +  }
   1.368 +
   1.369 +  static short simpleb_deop(short i) {
   1.370 +    Short ib = Short.valueOf(foo(i));
   1.371 +    dummy();
   1.372 +    return ib;
   1.373 +  }
   1.374 +
   1.375 +  static short simplef_deop(short i) {
   1.376 +    Short ib = foob(i);
   1.377 +    dummy();
   1.378 +    return ib;
   1.379 +  }
   1.380 +
   1.381 +  static short simplep_deop(Short ib) {
   1.382 +    dummy();
   1.383 +    return ib;
   1.384 +  }
   1.385 +
   1.386 +  static short simplec_deop(short i) {
   1.387 +    Short ib = ibc;
   1.388 +    dummy();
   1.389 +    return ib;
   1.390 +  }
   1.391 +
   1.392 +  static short test_deop(short i) {
   1.393 +    Short ib = new Short(foo(i));
   1.394 +    if ((i&1) == 0)
   1.395 +      ib = foo((short)(i+1));
   1.396 +    dummy();
   1.397 +    return ib;
   1.398 +  }
   1.399 +
   1.400 +  static short testb_deop(short i) {
   1.401 +    Short ib = foo(i);
   1.402 +    if ((i&1) == 0)
   1.403 +      ib = foo((short)(i+1));
   1.404 +    dummy();
   1.405 +    return ib;
   1.406 +  }
   1.407 +
   1.408 +  static short testf_deop(short i) {
   1.409 +    Short ib = foob(i);
   1.410 +    if ((i&1) == 0)
   1.411 +      ib = foo((short)(i+1));
   1.412 +    dummy();
   1.413 +    return ib;
   1.414 +  }
   1.415 +
   1.416 +  static short testp_deop(short i, Short ib) {
   1.417 +    if ((i&1) == 0)
   1.418 +      ib = foo((short)(i+1));
   1.419 +    dummy();
   1.420 +    return ib;
   1.421 +  }
   1.422 +
   1.423 +  static short testc_deop(short i) {
   1.424 +    Short ib = ibc;
   1.425 +    if ((i&1) == 0)
   1.426 +      ib = foo((short)(i+1));
   1.427 +    dummy();
   1.428 +    return ib;
   1.429 +  }
   1.430 +
   1.431 +  static short sum_deop(short[] a) {
   1.432 +    short result = 1;
   1.433 +    for (Short i : a)
   1.434 +        result += foo(i);
   1.435 +    dummy();
   1.436 +    return result;
   1.437 +  }
   1.438 +
   1.439 +  static short sumb_deop(short[] a) {
   1.440 +    Short result = 1;
   1.441 +    for (Short i : a)
   1.442 +        result = (short)(result + foo(i));
   1.443 +    dummy();
   1.444 +    return result;
   1.445 +  }
   1.446 +
   1.447 +  static short sumf_deop(short[] a) {
   1.448 +    Short result = 1;
   1.449 +    for (Short i : a)
   1.450 +        result = (short)(result + foob(i));
   1.451 +    dummy();
   1.452 +    return result;
   1.453 +  }
   1.454 +
   1.455 +  static short sump_deop(short[] a, Short result) {
   1.456 +    for (Short i : a)
   1.457 +        result = (short)(result + foob(i));
   1.458 +    dummy();
   1.459 +    return result;
   1.460 +  }
   1.461 +
   1.462 +  static short sumc_deop(short[] a) {
   1.463 +    Short result = ibc;
   1.464 +    for (Short i : a)
   1.465 +        result = (short)(result + foo(i));
   1.466 +    dummy();
   1.467 +    return result;
   1.468 +  }
   1.469 +
   1.470 +  static short remi_sum_deop() {
   1.471 +    Short j = new Short(foo((short)1));
   1.472 +    for (int i = 0; i< 1000; i++) {
   1.473 +      j = new Short(foo((short)(j + 1)));
   1.474 +    }
   1.475 +    dummy();
   1.476 +    return j;
   1.477 +  }
   1.478 +
   1.479 +  static short remi_sumb_deop() {
   1.480 +    Short j = Short.valueOf(foo((short)1));
   1.481 +    for (int i = 0; i< 1000; i++) {
   1.482 +      j = foo((short)(j + 1));
   1.483 +    }
   1.484 +    dummy();
   1.485 +    return j;
   1.486 +  }
   1.487 +
   1.488 +  static short remi_sumf_deop() {
   1.489 +    Short j = foob((short)1);
   1.490 +    for (int i = 0; i< 1000; i++) {
   1.491 +      j = foo((short)(j + 1));
   1.492 +    }
   1.493 +    dummy();
   1.494 +    return j;
   1.495 +  }
   1.496 +
   1.497 +  static short remi_sump_deop(Short j) {
   1.498 +    for (int i = 0; i< 1000; i++) {
   1.499 +      j = foo((short)(j + 1));
   1.500 +    }
   1.501 +    dummy();
   1.502 +    return j;
   1.503 +  }
   1.504 +
   1.505 +  static short remi_sumc_deop() {
   1.506 +    Short j = ibc;
   1.507 +    for (int i = 0; i< 1000; i++) {
   1.508 +      j = foo((short)(j + 1));
   1.509 +    }
   1.510 +    dummy();
   1.511 +    return j;
   1.512 +  }
   1.513 +
   1.514 +  //===============================================
   1.515 +  // Conditional increment
   1.516 +  static short remi_sum_cond() {
   1.517 +    Short j = new Short((short)1);
   1.518 +    for (int i = 0; i< 1000; i++) {
   1.519 +      if ((i&1) == 0) {
   1.520 +        j = new Short((short)(j + 1));
   1.521 +      }
   1.522 +    }
   1.523 +    return j;
   1.524 +  }
   1.525 +
   1.526 +  static short remi_sumb_cond() {
   1.527 +    Short j = Short.valueOf((short)1);
   1.528 +    for (int i = 0; i< 1000; i++) {
   1.529 +      if ((i&1) == 0) {
   1.530 +        j = (short)(j + 1);
   1.531 +      }
   1.532 +    }
   1.533 +    return j;
   1.534 +  }
   1.535 +
   1.536 +  static short remi_sumf_cond() {
   1.537 +    Short j = foob((short)1);
   1.538 +    for (int i = 0; i< 1000; i++) {
   1.539 +      if ((i&1) == 0) {
   1.540 +        j = (short)(j + 1);
   1.541 +      }
   1.542 +    }
   1.543 +    return j;
   1.544 +  }
   1.545 +
   1.546 +  static short remi_sump_cond(Short j) {
   1.547 +    for (int i = 0; i< 1000; i++) {
   1.548 +      if ((i&1) == 0) {
   1.549 +        j = (short)(j + 1);
   1.550 +      }
   1.551 +    }
   1.552 +    return j;
   1.553 +  }
   1.554 +
   1.555 +  static short remi_sumc_cond() {
   1.556 +    Short j = ibc;
   1.557 +    for (int i = 0; i< 1000; i++) {
   1.558 +      if ((i&1) == 0) {
   1.559 +        j = (short)(j + ibc);
   1.560 +      }
   1.561 +    }
   1.562 +    return j;
   1.563 +  }
   1.564 +
   1.565 +  static short remi_sum2_cond() {
   1.566 +    Short j1 = new Short((short)1);
   1.567 +    Short j2 = new Short((short)1);
   1.568 +    for (int i = 0; i< 1000; i++) {
   1.569 +      if ((i&1) == 0) {
   1.570 +        j1 = new Short((short)(j1 + 1));
   1.571 +      } else {
   1.572 +        j2 = new Short((short)(j2 + 2));
   1.573 +      }
   1.574 +    }
   1.575 +    return (short)(j1 + j2);
   1.576 +  }
   1.577 +
   1.578 +  static short remi_sumb2_cond() {
   1.579 +    Short j1 = Short.valueOf((short)1);
   1.580 +    Short j2 = Short.valueOf((short)1);
   1.581 +    for (int i = 0; i< 1000; i++) {
   1.582 +      if ((i&1) == 0) {
   1.583 +        j1 = (short)(j1 + 1);
   1.584 +      } else {
   1.585 +        j2 = (short)(j2 + 2);
   1.586 +      }
   1.587 +    }
   1.588 +    return (short)(j1 + j2);
   1.589 +  }
   1.590 +
   1.591 +  static short remi_summ2_cond() {
   1.592 +    Short j1 = new Short((short)1);
   1.593 +    Short j2 = Short.valueOf((short)1);
   1.594 +    for (int i = 0; i< 1000; i++) {
   1.595 +      if ((i&1) == 0) {
   1.596 +        j1 = new Short((short)(j1 + 1));
   1.597 +      } else {
   1.598 +        j2 = (short)(j2 + 2);
   1.599 +      }
   1.600 +    }
   1.601 +    return (short)(j1 + j2);
   1.602 +  }
   1.603 +
   1.604 +  static short remi_sump2_cond(Short j1) {
   1.605 +    Short j2 = Short.valueOf((short)1);
   1.606 +    for (int i = 0; i< 1000; i++) {
   1.607 +      if ((i&1) == 0) {
   1.608 +        j1 = new Short((short)(j1 + 1));
   1.609 +      } else {
   1.610 +        j2 = (short)(j2 + 2);
   1.611 +      }
   1.612 +    }
   1.613 +    return (short)(j1 + j2);
   1.614 +  }
   1.615 +
   1.616 +  static short remi_sumc2_cond() {
   1.617 +    Short j1 = ibc;
   1.618 +    Short j2 = Short.valueOf((short)1);
   1.619 +    for (int i = 0; i< 1000; i++) {
   1.620 +      if ((i&1) == 0) {
   1.621 +        j1 = (short)(j1 + ibc);
   1.622 +      } else {
   1.623 +        j2 = (short)(j2 + 2);
   1.624 +      }
   1.625 +    }
   1.626 +    return (short)(j1 + j2);
   1.627 +  }
   1.628 +
   1.629 +
   1.630 +  public static void main(String[] args) {
   1.631 +    final int ntests = 70;
   1.632 +
   1.633 +    String[] test_name = new String[] {
   1.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
   1.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
   1.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
   1.637 +        "test",        "testb",        "testc",        "testm",        "testp",
   1.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
   1.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
   1.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
   1.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
   1.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
   1.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
   1.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
   1.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
   1.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
   1.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
   1.648 +    };
   1.649 +
   1.650 +    final int[] val = new int[] {
   1.651 +       71994000,  71994000,    12000,  71994000,  71994000,
   1.652 +      144000000, 144000000, 72018000, 144000000, 144000000,
   1.653 +       71994000,  71994000,    12000,  71994000,  71994000,
   1.654 +       72000000,  72000000, 36006000,  72000000,  72000000,
   1.655 +      144012000, 144012000, 72030000, 144012000, 144012000,
   1.656 +       72000000,  72000000, 36006000,  72000000,  72000000,
   1.657 +         -24787,    -24787,   -24787,    -24787,    -24787,
   1.658 +          16962,     16962,    16962,     16962,     16962,
   1.659 +         -24787,    -24787,   -24787,    -24787,    -24787,
   1.660 +           1001,      1001,     1001,      1001,      1001,
   1.661 +           3002,      3002,     3002,      3002,      3002,
   1.662 +           1001,      1001,     1001,      1001,      1001,
   1.663 +            501,       501,      501,       501,       501,
   1.664 +           1502,      1502,     1502,      1502,      1502
   1.665 +    };
   1.666 +
   1.667 +    int[] res = new int[ntests];
   1.668 +    for (int i = 0; i < ntests; i++) {
   1.669 +      res[i] = 0;
   1.670 +    }
   1.671 +
   1.672 +
   1.673 +    for (int i = 0; i < 12000; i++) {
   1.674 +      res[0] += simple((short)i);
   1.675 +      res[1] += simpleb((short)i);
   1.676 +      res[2] += simplec();
   1.677 +      res[3] += simplef((short)i);
   1.678 +      res[4] += simplep((short)i);
   1.679 +
   1.680 +      res[5] += simple2((short)i);
   1.681 +      res[6] += simpleb2((short)i);
   1.682 +      res[7] += simplec2((short)i);
   1.683 +      res[8] += simplem2((short)i);
   1.684 +      res[9] += simplep2((short)i, (short)i);
   1.685 +
   1.686 +      res[10] += simple_deop((short)i);
   1.687 +      res[11] += simpleb_deop((short)i);
   1.688 +      res[12] += simplec_deop((short)i);
   1.689 +      res[13] += simplef_deop((short)i);
   1.690 +      res[14] += simplep_deop((short)i);
   1.691 +
   1.692 +      res[15] += test((short)i);
   1.693 +      res[16] += testb((short)i);
   1.694 +      res[17] += testc((short)i);
   1.695 +      res[18] += testm((short)i);
   1.696 +      res[19] += testp((short)i, (short)i);
   1.697 +
   1.698 +      res[20] += test2((short)i);
   1.699 +      res[21] += testb2((short)i);
   1.700 +      res[22] += testc2((short)i);
   1.701 +      res[23] += testm2((short)i);
   1.702 +      res[24] += testp2((short)i, (short)i);
   1.703 +
   1.704 +      res[25] += test_deop((short)i);
   1.705 +      res[26] += testb_deop((short)i);
   1.706 +      res[27] += testc_deop((short)i);
   1.707 +      res[28] += testf_deop((short)i);
   1.708 +      res[29] += testp_deop((short)i, (short)i);
   1.709 +    }
   1.710 +
   1.711 +    short[] ia = new short[1000];
   1.712 +    for (int i = 0; i < 1000; i++) {
   1.713 +      ia[i] = (short)i;
   1.714 +    }
   1.715 +
   1.716 +    for (int i = 0; i < 100; i++) {
   1.717 +      res[30] = sum(ia);
   1.718 +      res[31] = sumb(ia);
   1.719 +      res[32] = sumc(ia);
   1.720 +      res[33] = sumf(ia);
   1.721 +      res[34] = sump(ia, (short)1);
   1.722 +
   1.723 +      res[35] = sum2(ia);
   1.724 +      res[36] = sumb2(ia);
   1.725 +      res[37] = sumc2(ia);
   1.726 +      res[38] = summ2(ia);
   1.727 +      res[39] = sump2(ia, (short)1);
   1.728 +
   1.729 +      res[40] = sum_deop(ia);
   1.730 +      res[41] = sumb_deop(ia);
   1.731 +      res[42] = sumc_deop(ia);
   1.732 +      res[43] = sumf_deop(ia);
   1.733 +      res[44] = sump_deop(ia, (short)1);
   1.734 +
   1.735 +      res[45] = remi_sum();
   1.736 +      res[46] = remi_sumb();
   1.737 +      res[47] = remi_sumc();
   1.738 +      res[48] = remi_sumf();
   1.739 +      res[49] = remi_sump((short)1);
   1.740 +
   1.741 +      res[50] = remi_sum2();
   1.742 +      res[51] = remi_sumb2();
   1.743 +      res[52] = remi_sumc2();
   1.744 +      res[53] = remi_summ2();
   1.745 +      res[54] = remi_sump2((short)1);
   1.746 +
   1.747 +      res[55] = remi_sum_deop();
   1.748 +      res[56] = remi_sumb_deop();
   1.749 +      res[57] = remi_sumc_deop();
   1.750 +      res[58] = remi_sumf_deop();
   1.751 +      res[59] = remi_sump_deop((short)1);
   1.752 +
   1.753 +      res[60] = remi_sum_cond();
   1.754 +      res[61] = remi_sumb_cond();
   1.755 +      res[62] = remi_sumc_cond();
   1.756 +      res[63] = remi_sumf_cond();
   1.757 +      res[64] = remi_sump_cond((short)1);
   1.758 +
   1.759 +      res[65] = remi_sum2_cond();
   1.760 +      res[66] = remi_sumb2_cond();
   1.761 +      res[67] = remi_sumc2_cond();
   1.762 +      res[68] = remi_summ2_cond();
   1.763 +      res[69] = remi_sump2_cond((short)1);
   1.764 +    }
   1.765 +
   1.766 +    int failed = 0;
   1.767 +    for (int i = 0; i < ntests; i++) {
   1.768 +      if (res[i] != val[i]) {
   1.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
   1.770 +        failed++;
   1.771 +      }
   1.772 +    }
   1.773 +    if (failed > 0) {
   1.774 +      System.err.println("Failed " + failed + " tests.");
   1.775 +      throw new InternalError();
   1.776 +    } else {
   1.777 +      System.out.println("Passed.");
   1.778 +    }
   1.779 +  }
   1.780 +}

mercurial