test/compiler/7103261/Test7103261.java

changeset 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/compiler/7103261/Test7103261.java	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,107 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, 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 +/**
    1.29 + * @test
    1.30 + * @bug 7103261
    1.31 + * @summary crash with jittester on sparc
    1.32 + *
    1.33 + * @run main Test7103261
    1.34 + */
    1.35 +
    1.36 +// exercise implicit null checking in the compiler for various field types
    1.37 +public class Test7103261 {
    1.38 +    static Test7103261 null_value;
    1.39 +    static Test7103261 nonnull_value = new Test7103261();
    1.40 +    static Test7103261 nonnull_value2 = new Test7103261();
    1.41 +
    1.42 +    long l;
    1.43 +    int i;
    1.44 +    float f;
    1.45 +    double d;
    1.46 +    byte b;
    1.47 +    char c;
    1.48 +    short s;
    1.49 +    boolean z;
    1.50 +
    1.51 +    public static void main(String[] args) {
    1.52 +        constantStore();
    1.53 +        valueTest(false);
    1.54 +        valueTest(true);
    1.55 +    }
    1.56 +    static void constantStore() {
    1.57 +        for (int field = 0; field < 8; field++) {
    1.58 +            try {
    1.59 +                Test7103261 o = nonnull_value;
    1.60 +                for (int i = 0; i < 100000; i++) {
    1.61 +                    switch (field) {
    1.62 +                    case 0: o.l = 0; break;
    1.63 +                    case 1: o.i = 0; break;
    1.64 +                    case 2: o.f = 0; break;
    1.65 +                    case 3: o.d = 0; break;
    1.66 +                    case 4: o.b = 0; break;
    1.67 +                    case 5: o.c = 0; break;
    1.68 +                    case 6: o.s = 0; break;
    1.69 +                    case 7: o.z = false; break;
    1.70 +                    default: throw new InternalError();
    1.71 +                    }
    1.72 +                    if (i == 90000) {
    1.73 +                        // hide nullness from optimizer
    1.74 +                        o = null_value;
    1.75 +                    }
    1.76 +                }
    1.77 +            } catch (NullPointerException npe) {
    1.78 +            }
    1.79 +        }
    1.80 +    }
    1.81 +    static void valueTest(boolean store) {
    1.82 +        for (int field = 0; field < 8; field++) {
    1.83 +            try {
    1.84 +                Test7103261 o  = nonnull_value;
    1.85 +                Test7103261 o2 = nonnull_value2;
    1.86 +                for (int i = 0; i < 100000; i++) {
    1.87 +                    switch (field) {
    1.88 +                    case 0: o.l = o2.l; break;
    1.89 +                    case 1: o.i = o2.i; break;
    1.90 +                    case 2: o.f = o2.f; break;
    1.91 +                    case 3: o.d = o2.d; break;
    1.92 +                    case 4: o.b = o2.b; break;
    1.93 +                    case 5: o.c = o2.c; break;
    1.94 +                    case 6: o.s = o2.s; break;
    1.95 +                    case 7: o.z = o2.z; break;
    1.96 +                    default: throw new InternalError();
    1.97 +                    }
    1.98 +                    if (i == 90000) {
    1.99 +                        // hide nullness from optimizer
   1.100 +                        if (store)
   1.101 +                            o = null_value;
   1.102 +                        else
   1.103 +                            o2 = null_value;
   1.104 +                    }
   1.105 +                }
   1.106 +            } catch (NullPointerException npe) {
   1.107 +            }
   1.108 +        }
   1.109 +    }
   1.110 +}

mercurial