hotspot/test/compiler/c1/Test7103261.java
changeset 40059 c2304140ed64
parent 39417 0022da077e1e
child 41705 332239c052cc
equal deleted inserted replaced
40058:b4441f6cfe79 40059:c2304140ed64
       
     1 /*
       
     2  * Copyright (c) 2011, 2016, 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 /**
       
    26  * @test
       
    27  * @bug 7103261
       
    28  * @summary crash with jittester on sparc
       
    29  *
       
    30  * @run main compiler.c1.Test7103261
       
    31  */
       
    32 
       
    33 package compiler.c1;
       
    34 
       
    35 // exercise implicit null checking in the compiler for various field types
       
    36 public class Test7103261 {
       
    37     static Test7103261 null_value;
       
    38     static Test7103261 nonnull_value = new Test7103261();
       
    39     static Test7103261 nonnull_value2 = new Test7103261();
       
    40 
       
    41     long l;
       
    42     int i;
       
    43     float f;
       
    44     double d;
       
    45     byte b;
       
    46     char c;
       
    47     short s;
       
    48     boolean z;
       
    49     Object o;
       
    50 
       
    51     public static void main(String[] args) {
       
    52         constantStore();
       
    53         valueTest(false);
       
    54         valueTest(true);
       
    55     }
       
    56     static void constantStore() {
       
    57         for (int field = 0; field < 9; field++) {
       
    58             try {
       
    59                 Test7103261 o = nonnull_value;
       
    60                 for (int i = 0; i < 100000; i++) {
       
    61                     switch (field) {
       
    62                     case 0: o.l = 0; break;
       
    63                     case 1: o.i = 0; break;
       
    64                     case 2: o.f = 0; break;
       
    65                     case 3: o.d = 0; break;
       
    66                     case 4: o.b = 0; break;
       
    67                     case 5: o.c = 0; break;
       
    68                     case 6: o.s = 0; break;
       
    69                     case 7: o.z = false; break;
       
    70                     case 8: o.o = null; break;
       
    71                     default: throw new InternalError();
       
    72                     }
       
    73                     if (i == 90000) {
       
    74                         // hide nullness from optimizer
       
    75                         o = null_value;
       
    76                     }
       
    77                 }
       
    78             } catch (NullPointerException npe) {
       
    79             }
       
    80         }
       
    81     }
       
    82     static void valueTest(boolean store) {
       
    83         for (int field = 0; field < 9; field++) {
       
    84             try {
       
    85                 Test7103261 o  = nonnull_value;
       
    86                 Test7103261 o2 = nonnull_value2;
       
    87                 for (int i = 0; i < 100000; i++) {
       
    88                     switch (field) {
       
    89                     case 0: o.l = o2.l; break;
       
    90                     case 1: o.i = o2.i; break;
       
    91                     case 2: o.f = o2.f; break;
       
    92                     case 3: o.d = o2.d; break;
       
    93                     case 4: o.b = o2.b; break;
       
    94                     case 5: o.c = o2.c; break;
       
    95                     case 6: o.s = o2.s; break;
       
    96                     case 7: o.z = o2.z; break;
       
    97                     case 8: o.o = o2.o; break;
       
    98                     default: throw new InternalError();
       
    99                     }
       
   100                     if (i == 90000) {
       
   101                         // hide nullness from optimizer
       
   102                         if (store)
       
   103                             o = null_value;
       
   104                         else
       
   105                             o2 = null_value;
       
   106                     }
       
   107                 }
       
   108             } catch (NullPointerException npe) {
       
   109             }
       
   110         }
       
   111     }
       
   112 }