Skip to content

Commit

Permalink
8263884: Clean up os::is_allocatable() across Posix platforms
Browse files Browse the repository at this point in the history
Reviewed-by: stefank
  • Loading branch information
tstuefe committed Mar 25, 2021
1 parent a9d287a commit d602ae0
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 96 deletions.
20 changes: 20 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Expand Up @@ -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);
Expand Down
20 changes: 0 additions & 20 deletions src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
Expand Up @@ -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];
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp
Expand Up @@ -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; }
Expand Down
18 changes: 0 additions & 18 deletions src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/bsd_zero/os_bsd_zero.hpp
Expand Up @@ -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; }
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.hpp
Expand Up @@ -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; }
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
Expand Up @@ -413,10 +413,6 @@ void os::setup_fpu() {
#endif
}

bool os::is_allocatable(size_t bytes) {
return true;
}

////////////////////////////////////////////////////////////////////////////////
// thread stack

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp
Expand Up @@ -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; }
Expand Down
20 changes: 0 additions & 20 deletions src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp
Expand Up @@ -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; }
Expand Down
18 changes: 0 additions & 18 deletions src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os_cpu/linux_zero/os_linux_zero.hpp
Expand Up @@ -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; }
Expand Down

1 comment on commit d602ae0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.