8263884: Clean up os::is_allocatable() across Posix platforms

Reviewed-by: stefank
This commit is contained in:
Thomas Stuefe 2021-03-25 08:54:05 +00:00
parent a9d287a667
commit d602ae080b
13 changed files with 20 additions and 96 deletions

View File

@ -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);

View File

@ -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];

View File

@ -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; }

View File

@ -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

View File

@ -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; }

View File

@ -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

View File

@ -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; }

View File

@ -413,10 +413,6 @@ void os::setup_fpu() {
#endif
}
bool os::is_allocatable(size_t bytes) {
return true;
}
////////////////////////////////////////////////////////////////////////////////
// thread stack

View File

@ -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; }

View File

@ -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

View File

@ -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; }

View File

@ -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

View File

@ -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; }