8319927: Log that IEEE rounding mode was corrupted by loading a library
Reviewed-by: goetz, lucy
This commit is contained in:
parent
f33c874b6e
commit
9faead1469
src/hotspot/os
test/hotspot/jtreg/compiler/floatingpoint
@ -978,6 +978,12 @@ bool os::dll_address_to_library_name(address addr, char* buf,
|
||||
|
||||
void *os::Bsd::dlopen_helper(const char *filename, int mode) {
|
||||
#ifndef IA32
|
||||
bool ieee_handling = IEEE_subnormal_handling_OK();
|
||||
if (!ieee_handling) {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling check failed before loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling check failed before loading %s", filename);
|
||||
}
|
||||
|
||||
// Save and restore the floating-point environment around dlopen().
|
||||
// There are known cases where global library initialization sets
|
||||
// FPU flags that affect computation accuracy, for example, enabling
|
||||
@ -1004,7 +1010,17 @@ void *os::Bsd::dlopen_helper(const char *filename, int mode) {
|
||||
// flags. Silently fix things now.
|
||||
int rtn = fesetenv(&default_fenv);
|
||||
assert(rtn == 0, "fesetenv must succeed");
|
||||
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
|
||||
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();
|
||||
|
||||
if (ieee_handling_after_issue) {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
|
||||
} else {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
|
||||
}
|
||||
|
||||
assert(ieee_handling_after_issue, "fesetenv didn't work");
|
||||
}
|
||||
#endif // IA32
|
||||
|
||||
|
@ -1804,6 +1804,12 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
|
||||
void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
|
||||
#ifndef IA32
|
||||
bool ieee_handling = IEEE_subnormal_handling_OK();
|
||||
if (!ieee_handling) {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling check failed before loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling check failed before loading %s", filename);
|
||||
}
|
||||
|
||||
// Save and restore the floating-point environment around dlopen().
|
||||
// There are known cases where global library initialization sets
|
||||
// FPU flags that affect computation accuracy, for example, enabling
|
||||
@ -1843,11 +1849,20 @@ void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
|
||||
#ifndef IA32
|
||||
// Quickly test to make sure subnormals are correctly handled.
|
||||
if (! IEEE_subnormal_handling_OK()) {
|
||||
// We just dlopen()ed a library that mangled the floating-point
|
||||
// flags. Silently fix things now.
|
||||
// We just dlopen()ed a library that mangled the floating-point flags.
|
||||
// Attempt to fix things now.
|
||||
int rtn = fesetenv(&default_fenv);
|
||||
assert(rtn == 0, "fesetenv must succeed");
|
||||
assert(IEEE_subnormal_handling_OK(), "fsetenv didn't work");
|
||||
bool ieee_handling_after_issue = IEEE_subnormal_handling_OK();
|
||||
|
||||
if (ieee_handling_after_issue) {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling had to be corrected after loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling had to be corrected after loading %s", filename);
|
||||
} else {
|
||||
Events::log_dll_message(nullptr, "IEEE subnormal handling could not be corrected after loading %s", filename);
|
||||
log_info(os)("IEEE subnormal handling could not be corrected after loading %s", filename);
|
||||
}
|
||||
assert(ieee_handling_after_issue, "fesetenv didn't work");
|
||||
}
|
||||
#endif // IA32
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8295159
|
||||
* @summary DSO created with -ffast-math breaks Java floating-point arithmetic
|
||||
* @run main/othervm/native compiler.floatingpoint.TestSubnormalDouble
|
||||
* @run main/othervm/native -Xlog:os=info compiler.floatingpoint.TestSubnormalDouble
|
||||
*/
|
||||
|
||||
package compiler.floatingpoint;
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8295159
|
||||
* @summary DSO created with -ffast-math breaks Java floating-point arithmetic
|
||||
* @run main/othervm/native compiler.floatingpoint.TestSubnormalFloat
|
||||
* @run main/othervm/native -Xlog:os=info compiler.floatingpoint.TestSubnormalFloat
|
||||
*/
|
||||
|
||||
package compiler.floatingpoint;
|
||||
|
Loading…
x
Reference in New Issue
Block a user