Skip to content

Commit

Permalink
8342769
Browse files Browse the repository at this point in the history
  • Loading branch information
TheShermanTanker authored and swesonga committed Nov 8, 2024
1 parent d0077ee commit 45955de
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
31 changes: 31 additions & 0 deletions src/hotspot/cpu/x86/sharedRuntime_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,49 @@ void SharedRuntime::inline_check_hashcode_from_object_header(MacroAssembler* mas
}
#endif //COMPILER1

#ifdef _WIN64
const juint float_sign_mask = 0x7FFFFFFF;
const juint float_infinity = 0x7F800000;
const julong double_sign_mask = CONST64(0x7FFFFFFFFFFFFFFF);
const julong double_infinity = CONST64(0x7FF0000000000000);
#endif

JRT_LEAF(jfloat, SharedRuntime::frem(jfloat x, jfloat y))
#ifdef _WIN64
// 64-bit Windows on amd64 returns the wrong values for
// infinity operands.
juint xbits = PrimitiveConversions::cast<juint>(x);
juint ybits = PrimitiveConversions::cast<juint>(y);
// x Mod Infinity == x unless x is infinity
if (((xbits & float_sign_mask) != float_infinity) &&
((ybits & float_sign_mask) == float_infinity) ) {
return x;
}
return ((jfloat)fmod_winx64((double)x, (double)y));
#else
assert(StubRoutines::fmod() != nullptr, "");
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();
jdouble dx = (jdouble) x;
jdouble dy = (jdouble) y;

return (jfloat) (*addr)(dx, dy);
#endif
JRT_END

JRT_LEAF(jdouble, SharedRuntime::drem(jdouble x, jdouble y))
#ifdef _WIN64
julong xbits = PrimitiveConversions::cast<julong>(x);
julong ybits = PrimitiveConversions::cast<julong>(y);
// x Mod Infinity == x unless x is infinity
if (((xbits & double_sign_mask) != double_infinity) &&
((ybits & double_sign_mask) == double_infinity) ) {
return x;
}
return ((jdouble)fmod_winx64((double)x, (double)y));
#else
assert(StubRoutines::fmod() != nullptr, "");
jdouble (*addr)(jdouble, jdouble) = (double (*)(double, double))StubRoutines::fmod();

return (*addr)(x, y);
#endif
JRT_END
2 changes: 2 additions & 0 deletions src/hotspot/cpu/x86/upcallLinker_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ static int compute_reg_save_area_size(const ABIDescriptor& abi) {
return size;
}

#ifndef _WIN64
constexpr int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions
#endif

static void preserve_callee_saved_registers(MacroAssembler* _masm, const ABIDescriptor& abi, int reg_save_area_offset) {
// 1. iterate all registers in the architecture
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/memMapPrinter_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class MappingInfoPrinter {
INDENT_BY(57);
st->print("%s-%s", mapping_info._state_buffer.base(), mapping_info._type_buffer.base());
INDENT_BY(63);
st->print("%#11llx", reinterpret_cast<const unsigned long long>(mem_info.BaseAddress) - reinterpret_cast<const unsigned long long>(mem_info.AllocationBase));
st->print("%#11llx", reinterpret_cast<unsigned long long>(mem_info.BaseAddress) - reinterpret_cast<unsigned long long>(mem_info.AllocationBase));
INDENT_BY(72);
if (_session.print_nmt_info_for_region(mem_info.BaseAddress, static_cast<const char*>(mem_info.BaseAddress) + mem_info.RegionSize)) {
st->print(" ");
Expand Down
31 changes: 0 additions & 31 deletions src/hotspot/share/runtime/sharedRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,44 +284,13 @@ JRT_LEAF(jlong, SharedRuntime::lrem(jlong y, jlong x))
JRT_END


#ifdef _WIN64
const juint float_sign_mask = 0x7FFFFFFF;
const juint float_infinity = 0x7F800000;
const julong double_sign_mask = CONST64(0x7FFFFFFFFFFFFFFF);
const julong double_infinity = CONST64(0x7FF0000000000000);
#endif

#if !defined(X86)
JRT_LEAF(jfloat, SharedRuntime::frem(jfloat x, jfloat y))
#ifdef _WIN64
// 64-bit Windows on amd64 returns the wrong values for
// infinity operands.
juint xbits = PrimitiveConversions::cast<juint>(x);
juint ybits = PrimitiveConversions::cast<juint>(y);
// x Mod Infinity == x unless x is infinity
if (((xbits & float_sign_mask) != float_infinity) &&
((ybits & float_sign_mask) == float_infinity) ) {
return x;
}
return ((jfloat)fmod_winx64((double)x, (double)y));
#else
return ((jfloat)fmod((double)x,(double)y));
#endif
JRT_END

JRT_LEAF(jdouble, SharedRuntime::drem(jdouble x, jdouble y))
#ifdef _WIN64
julong xbits = PrimitiveConversions::cast<julong>(x);
julong ybits = PrimitiveConversions::cast<julong>(y);
// x Mod Infinity == x unless x is infinity
if (((xbits & double_sign_mask) != double_infinity) &&
((ybits & double_sign_mask) == double_infinity) ) {
return x;
}
return ((jdouble)fmod_winx64((double)x, (double)y));
#else
return ((jdouble)fmod((double)x,(double)y));
#endif
JRT_END
#endif // !X86

Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/gtest/runtime/test_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ TEST_VM(os, find_mapping_simple) {
ASSERT_EQ(mapping_info.base, p);
ASSERT_EQ(mapping_info.regions, 1);
ASSERT_EQ(mapping_info.size, total_range_len);
ASSERT_EQ(mapping_info.committed_size, 0);
ASSERT_EQ(mapping_info.committed_size, 0U);
}
// Test just outside the allocation
if (os::win32::find_mapping(p - 1, &mapping_info)) {
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/gtest/runtime/test_os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ TEST_VM(os_windows, large_page_init_decide_size) {
size_t decided_size = os::win32::large_page_init_decide_size();
size_t min_size = GetLargePageMinimum();
if (min_size == 0) {
EXPECT_EQ(decided_size, 0) << "Expected decided size to be 0 when large page is not supported by the processor";
EXPECT_EQ(decided_size, 0U) << "Expected decided size to be 0 when large page is not supported by the processor";
return;
}

Expand All @@ -814,7 +814,7 @@ TEST_VM(os_windows, large_page_init_decide_size) {
FLAG_SET_CMDLINE(LargePageSizeInBytes, 5 * M); // Set large page size to 5MB
if (!EnableAllLargePageSizesForWindows) {
decided_size = os::win32::large_page_init_decide_size(); // Recalculate decided size
EXPECT_EQ(decided_size, 0) << "Expected decided size to be 0 for large pages bigger than 4mb on IA32 or AMD64";
EXPECT_EQ(decided_size, 0U) << "Expected decided size to be 0 for large pages bigger than 4mb on IA32 or AMD64";
}
#endif

Expand All @@ -827,7 +827,7 @@ TEST_VM(os_windows, large_page_init_decide_size) {

// Assert that the decided size defaults to minimum page size when LargePageSizeInBytes
// is not a multiple of the minimum size, assuming conditions are always met
EXPECT_EQ(decided_size, 0) << "Expected decided size to default to 0 when LargePageSizeInBytes is not a multiple of minimum size";
EXPECT_EQ(decided_size, 0U) << "Expected decided size to default to 0 when LargePageSizeInBytes is not a multiple of minimum size";
}

class ReserveMemorySpecialRunnable : public TestRunnable {
Expand Down

0 comments on commit 45955de

Please sign in to comment.