Test6880034.java revision 1472
2362N/A * Copyright 2009 SAP AG. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. 2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary SIGBUS during deoptimisation at a safepoint on 64bit-SPARC 0N/A * @run main/othervm -Xcomp -Xbatch -XX:CompileCommand=compileonly,Test6880034,deopt_compiledframe_at_safepoint -XX:+PrintCompilation Test6880034 11N/A// This test provokes a deoptimisation at a safepoint. 0N/A// It achieves this by compiling the method 'deopt_compiledframe_at_safepoint' 0N/A// before its first usage at a point in time when a call to the virtual method 0N/A// A::doSomething() from within 'deopt_compiledframe_at_safepoint' can be 0N/A// optimised to a static call because class A has no descendants. 0N/A// Later, when deopt_compiledframe_at_safepoint() is running, class B which 0N/A// extends A and overrides the virtual method "doSomething()", is loaded 11N/A// asynchronously in another thread. This makes the compiled code of 0N/A// 'deopt_compiledframe_at_safepoint' invalid and triggers a deoptimisation of 0N/A// the frame where 'deopt_compiledframe_at_safepoint' is running in a 0N/A// The deoptimisation leads to a SIGBUS on 64-bit server VMs on SPARC and to 0N/A// an incorrect result on 32-bit server VMs on SPARC due to a regression 0N/A// introduced by the change: "6420645: Create a vm that uses compressed oops 0N/A// for up to 32gb heapsizes" 0N/A// investigation showed that change 6420645 is not really the root cause of 0N/A// this error but only reveals a problem with the float register encodings in 0N/A// sparc.ad which was hidden until now. 0N/A// Notice that for this test to fail in jtreg it is crucial that 0N/A// deopt_compiledframe_at_safepoint() runs in the main thread. Otherwise a 0N/A// crash in deopt_compiledframe_at_safepoint() will not be detected as a test 0N/A// Author: Volker H. Simonis // override 'A::doSomething()' public static volatile A a =
new A();
// Change 'a' to point to a 'B' object public static volatile boolean is_in_loop =
false;
// This will be an optimised static call to A::doSomething() until we load "B" // Need more than 16 'double' locals in this frame // Once we load "B", this method will be made 'not entrant' and deoptimised // at the safepoint which is at the end of this loop. // Tell the world that we're now running wild in the loop // Just to resolve G before we compile deopt_compiledframe_at_safepoint() // Asynchronous thread which will eventually invalidate the code for // deopt_compiledframe_at_safepoint() and therefore triggering a // deoptimisation of that method. // Wait until the loop is running // Load class 'B' asynchronously.. // Run the loop in deopt_compiledframe_at_safepoint()