aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Thomas Stuefe <stuefe@openjdk.org> 2021-03-25 08:54:05 +0000
committerGravatar Thomas Stuefe <stuefe@openjdk.org> 2021-03-25 08:54:05 +0000
commitd602ae080bdf8e1b1afa5055e081915595b5a94a (patch)
tree98df5e652fdeb627670be03f4de5c2a3bc958af2
parenta9d287a66749b45e1dee1ecf88735931ff963f4d (diff)
downloadjdk-d602ae080bdf8e1b1afa5055e081915595b5a94a.tar.gz
jdk-d602ae080bdf8e1b1afa5055e081915595b5a94a.zip
8263884: Clean up os::is_allocatable() across Posix platforms
Reviewed-by: stefank
-rw-r--r--src/hotspot/os/posix/os_posix.cpp20
-rw-r--r--src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp20
-rw-r--r--src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp2
-rw-r--r--src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp18
-rw-r--r--src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp2
-rw-r--r--src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp4
-rw-r--r--src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp2
-rw-r--r--src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp4
-rw-r--r--src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp2
-rw-r--r--src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp20
-rw-r--r--src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp2
-rw-r--r--src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp18
-rw-r--r--src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp2
13 files changed, 20 insertions, 96 deletions
diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp
index ba076586276..2009d91d6e9 100644
--- a/src/hotspot/os/posix/os_posix.cpp
+++ b/src/hotspot/os/posix/os_posix.cpp
@@ -546,6 +546,26 @@ bool os::get_host_name(char* buf, size_t buflen) {
return true;
}
+#ifndef _LP64
+// Helper, on 32bit, for os::has_allocatable_memory_limit
+static bool is_allocatable(size_t s) {
+ if (s < 2 * G) {
+ return true;
+ }
+ // Use raw anonymous mmap here; no need to go through any
+ // of our reservation layers. We will unmap right away.
+ void* p = ::mmap(NULL, s, PROT_NONE,
+ MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED) {
+ return false;
+ } else {
+ ::munmap(p, s);
+ return true;
+ }
+}
+#endif // !_LP64
+
+
bool os::has_allocatable_memory_limit(size_t* limit) {
struct rlimit rlim;
int getrlimit_res = getrlimit(RLIMIT_AS, &rlim);
diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
index 91ca9564a3e..1eb62bf4228 100644
--- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
+++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
@@ -641,26 +641,6 @@ bool os::supports_sse() {
return true;
}
-bool os::is_allocatable(size_t bytes) {
-#ifdef AMD64
- // unused on amd64?
- return true;
-#else
-
- if (bytes < 2 * G) {
- return true;
- }
-
- char* addr = reserve_memory(bytes);
-
- if (addr != NULL) {
- release_memory(addr, bytes);
- }
-
- return addr != NULL;
-#endif // AMD64
-}
-
juint os::cpu_microcode_revision() {
juint result = 0;
char data[8];
diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp
index e3ada5a62b8..fc5c613d4c3 100644
--- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp
+++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp
@@ -37,8 +37,6 @@
static jlong rdtsc();
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
diff --git a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp
index 18125f1c16c..df96bb859f4 100644
--- a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp
+++ b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp
@@ -158,24 +158,6 @@ void os::Bsd::init_thread_fpu_state(void) {
// Nothing to do
}
-bool os::is_allocatable(size_t bytes) {
-#ifdef _LP64
- return true;
-#else
- if (bytes < 2 * G) {
- return true;
- }
-
- char* addr = reserve_memory(bytes);
-
- if (addr != NULL) {
- release_memory(addr, bytes);
- }
-
- return addr != NULL;
-#endif // _LP64
-}
-
///////////////////////////////////////////////////////////////////////////////
// thread stack
diff --git a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp
index 511400ae0d2..286837bc731 100644
--- a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp
+++ b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp
@@ -28,8 +28,6 @@
static void setup_fpu() {}
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
index 13702ba1c23..b3c60b6e624 100644
--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
@@ -304,10 +304,6 @@ int os::Linux::get_fpu_control_word(void) {
void os::Linux::set_fpu_control_word(int fpu_control) {
}
-bool os::is_allocatable(size_t bytes) {
- return true;
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread stack
diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp
index 6e5f5ee03b1..14169be6d1d 100644
--- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp
+++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp
@@ -32,8 +32,6 @@
static void setup_fpu();
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
index 064c1fba16b..3957be6263c 100644
--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
@@ -413,10 +413,6 @@ void os::setup_fpu() {
#endif
}
-bool os::is_allocatable(size_t bytes) {
- return true;
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread stack
diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp
index 9c5d629b095..c4e240767e2 100644
--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp
+++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp
@@ -34,8 +34,6 @@
static void setup_fpu();
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
index dcd2f566a16..f4ce6019d34 100644
--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
@@ -478,26 +478,6 @@ juint os::cpu_microcode_revision() {
return result;
}
-bool os::is_allocatable(size_t bytes) {
-#ifdef AMD64
- // unused on amd64?
- return true;
-#else
-
- if (bytes < 2 * G) {
- return true;
- }
-
- char* addr = reserve_memory(bytes);
-
- if (addr != NULL) {
- release_memory(addr, bytes);
- }
-
- return addr != NULL;
-#endif // AMD64
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread stack
diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp
index a60394f9a73..979006035cc 100644
--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp
+++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp
@@ -31,8 +31,6 @@
static jlong rdtsc();
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }
diff --git a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
index ac57da78a25..ebc7b8b75fb 100644
--- a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
+++ b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
@@ -182,24 +182,6 @@ void os::Linux::set_fpu_control_word(int fpu) {
ShouldNotCallThis();
}
-bool os::is_allocatable(size_t bytes) {
-#ifdef _LP64
- return true;
-#else
- if (bytes < 2 * G) {
- return true;
- }
-
- char* addr = reserve_memory(bytes);
-
- if (addr != NULL) {
- release_memory(addr, bytes);
- }
-
- return addr != NULL;
-#endif // _LP64
-}
-
///////////////////////////////////////////////////////////////////////////////
// thread stack
diff --git a/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp b/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp
index 9d4e0808551..8db407aa20d 100644
--- a/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp
+++ b/src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp
@@ -28,8 +28,6 @@
static void setup_fpu() {}
- static bool is_allocatable(size_t bytes);
-
// Used to register dynamic code cache area with the OS
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }