aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkvn <none@none>2013-07-15 10:28:32 -0700
committerkvn <none@none>2013-07-15 10:28:32 -0700
commitb2e2c66f22b485d19d9d7e11ad0fbf8aacfcc710 (patch)
tree65624154fc978da5084e41c0be08a97e431b5b95
parentcb0b61f13e351c971e5d37e9effdff106b8f8941 (diff)
downloadjdk8u_hotspot-b2e2c66f22b485d19d9d7e11ad0fbf8aacfcc710.tar.gz
8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
Summary: remove StubRoutines::x86::_mxcsr_std and use StubRoutines::_mxcsr_std Reviewed-by: jrose
-rw-r--r--src/cpu/x86/vm/stubGenerator_x86_64.cpp34
-rw-r--r--src/cpu/x86/vm/stubRoutines_x86_64.cpp1
-rw-r--r--src/cpu/x86/vm/stubRoutines_x86_64.hpp6
-rw-r--r--test/compiler/cpuflags/RestoreMXCSR.java42
4 files changed, 71 insertions, 12 deletions
diff --git a/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/src/cpu/x86/vm/stubGenerator_x86_64.cpp
index 2d94642f8..e27b0701e 100644
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp
+++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp
@@ -279,7 +279,7 @@ class StubGenerator: public StubCodeGenerator {
__ stmxcsr(mxcsr_save);
__ movl(rax, mxcsr_save);
__ andl(rax, MXCSR_MASK); // Only check control and mask bits
- ExternalAddress mxcsr_std(StubRoutines::x86::mxcsr_std());
+ ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
__ cmp32(rax, mxcsr_std);
__ jcc(Assembler::equal, skip_ldmx);
__ ldmxcsr(mxcsr_std);
@@ -729,17 +729,18 @@ class StubGenerator: public StubCodeGenerator {
if (CheckJNICalls) {
Label ok_ret;
+ ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
__ push(rax);
__ subptr(rsp, wordSize); // allocate a temp location
__ stmxcsr(mxcsr_save);
__ movl(rax, mxcsr_save);
__ andl(rax, MXCSR_MASK); // Only check control and mask bits
- __ cmpl(rax, *(int *)(StubRoutines::x86::mxcsr_std()));
+ __ cmp32(rax, mxcsr_std);
__ jcc(Assembler::equal, ok_ret);
__ warn("MXCSR changed by native JNI code, use -XX:+RestoreMXCSROnJNICall");
- __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std()));
+ __ ldmxcsr(mxcsr_std);
__ bind(ok_ret);
__ addptr(rsp, wordSize);
@@ -3729,12 +3730,35 @@ class StubGenerator: public StubCodeGenerator {
return stub->entry_point();
}
+ void create_control_words() {
+ // Round to nearest, 53-bit mode, exceptions masked
+ StubRoutines::_fpu_cntrl_wrd_std = 0x027F;
+ // Round to zero, 53-bit mode, exception mased
+ StubRoutines::_fpu_cntrl_wrd_trunc = 0x0D7F;
+ // Round to nearest, 24-bit mode, exceptions masked
+ StubRoutines::_fpu_cntrl_wrd_24 = 0x007F;
+ // Round to nearest, 64-bit mode, exceptions masked
+ StubRoutines::_fpu_cntrl_wrd_64 = 0x037F;
+ // Round to nearest, 64-bit mode, exceptions masked
+ StubRoutines::_mxcsr_std = 0x1F80;
+ // Note: the following two constants are 80-bit values
+ // layout is critical for correct loading by FPU.
+ // Bias for strict fp multiply/divide
+ StubRoutines::_fpu_subnormal_bias1[0]= 0x00000000; // 2^(-15360) == 0x03ff 8000 0000 0000 0000
+ StubRoutines::_fpu_subnormal_bias1[1]= 0x80000000;
+ StubRoutines::_fpu_subnormal_bias1[2]= 0x03ff;
+ // Un-Bias for strict fp multiply/divide
+ StubRoutines::_fpu_subnormal_bias2[0]= 0x00000000; // 2^(+15360) == 0x7bff 8000 0000 0000 0000
+ StubRoutines::_fpu_subnormal_bias2[1]= 0x80000000;
+ StubRoutines::_fpu_subnormal_bias2[2]= 0x7bff;
+ }
+
// Initialization
void generate_initial() {
// Generates all stubs and initializes the entry points
- // This platform-specific stub is needed by generate_call_stub()
- StubRoutines::x86::_mxcsr_std = generate_fp_mask("mxcsr_std", 0x0000000000001F80);
+ // This platform-specific settings are needed by generate_call_stub()
+ create_control_words();
// entry points that exist in all platforms Note: This is code
// that could be shared among different platforms - however the
diff --git a/src/cpu/x86/vm/stubRoutines_x86_64.cpp b/src/cpu/x86/vm/stubRoutines_x86_64.cpp
index 5c11734cc..bf539083e 100644
--- a/src/cpu/x86/vm/stubRoutines_x86_64.cpp
+++ b/src/cpu/x86/vm/stubRoutines_x86_64.cpp
@@ -42,4 +42,3 @@ address StubRoutines::x86::_float_sign_mask = NULL;
address StubRoutines::x86::_float_sign_flip = NULL;
address StubRoutines::x86::_double_sign_mask = NULL;
address StubRoutines::x86::_double_sign_flip = NULL;
-address StubRoutines::x86::_mxcsr_std = NULL;
diff --git a/src/cpu/x86/vm/stubRoutines_x86_64.hpp b/src/cpu/x86/vm/stubRoutines_x86_64.hpp
index d63e9fdf5..205bce4eb 100644
--- a/src/cpu/x86/vm/stubRoutines_x86_64.hpp
+++ b/src/cpu/x86/vm/stubRoutines_x86_64.hpp
@@ -52,7 +52,6 @@ class x86 {
static address _float_sign_flip;
static address _double_sign_mask;
static address _double_sign_flip;
- static address _mxcsr_std;
public:
@@ -106,11 +105,6 @@ class x86 {
return _double_sign_flip;
}
- static address mxcsr_std()
- {
- return _mxcsr_std;
- }
-
# include "stubRoutines_x86.hpp"
};
diff --git a/test/compiler/cpuflags/RestoreMXCSR.java b/test/compiler/cpuflags/RestoreMXCSR.java
new file mode 100644
index 000000000..0e4bce852
--- /dev/null
+++ b/test/compiler/cpuflags/RestoreMXCSR.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8020433
+ * @summary Crash when using -XX:+RestoreMXCSROnJNICalls
+ * @library /testlibrary
+ *
+ */
+import com.oracle.java.testlibrary.*;
+
+public class RestoreMXCSR {
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb;
+ OutputAnalyzer out;
+
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+RestoreMXCSROnJNICalls", "-version");
+ out = new OutputAnalyzer(pb.start());
+ out.shouldHaveExitValue(0);
+ }
+}