hotspot/test/compiler/5091921/Test6357214.java
author pchelko
Mon, 16 Jun 2014 17:13:58 +0400
changeset 25197 533f45be322f
parent 9446 748a37b25d10
permissions -rw-r--r--
8046221: [TEST_BUG] Cleanup datatransfer tests Reviewed-by: anthony, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9446
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     1
/*
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     4
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     8
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    13
 * accompanied this code).
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    14
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    18
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    21
 * questions.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    22
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    23
 */
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    24
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    25
/**
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    26
 * @test
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    27
 * @bug 6357214
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    28
 * @summary Hotspot server compiler gets integer comparison wrong
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    29
 *
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    30
 * @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test6357214
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    31
 */
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    32
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    33
// The test hangs after few iterations before the fix. So it fails if timeout.
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    34
class MyResult {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    35
        public boolean next() {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    36
                return true;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    37
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    38
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    39
        public String getString(String in) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    40
                if (in.equals("id"))
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    41
                        return "idFoo";
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    42
                if (in.equals("contentKey"))
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    43
                        return "ckFoo";
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    44
                return "Foo";
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    45
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    46
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    47
        public int getInt(String in) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    48
                if (in.equals("processingComplete"))
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    49
                        return 0;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    50
                return 1;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    51
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    52
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    53
        public byte[] getBytes(String in) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    54
                byte[] arr = null;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    55
                if (in.equals("content")) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    56
                        arr = new byte[65536];
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    57
                        byte j = 32;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    58
                        for (int i=0; i<65536; i++) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    59
                                arr[i] = j;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    60
                                if (++j == 127)
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    61
                                        j=32;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    62
                        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    63
                }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    64
                return arr;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    65
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    66
}
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    67
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    68
public class Test6357214 {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    69
        public static volatile boolean bollocks = true;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    70
    public String create(String context) throws Exception {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    71
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    72
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    73
        // Extract HTTP parameters
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    74
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    75
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    76
        boolean showAll = System.getProperty("showAll") != null;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    77
          String eventID = System.getProperty("eventID");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    78
          String eventContentKey = System.getProperty("cKey");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    79
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    80
        // Build ContentStaging query based on eventID or eventContentKey
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    81
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    82
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    83
        String sql = "select id, processingComplete, contentKey, content "
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    84
                   + "from   ContentStaging cs, ContentStagingKey csk "
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    85
                   + "where  cs.eventContentKey = csk.eventContentKey ";
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    86
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    87
        if (eventID != null) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    88
            sql += "and id = " + eventID;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    89
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    90
        else if (eventContentKey != null) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    91
            sql += "and cs.eventContentKey = '"
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    92
                +  eventContentKey
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    93
                +  "' having id = max(id)";
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    94
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    95
        else {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    96
            throw new Exception("Need eventID or eventContentKey");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    97
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    98
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
    99
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   100
        // This factory builds a static panel, there is no JSP
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   101
        //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   102
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   103
        StringBuffer html = new StringBuffer();
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   104
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   105
        try {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   106
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   107
                MyResult result = new MyResult();
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   108
            if (result.next()) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   109
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   110
                eventID = result.getString("id");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   111
                int processingComplete = result.getInt("processingComplete");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   112
                String contentKey = result.getString("contentKey");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   113
                byte[] bytes = result.getBytes("content");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   114
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   115
                //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   116
                // Print content status and associated controls
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   117
                //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   118
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   119
                html.append("<br/><font class=\"small\">");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   120
                html.append("Status: ");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   121
                switch (processingComplete) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   122
                    case  0 :
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   123
                    case  1 : html.append("PENDING"); break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   124
                    case  2 : html.append(contentKey); break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   125
                    case  3 : html.append(eventID); break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   126
                    default : html.append("UNKNONW");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   127
                }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   128
                html.append("</font><br/>");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   129
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   130
                //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   131
                // Print at most 20Kb of content unless "showAll" is set
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   132
                //
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   133
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   134
                int limit = showAll ? Integer.MAX_VALUE : 1024 * 20;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   135
                System.out.println(limit);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   136
                html.append("<pre>");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   137
                for (int i = 0; bytes != null && i < bytes.length; i++) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   138
                    char c = (char) bytes[i];
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   139
                    switch (c) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   140
                        case '<' : html.append("&lt;");  break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   141
                        case '>' : html.append("&gt;");  break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   142
                        case '&' : html.append("&amp;"); break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   143
                        default  : html.append(c);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   144
                    }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   145
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   146
                    if (i > limit) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   147
                        while (bollocks);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   148
                        // System.out.println("i is " + i);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   149
                        // System.out.println("limit is " + limit);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   150
                        html.append("...\n</pre>");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   151
                        html.append(eventID);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   152
                        html.append("<pre>");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   153
                        break;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   154
                    }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   155
                }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   156
                html.append("</pre>");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   157
            }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   158
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   159
        catch (Exception exception) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   160
            throw exception;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   161
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   162
        finally {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   163
            html.append("Oof!!");
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   164
        }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   165
        String ret = html.toString();
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   166
        System.out.println("Returning string length = "+ ret.length());
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   167
        return ret;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   168
    }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   169
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   170
    public static void main(String[] args) throws Exception {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   171
                int length=0;
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   172
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   173
                for (int i = 0; i < 100; i++) {
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   174
                        length = new Test6357214().create("boo").length();
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   175
                        System.out.println(length);
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   176
                }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   177
    }
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   178
}
748a37b25d10 5091921: Sign flip issues in loop optimizer
kvn
parents:
diff changeset
   179