hotspot/test/compiler/6851282/Test.java
author kvn
Wed, 25 May 2011 21:17:07 -0700
changeset 9961 5d84243241ac
parent 5547 f4b087cbb361
permissions -rw-r--r--
7048332: Cadd_cmpLTMask doesn't handle 64-bit tmp register properly Summary: Use ins_encode %{ %} form to encode cadd_cmpLTMask() instruction and remove unused code. Reviewed-by: never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3270
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3601
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3270
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     4
 *
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     8
 *
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    13
 * accompanied this code).
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    14
 *
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3601
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3601
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: 3601
diff changeset
    21
 * questions.
3270
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    22
 *
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    23
 */
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    24
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    25
/**
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    26
 * @test
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    27
 * @bug 6851282
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    28
 * @summary JIT miscompilation results in null entry in array when using CompressedOops
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    29
 *
3601
cf7521ee8975 6868486: timouts and outOfMemory in regression tests
kvn
parents: 3270
diff changeset
    30
 * @run main/othervm/timeout=600 -Xmx256m -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops Test
3270
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    31
 */
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    32
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    33
import java.util.ArrayList;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    34
import java.util.List;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    35
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    36
public class Test {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    37
  void foo(A a, A[] as) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    38
    for (A a1 : as) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    39
      B[] filtered = a.c(a1);
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    40
      for (B b : filtered) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    41
        if (b == null) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    42
          System.out.println("bug: b == null");
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    43
          System.exit(97);
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    44
        }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    45
      }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    46
    }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    47
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    48
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    49
  public static void main(String[] args) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    50
    List<A> as = new ArrayList<A>();
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    51
    for (int i = 0; i < 5000; i++) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    52
      List<B> bs = new ArrayList<B>();
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    53
      for (int j = i; j < i + 1000; j++)
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    54
        bs.add(new B(j));
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    55
      as.add(new A(bs.toArray(new B[0])));
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    56
    }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    57
    new Test().foo(as.get(0), as.subList(1, as.size()).toArray(new A[0]));
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    58
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    59
}
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    60
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    61
class A {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    62
  final B[] bs;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    63
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    64
  public A(B[] bs) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    65
    this.bs = bs;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    66
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    67
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    68
  final B[] c(final A a) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    69
    return new BoxedArray<B>(bs).filter(new Function<B, Boolean>() {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    70
      public Boolean apply(B arg) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    71
        for (B b : a.bs) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    72
          if (b.d == arg.d)
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    73
            return true;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    74
        }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    75
        return false;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    76
      }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    77
    });
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    78
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    79
}
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    80
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    81
class BoxedArray<T> {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    82
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    83
  private final T[] array;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    84
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    85
  BoxedArray(T[] array) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    86
    this.array = array;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    87
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    88
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    89
  public T[] filter(Function<T, Boolean> function) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    90
    boolean[] include = new boolean[array.length];
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    91
    int len = 0;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    92
    int i = 0;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    93
    while (i < array.length) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    94
      if (function.apply(array[i])) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    95
        include[i] = true;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    96
        len += 1;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    97
      }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    98
      i += 1;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
    99
    }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   100
    T[] result = (T[]) java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), len);
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   101
    len = 0;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   102
    i = 0;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   103
    while (len < result.length) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   104
      if (include[i]) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   105
        result[len] = array[i];
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   106
        len += 1;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   107
      }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   108
      i += 1;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   109
    }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   110
    return result;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   111
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   112
}
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   113
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   114
interface Function<T, R> {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   115
  R apply(T arg);
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   116
}
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   117
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   118
class B {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   119
  final int d;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   120
  public B(int d) {
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   121
    this.d = d;
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   122
  }
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   123
}
0a2825307027 6851282: JIT miscompilation results in null entry in array when using CompressedOops
kvn
parents:
diff changeset
   124