6880034: SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
Fix problem with the double register encodings in sparc.ad Reviewed-by: never, jrose
This commit is contained in:
parent
e4541dcd08
commit
930f3d4570
hotspot
@ -107,7 +107,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
|
||||
// are saved in register windows - I's and L's in the caller's frame and O's in the stub frame
|
||||
// (as the stub's I's) when the runtime routine called by the stub creates its frame.
|
||||
int i;
|
||||
// Always make the frame size 16 bytr aligned.
|
||||
// Always make the frame size 16 byte aligned.
|
||||
int frame_size = round_to(additional_frame_words + register_save_size, 16);
|
||||
// OopMap frame size is in c2 stack slots (sizeof(jint)) not bytes or words
|
||||
int frame_size_in_slots = frame_size / sizeof(jint);
|
||||
@ -201,15 +201,14 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
|
||||
__ stx(G5, SP, ccr_offset+STACK_BIAS);
|
||||
__ stxfsr(SP, fsr_offset+STACK_BIAS);
|
||||
|
||||
// Save all the FP registers
|
||||
// Save all the FP registers: 32 doubles (32 floats correspond to the 2 halves of the first 16 doubles)
|
||||
int offset = d00_offset;
|
||||
for( int i=0; i<64; i+=2 ) {
|
||||
for( int i=0; i<FloatRegisterImpl::number_of_registers; i+=2 ) {
|
||||
FloatRegister f = as_FloatRegister(i);
|
||||
__ stf(FloatRegisterImpl::D, f, SP, offset+STACK_BIAS);
|
||||
// Record as callee saved both halves of double registers (2 float registers).
|
||||
map->set_callee_saved(VMRegImpl::stack2reg(offset>>2), f->as_VMReg());
|
||||
if (true) {
|
||||
map->set_callee_saved(VMRegImpl::stack2reg((offset + sizeof(float))>>2), f->as_VMReg()->next());
|
||||
}
|
||||
map->set_callee_saved(VMRegImpl::stack2reg((offset + sizeof(float))>>2), f->as_VMReg()->next());
|
||||
offset += sizeof(double);
|
||||
}
|
||||
|
||||
@ -224,7 +223,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_
|
||||
void RegisterSaver::restore_live_registers(MacroAssembler* masm) {
|
||||
|
||||
// Restore all the FP registers
|
||||
for( int i=0; i<64; i+=2 ) {
|
||||
for( int i=0; i<FloatRegisterImpl::number_of_registers; i+=2 ) {
|
||||
__ ldf(FloatRegisterImpl::D, SP, d00_offset+i*sizeof(float)+STACK_BIAS, as_FloatRegister(i));
|
||||
}
|
||||
|
||||
|
@ -193,38 +193,38 @@ reg_def R_F31( SOC, SOC, Op_RegF, 31, F31->as_VMReg());
|
||||
// I believe we can't handle callee-save doubles D32 and up until
|
||||
// the place in the sparc stack crawler that asserts on the 255 is
|
||||
// fixed up.
|
||||
reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg());
|
||||
reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg()->next());
|
||||
reg_def R_D34x(SOC, SOC, Op_RegD,255, F34->as_VMReg());
|
||||
reg_def R_D34 (SOC, SOC, Op_RegD, 3, F34->as_VMReg()->next());
|
||||
reg_def R_D36x(SOC, SOC, Op_RegD,255, F36->as_VMReg());
|
||||
reg_def R_D36 (SOC, SOC, Op_RegD, 5, F36->as_VMReg()->next());
|
||||
reg_def R_D38x(SOC, SOC, Op_RegD,255, F38->as_VMReg());
|
||||
reg_def R_D38 (SOC, SOC, Op_RegD, 7, F38->as_VMReg()->next());
|
||||
reg_def R_D40x(SOC, SOC, Op_RegD,255, F40->as_VMReg());
|
||||
reg_def R_D40 (SOC, SOC, Op_RegD, 9, F40->as_VMReg()->next());
|
||||
reg_def R_D42x(SOC, SOC, Op_RegD,255, F42->as_VMReg());
|
||||
reg_def R_D42 (SOC, SOC, Op_RegD, 11, F42->as_VMReg()->next());
|
||||
reg_def R_D44x(SOC, SOC, Op_RegD,255, F44->as_VMReg());
|
||||
reg_def R_D44 (SOC, SOC, Op_RegD, 13, F44->as_VMReg()->next());
|
||||
reg_def R_D46x(SOC, SOC, Op_RegD,255, F46->as_VMReg());
|
||||
reg_def R_D46 (SOC, SOC, Op_RegD, 15, F46->as_VMReg()->next());
|
||||
reg_def R_D48x(SOC, SOC, Op_RegD,255, F48->as_VMReg());
|
||||
reg_def R_D48 (SOC, SOC, Op_RegD, 17, F48->as_VMReg()->next());
|
||||
reg_def R_D50x(SOC, SOC, Op_RegD,255, F50->as_VMReg());
|
||||
reg_def R_D50 (SOC, SOC, Op_RegD, 19, F50->as_VMReg()->next());
|
||||
reg_def R_D52x(SOC, SOC, Op_RegD,255, F52->as_VMReg());
|
||||
reg_def R_D52 (SOC, SOC, Op_RegD, 21, F52->as_VMReg()->next());
|
||||
reg_def R_D54x(SOC, SOC, Op_RegD,255, F54->as_VMReg());
|
||||
reg_def R_D54 (SOC, SOC, Op_RegD, 23, F54->as_VMReg()->next());
|
||||
reg_def R_D56x(SOC, SOC, Op_RegD,255, F56->as_VMReg());
|
||||
reg_def R_D56 (SOC, SOC, Op_RegD, 25, F56->as_VMReg()->next());
|
||||
reg_def R_D58x(SOC, SOC, Op_RegD,255, F58->as_VMReg());
|
||||
reg_def R_D58 (SOC, SOC, Op_RegD, 27, F58->as_VMReg()->next());
|
||||
reg_def R_D60x(SOC, SOC, Op_RegD,255, F60->as_VMReg());
|
||||
reg_def R_D60 (SOC, SOC, Op_RegD, 29, F60->as_VMReg()->next());
|
||||
reg_def R_D62x(SOC, SOC, Op_RegD,255, F62->as_VMReg());
|
||||
reg_def R_D62 (SOC, SOC, Op_RegD, 31, F62->as_VMReg()->next());
|
||||
reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg());
|
||||
reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg()->next());
|
||||
reg_def R_D34 (SOC, SOC, Op_RegD, 3, F34->as_VMReg());
|
||||
reg_def R_D34x(SOC, SOC, Op_RegD,255, F34->as_VMReg()->next());
|
||||
reg_def R_D36 (SOC, SOC, Op_RegD, 5, F36->as_VMReg());
|
||||
reg_def R_D36x(SOC, SOC, Op_RegD,255, F36->as_VMReg()->next());
|
||||
reg_def R_D38 (SOC, SOC, Op_RegD, 7, F38->as_VMReg());
|
||||
reg_def R_D38x(SOC, SOC, Op_RegD,255, F38->as_VMReg()->next());
|
||||
reg_def R_D40 (SOC, SOC, Op_RegD, 9, F40->as_VMReg());
|
||||
reg_def R_D40x(SOC, SOC, Op_RegD,255, F40->as_VMReg()->next());
|
||||
reg_def R_D42 (SOC, SOC, Op_RegD, 11, F42->as_VMReg());
|
||||
reg_def R_D42x(SOC, SOC, Op_RegD,255, F42->as_VMReg()->next());
|
||||
reg_def R_D44 (SOC, SOC, Op_RegD, 13, F44->as_VMReg());
|
||||
reg_def R_D44x(SOC, SOC, Op_RegD,255, F44->as_VMReg()->next());
|
||||
reg_def R_D46 (SOC, SOC, Op_RegD, 15, F46->as_VMReg());
|
||||
reg_def R_D46x(SOC, SOC, Op_RegD,255, F46->as_VMReg()->next());
|
||||
reg_def R_D48 (SOC, SOC, Op_RegD, 17, F48->as_VMReg());
|
||||
reg_def R_D48x(SOC, SOC, Op_RegD,255, F48->as_VMReg()->next());
|
||||
reg_def R_D50 (SOC, SOC, Op_RegD, 19, F50->as_VMReg());
|
||||
reg_def R_D50x(SOC, SOC, Op_RegD,255, F50->as_VMReg()->next());
|
||||
reg_def R_D52 (SOC, SOC, Op_RegD, 21, F52->as_VMReg());
|
||||
reg_def R_D52x(SOC, SOC, Op_RegD,255, F52->as_VMReg()->next());
|
||||
reg_def R_D54 (SOC, SOC, Op_RegD, 23, F54->as_VMReg());
|
||||
reg_def R_D54x(SOC, SOC, Op_RegD,255, F54->as_VMReg()->next());
|
||||
reg_def R_D56 (SOC, SOC, Op_RegD, 25, F56->as_VMReg());
|
||||
reg_def R_D56x(SOC, SOC, Op_RegD,255, F56->as_VMReg()->next());
|
||||
reg_def R_D58 (SOC, SOC, Op_RegD, 27, F58->as_VMReg());
|
||||
reg_def R_D58x(SOC, SOC, Op_RegD,255, F58->as_VMReg()->next());
|
||||
reg_def R_D60 (SOC, SOC, Op_RegD, 29, F60->as_VMReg());
|
||||
reg_def R_D60x(SOC, SOC, Op_RegD,255, F60->as_VMReg()->next());
|
||||
reg_def R_D62 (SOC, SOC, Op_RegD, 31, F62->as_VMReg());
|
||||
reg_def R_D62x(SOC, SOC, Op_RegD,255, F62->as_VMReg()->next());
|
||||
|
||||
|
||||
// ----------------------------
|
||||
|
163
hotspot/test/compiler/6880034/Test6880034.java
Normal file
163
hotspot/test/compiler/6880034/Test6880034.java
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright 2009 SAP AG. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6880034
|
||||
* @summary SIGBUS during deoptimisation at a safepoint on 64bit-SPARC
|
||||
*
|
||||
* @run main/othervm -Xcomp -Xbatch -XX:CompileCommand=compileonly,Test6880034,deopt_compiledframe_at_safepoint -XX:+PrintCompilation Test6880034
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// This test provokes a deoptimisation at a safepoint.
|
||||
//
|
||||
// It achieves this by compiling the method 'deopt_compiledframe_at_safepoint'
|
||||
// before its first usage at a point in time when a call to the virtual method
|
||||
// A::doSomething() from within 'deopt_compiledframe_at_safepoint' can be
|
||||
// optimised to a static call because class A has no descendants.
|
||||
//
|
||||
// Later, when deopt_compiledframe_at_safepoint() is running, class B which
|
||||
// extends A and overrides the virtual method "doSomething()", is loaded
|
||||
// asynchronously in another thread. This makes the compiled code of
|
||||
// 'deopt_compiledframe_at_safepoint' invalid and triggers a deoptimisation of
|
||||
// the frame where 'deopt_compiledframe_at_safepoint' is running in a
|
||||
// loop.
|
||||
//
|
||||
// The deoptimisation leads to a SIGBUS on 64-bit server VMs on SPARC and to
|
||||
// an incorrect result on 32-bit server VMs on SPARC due to a regression
|
||||
// introduced by the change: "6420645: Create a vm that uses compressed oops
|
||||
// for up to 32gb heapsizes"
|
||||
// (http://hg.openjdk.java.net/jdk7/jdk7/hotspot/rev/ba764ed4b6f2). Further
|
||||
// investigation showed that change 6420645 is not really the root cause of
|
||||
// this error but only reveals a problem with the float register encodings in
|
||||
// sparc.ad which was hidden until now.
|
||||
//
|
||||
// Notice that for this test to fail in jtreg it is crucial that
|
||||
// deopt_compiledframe_at_safepoint() runs in the main thread. Otherwise a
|
||||
// crash in deopt_compiledframe_at_safepoint() will not be detected as a test
|
||||
// failure by jtreg.
|
||||
//
|
||||
// Author: Volker H. Simonis
|
||||
|
||||
class A {
|
||||
public int doSomething() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public B() {}
|
||||
// override 'A::doSomething()'
|
||||
public int doSomething() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class G {
|
||||
public static volatile A a = new A();
|
||||
|
||||
// Change 'a' to point to a 'B' object
|
||||
public static void setAtoB() {
|
||||
try {
|
||||
a = (A) ClassLoader.
|
||||
getSystemClassLoader().
|
||||
loadClass("B").
|
||||
getConstructor(new Class[] {}).
|
||||
newInstance(new Object[] {});
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Test6880034 {
|
||||
|
||||
public static volatile boolean is_in_loop = false;
|
||||
public static volatile boolean stop_while_loop = false;
|
||||
|
||||
public static double deopt_compiledframe_at_safepoint() {
|
||||
// This will be an optimised static call to A::doSomething() until we load "B"
|
||||
int i = G.a.doSomething();
|
||||
|
||||
// Need more than 16 'double' locals in this frame
|
||||
double local1 = 1;
|
||||
double local2 = 2;
|
||||
double local3 = 3;
|
||||
double local4 = 4;
|
||||
double local5 = 5;
|
||||
double local6 = 6;
|
||||
double local7 = 7;
|
||||
double local8 = 8;
|
||||
|
||||
long k = 0;
|
||||
// Once we load "B", this method will be made 'not entrant' and deoptimised
|
||||
// at the safepoint which is at the end of this loop.
|
||||
while (!stop_while_loop) {
|
||||
if (k == 1) local1 += i;
|
||||
if (k == 2) local2 += i;
|
||||
if (k == 3) local3 += i;
|
||||
if (k == 4) local4 += i;
|
||||
if (k == 5) local5 += i;
|
||||
if (k == 6) local6 += i;
|
||||
if (k == 7) local7 += i;
|
||||
if (k == 8) local8 += i;
|
||||
|
||||
// Tell the world that we're now running wild in the loop
|
||||
if (k++ == 20000) is_in_loop = true;
|
||||
}
|
||||
|
||||
return
|
||||
local1 + local2 + local3 + local4 +
|
||||
local5 + local6 + local7 + local8 + i;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Just to resolve G before we compile deopt_compiledframe_at_safepoint()
|
||||
G g = new G();
|
||||
|
||||
// Asynchronous thread which will eventually invalidate the code for
|
||||
// deopt_compiledframe_at_safepoint() and therefore triggering a
|
||||
// deoptimisation of that method.
|
||||
new Thread() {
|
||||
public void run() {
|
||||
while (!is_in_loop) {
|
||||
// Wait until the loop is running
|
||||
}
|
||||
// Load class 'B' asynchronously..
|
||||
G.setAtoB();
|
||||
// ..and stop the loop
|
||||
stop_while_loop = true;
|
||||
}
|
||||
}.start();
|
||||
|
||||
// Run the loop in deopt_compiledframe_at_safepoint()
|
||||
double retVal = deopt_compiledframe_at_safepoint();
|
||||
|
||||
System.out.println(retVal == 36 ? "OK" : "ERROR : " + retVal);
|
||||
if (retVal != 36) throw new RuntimeException();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user