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