hotspot/test/compiler/6880034/Test6880034.java
author sherman
Thu, 17 Jun 2010 13:21:46 -0700
changeset 5805 87c7dd70572a
parent 5547 f4b087cbb361
permissions -rw-r--r--
6962067: TEST_BUG: Tests in java/util/zip/ZipFile leave file open Summary: Close zipfile and io stream when done Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4010
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     1
/*
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     2
 * Copyright 2009 SAP AG.  All Rights Reserved.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     4
 *
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     8
 *
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    13
 * accompanied this code).
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    14
 *
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4010
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4010
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: 4010
diff changeset
    21
 * questions.
4010
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    22
 */
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    23
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    24
/**
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    25
 * @test
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    26
 * @bug 6880034
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    27
 * @summary SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    28
 *
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    29
 * @run main/othervm -Xcomp -Xbatch -XX:CompileCommand=compileonly,Test6880034,deopt_compiledframe_at_safepoint -XX:+PrintCompilation Test6880034
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    30
 */
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    31
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    32
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    33
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    34
// This test provokes a deoptimisation at a safepoint.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    35
//
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    36
// It achieves this by compiling the method 'deopt_compiledframe_at_safepoint'
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    37
// before its first usage at a point in time when a call to the virtual method
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    38
// A::doSomething() from within 'deopt_compiledframe_at_safepoint' can be
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    39
// optimised to a static call because class A has no descendants.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    40
//
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    41
// Later, when deopt_compiledframe_at_safepoint() is running, class B which
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    42
// extends A and overrides the virtual method "doSomething()", is loaded
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    43
// asynchronously in another thread.  This makes the compiled code of
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    44
// 'deopt_compiledframe_at_safepoint' invalid and triggers a deoptimisation of
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    45
// the frame where 'deopt_compiledframe_at_safepoint' is running in a
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    46
// loop.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    47
//
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    48
// The deoptimisation leads to a SIGBUS on 64-bit server VMs on SPARC and to
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    49
// an incorrect result on 32-bit server VMs on SPARC due to a regression
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    50
// introduced by the change: "6420645: Create a vm that uses compressed oops
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    51
// for up to 32gb heapsizes"
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    52
// (http://hg.openjdk.java.net/jdk7/jdk7/hotspot/rev/ba764ed4b6f2).  Further
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    53
// investigation showed that change 6420645 is not really the root cause of
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    54
// this error but only reveals a problem with the float register encodings in
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    55
// sparc.ad which was hidden until now.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    56
//
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    57
// Notice that for this test to fail in jtreg it is crucial that
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    58
// deopt_compiledframe_at_safepoint() runs in the main thread. Otherwise a
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    59
// crash in deopt_compiledframe_at_safepoint() will not be detected as a test
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    60
// failure by jtreg.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    61
//
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    62
// Author: Volker H. Simonis
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    63
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    64
class A {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    65
  public int doSomething() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    66
    return 0;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    67
  }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    68
}
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    69
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    70
class B extends A {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    71
  public B() {}
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    72
  // override 'A::doSomething()'
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    73
  public int doSomething() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    74
    return 1;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    75
  }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    76
}
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    77
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    78
class G {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    79
  public static volatile A a = new A();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    80
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    81
  // Change 'a' to point to a 'B' object
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    82
  public static void setAtoB() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    83
    try {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    84
      a =  (A) ClassLoader.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    85
        getSystemClassLoader().
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    86
        loadClass("B").
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    87
        getConstructor(new Class[] {}).
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    88
        newInstance(new Object[] {});
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    89
    }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    90
    catch (Exception e) {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    91
      System.out.println(e);
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    92
    }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    93
  }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    94
}
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    95
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    96
public class Test6880034 {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    97
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    98
  public static volatile boolean is_in_loop = false;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
    99
  public static volatile boolean stop_while_loop = false;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   100
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   101
  public static double deopt_compiledframe_at_safepoint() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   102
    // This will be an optimised static call to A::doSomething() until we load "B"
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   103
    int i = G.a.doSomething();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   104
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   105
    // Need more than 16 'double' locals in this frame
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   106
    double local1 = 1;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   107
    double local2 = 2;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   108
    double local3 = 3;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   109
    double local4 = 4;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   110
    double local5 = 5;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   111
    double local6 = 6;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   112
    double local7 = 7;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   113
    double local8 = 8;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   114
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   115
    long k = 0;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   116
    // Once we load "B", this method will be made 'not entrant' and deoptimised
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   117
    // at the safepoint which is at the end of this loop.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   118
    while (!stop_while_loop) {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   119
      if (k ==  1) local1 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   120
      if (k ==  2) local2 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   121
      if (k ==  3) local3 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   122
      if (k ==  4) local4 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   123
      if (k ==  5) local5 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   124
      if (k ==  6) local6 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   125
      if (k ==  7) local7 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   126
      if (k ==  8) local8 += i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   127
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   128
      // Tell the world that we're now running wild in the loop
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   129
      if (k++ == 20000) is_in_loop = true;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   130
    }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   131
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   132
    return
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   133
      local1 + local2 + local3 + local4 +
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   134
      local5 + local6 + local7 + local8 + i;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   135
  }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   136
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   137
  public static void main(String[] args) {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   138
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   139
    // Just to resolve G before we compile deopt_compiledframe_at_safepoint()
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   140
    G g = new G();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   141
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   142
    // Asynchronous thread which will eventually invalidate the code for
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   143
    // deopt_compiledframe_at_safepoint() and therefore triggering a
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   144
    // deoptimisation of that method.
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   145
    new Thread() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   146
      public void run() {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   147
        while (!is_in_loop) {
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   148
          // Wait until the loop is running
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   149
        }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   150
        // Load class 'B' asynchronously..
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   151
        G.setAtoB();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   152
        // ..and stop the loop
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   153
        stop_while_loop = true;
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   154
      }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   155
    }.start();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   156
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   157
    // Run the loop in deopt_compiledframe_at_safepoint()
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   158
    double retVal = deopt_compiledframe_at_safepoint();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   159
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   160
    System.out.println(retVal == 36 ? "OK" : "ERROR : " + retVal);
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   161
    if (retVal != 36) throw new RuntimeException();
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   162
  }
7467ebf34334 6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
kvn
parents:
diff changeset
   163
}