test/hotspot/jtreg/compiler/c2/Test6661247.java
author shade
Fri, 08 Jun 2018 11:41:43 +0200
changeset 50463 929cd9246fc9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8204479: Bitwise AND on byte value sometimes produces wrong result Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
     2
 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
     4
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
     7
 * published by the Free Software Foundation.
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
     8
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    13
 * accompanied this code).
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    14
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 243
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    22
 */
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    23
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    24
/*
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    25
 * @test
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    26
 * @bug 6661247
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    27
 * @summary Internal bug in 32-bit HotSpot optimizer while bit manipulations
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    28
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    29
 * @run main compiler.c2.Test6661247
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    30
 */
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    31
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    32
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    33
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    34
import java.nio.LongBuffer;
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    35
import java.util.Random;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    36
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    37
// This isn't a completely reliable test for 6661247 since the results
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    38
// depend on what the local schedule looks like but it does reproduce
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    39
// the issue in current builds.
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    40
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    41
public class Test6661247 {
243
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    42
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    43
    public static void test(boolean[] src, int srcPos, LongBuffer dest, long destPos, int count) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    44
        int countStart = (destPos & 63) == 0 ? 0 : 64 - (int)(destPos & 63);
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    45
        if (countStart > count)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    46
            countStart = count;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    47
        for (int srcPosMax = srcPos + countStart; srcPos < srcPosMax; srcPos++, destPos++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    48
            if (src[srcPos])
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    49
                dest.put((int)(destPos >>> 6), dest.get((int)(destPos >>> 6)) | 1L << (destPos & 63));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    50
            else
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    51
                dest.put((int)(destPos >>> 6), dest.get((int)(destPos >>> 6)) & ~(1L << (destPos & 63)));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    52
        }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    53
        count -= countStart;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    54
        int cnt = count >>> 6;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    55
        for (int k = (int)(destPos >>> 6), kMax = k + cnt; k < kMax; k++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    56
            int low = (src[srcPos] ? 1 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    57
                | (src[srcPos + 1] ? 1 << 1 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    58
                | (src[srcPos + 2] ? 1 << 2 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    59
                | (src[srcPos + 3] ? 1 << 3 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    60
                | (src[srcPos + 4] ? 1 << 4 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    61
                | (src[srcPos + 5] ? 1 << 5 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    62
                | (src[srcPos + 6] ? 1 << 6 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    63
                | (src[srcPos + 7] ? 1 << 7 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    64
                | (src[srcPos + 8] ? 1 << 8 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    65
                | (src[srcPos + 9] ? 1 << 9 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    66
                | (src[srcPos + 10] ? 1 << 10 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    67
                | (src[srcPos + 11] ? 1 << 11 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    68
                | (src[srcPos + 12] ? 1 << 12 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    69
                | (src[srcPos + 13] ? 1 << 13 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    70
                | (src[srcPos + 14] ? 1 << 14 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    71
                | (src[srcPos + 15] ? 1 << 15 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    72
                | (src[srcPos + 16] ? 1 << 16 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    73
                | (src[srcPos + 17] ? 1 << 17 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    74
                | (src[srcPos + 18] ? 1 << 18 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    75
                | (src[srcPos + 19] ? 1 << 19 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    76
                | (src[srcPos + 20] ? 1 << 20 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    77
                | (src[srcPos + 21] ? 1 << 21 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    78
                | (src[srcPos + 22] ? 1 << 22 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    79
                | (src[srcPos + 23] ? 1 << 23 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    80
                | (src[srcPos + 24] ? 1 << 24 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    81
                | (src[srcPos + 25] ? 1 << 25 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    82
                | (src[srcPos + 26] ? 1 << 26 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    83
                | (src[srcPos + 27] ? 1 << 27 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    84
                | (src[srcPos + 28] ? 1 << 28 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    85
                | (src[srcPos + 29] ? 1 << 29 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    86
                | (src[srcPos + 30] ? 1 << 30 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    87
                | (src[srcPos + 31] ? 1 << 31 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    88
                ;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    89
            srcPos += 32;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    90
            int high = (src[srcPos] ? 1 : 0)        // PROBLEM!
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    91
                | (src[srcPos + 1] ? 1 << 1 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    92
                | (src[srcPos + 2] ? 1 << 2 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    93
                | (src[srcPos + 3] ? 1 << 3 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    94
                | (src[srcPos + 4] ? 1 << 4 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    95
                | (src[srcPos + 5] ? 1 << 5 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    96
                | (src[srcPos + 6] ? 1 << 6 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    97
                | (src[srcPos + 7] ? 1 << 7 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    98
                | (src[srcPos + 8] ? 1 << 8 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
    99
                | (src[srcPos + 9] ? 1 << 9 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   100
                | (src[srcPos + 10] ? 1 << 10 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   101
                | (src[srcPos + 11] ? 1 << 11 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   102
                | (src[srcPos + 12] ? 1 << 12 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   103
                | (src[srcPos + 13] ? 1 << 13 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   104
                | (src[srcPos + 14] ? 1 << 14 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   105
                | (src[srcPos + 15] ? 1 << 15 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   106
                | (src[srcPos + 16] ? 1 << 16 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   107
                | (src[srcPos + 17] ? 1 << 17 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   108
                | (src[srcPos + 18] ? 1 << 18 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   109
                | (src[srcPos + 19] ? 1 << 19 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   110
                | (src[srcPos + 20] ? 1 << 20 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   111
                | (src[srcPos + 21] ? 1 << 21 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   112
                | (src[srcPos + 22] ? 1 << 22 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   113
                | (src[srcPos + 23] ? 1 << 23 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   114
                | (src[srcPos + 24] ? 1 << 24 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   115
                | (src[srcPos + 25] ? 1 << 25 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   116
                | (src[srcPos + 26] ? 1 << 26 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   117
                | (src[srcPos + 27] ? 1 << 27 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   118
                | (src[srcPos + 28] ? 1 << 28 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   119
                | (src[srcPos + 29] ? 1 << 29 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   120
                | (src[srcPos + 30] ? 1 << 30 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   121
                | (src[srcPos + 31] ? 1 << 31 : 0)
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   122
                ;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   123
            srcPos += 32;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   124
            dest.put(k, ((long)low & 0xFFFFFFFFL) | (((long)high) << 32));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   125
            destPos += 64;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   126
        }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   127
        int countFinish = count & 63;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   128
        for (int srcPosMax = srcPos + countFinish; srcPos < srcPosMax; srcPos++, destPos++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   129
            if (src[srcPos])
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   130
                dest.put((int)(destPos >>> 6), dest.get((int)(destPos >>> 6)) | 1L << (destPos & 63));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   131
            else
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   132
                dest.put((int)(destPos >>> 6), dest.get((int)(destPos >>> 6)) & ~(1L << (destPos & 63)));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   133
        }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   134
    }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   135
    public static void main(String[] args) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   136
        Random r = new Random();
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   137
        int entries = 1000;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   138
        boolean[] src = new boolean[entries * 64];
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   139
        long[] dest = new long[entries];
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   140
        long[] result = new long[entries];
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   141
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   142
        for (int c = 0; c < 2000; c++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   143
            for (int i = 0; i < entries; i++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   144
                long l = r.nextLong();
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   145
                for (int bit = 0; bit < 64; bit++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   146
                    src[i * 64 + bit] = (l & (1L << bit)) != 0;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   147
                }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   148
                dest[i] = 0;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   149
                result[i] = l;
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   150
            }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   151
            test(src, 0, LongBuffer.wrap(dest, 0, dest.length), 0, src.length);
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   152
            for (int i = 0; i < entries; i++) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   153
                if (dest[i] != result[i]) {
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   154
                    throw new InternalError(i + ": " + Long.toHexString(dest[i]) + " != " + Long.toHexString(result[i]));
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   155
                }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   156
            }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   157
        }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   158
    }
79b67a7a584a 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
diff changeset
   159
}