test/compiler/5091921/Test6357214.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2011, 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  */
    25 /**
    26  * @test
    27  * @bug 6357214
    28  * @summary Hotspot server compiler gets integer comparison wrong
    29  *
    30  * @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test6357214
    31  */
    33 // The test hangs after few iterations before the fix. So it fails if timeout.
    34 class MyResult {
    35         public boolean next() {
    36                 return true;
    37         }
    39         public String getString(String in) {
    40                 if (in.equals("id"))
    41                         return "idFoo";
    42                 if (in.equals("contentKey"))
    43                         return "ckFoo";
    44                 return "Foo";
    45         }
    47         public int getInt(String in) {
    48                 if (in.equals("processingComplete"))
    49                         return 0;
    50                 return 1;
    51         }
    53         public byte[] getBytes(String in) {
    54                 byte[] arr = null;
    55                 if (in.equals("content")) {
    56                         arr = new byte[65536];
    57                         byte j = 32;
    58                         for (int i=0; i<65536; i++) {
    59                                 arr[i] = j;
    60                                 if (++j == 127)
    61                                         j=32;
    62                         }
    63                 }
    64                 return arr;
    65         }
    66 }
    68 public class Test6357214 {
    69         public static volatile boolean bollocks = true;
    70     public String create(String context) throws Exception {
    72         //
    73         // Extract HTTP parameters
    74         //
    76         boolean showAll = System.getProperty("showAll") != null;
    77           String eventID = System.getProperty("eventID");
    78           String eventContentKey = System.getProperty("cKey");
    79         //
    80         // Build ContentStaging query based on eventID or eventContentKey
    81         //
    83         String sql = "select id, processingComplete, contentKey, content "
    84                    + "from   ContentStaging cs, ContentStagingKey csk "
    85                    + "where  cs.eventContentKey = csk.eventContentKey ";
    87         if (eventID != null) {
    88             sql += "and id = " + eventID;
    89         }
    90         else if (eventContentKey != null) {
    91             sql += "and cs.eventContentKey = '"
    92                 +  eventContentKey
    93                 +  "' having id = max(id)";
    94         }
    95         else {
    96             throw new Exception("Need eventID or eventContentKey");
    97         }
    99         //
   100         // This factory builds a static panel, there is no JSP
   101         //
   103         StringBuffer html = new StringBuffer();
   105         try {
   107                 MyResult result = new MyResult();
   108             if (result.next()) {
   110                 eventID = result.getString("id");
   111                 int processingComplete = result.getInt("processingComplete");
   112                 String contentKey = result.getString("contentKey");
   113                 byte[] bytes = result.getBytes("content");
   115                 //
   116                 // Print content status and associated controls
   117                 //
   119                 html.append("<br/><font class=\"small\">");
   120                 html.append("Status: ");
   121                 switch (processingComplete) {
   122                     case  0 :
   123                     case  1 : html.append("PENDING"); break;
   124                     case  2 : html.append(contentKey); break;
   125                     case  3 : html.append(eventID); break;
   126                     default : html.append("UNKNONW");
   127                 }
   128                 html.append("</font><br/>");
   130                 //
   131                 // Print at most 20Kb of content unless "showAll" is set
   132                 //
   134                 int limit = showAll ? Integer.MAX_VALUE : 1024 * 20;
   135                 System.out.println(limit);
   136                 html.append("<pre>");
   137                 for (int i = 0; bytes != null && i < bytes.length; i++) {
   138                     char c = (char) bytes[i];
   139                     switch (c) {
   140                         case '<' : html.append("&lt;");  break;
   141                         case '>' : html.append("&gt;");  break;
   142                         case '&' : html.append("&amp;"); break;
   143                         default  : html.append(c);
   144                     }
   146                     if (i > limit) {
   147                         while (bollocks);
   148                         // System.out.println("i is " + i);
   149                         // System.out.println("limit is " + limit);
   150                         html.append("...\n</pre>");
   151                         html.append(eventID);
   152                         html.append("<pre>");
   153                         break;
   154                     }
   155                 }
   156                 html.append("</pre>");
   157             }
   158         }
   159         catch (Exception exception) {
   160             throw exception;
   161         }
   162         finally {
   163             html.append("Oof!!");
   164         }
   165         String ret = html.toString();
   166         System.out.println("Returning string length = "+ ret.length());
   167         return ret;
   168     }
   170     public static void main(String[] args) throws Exception {
   171                 int length=0;
   173                 for (int i = 0; i < 100; i++) {
   174                         length = new Test6357214().create("boo").length();
   175                         System.out.println(length);
   176                 }
   177     }
   178 }

mercurial