8291945: Add OSInfo API for static OS information
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
bd5855337c
commit
9bfffa082e
@ -60,6 +60,7 @@
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/objectMonitor.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "runtime/osThread.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
#include "runtime/safefetch.hpp"
|
||||
@ -160,7 +161,6 @@ static void vmembk_print_on(outputStream* os);
|
||||
julong os::Aix::_physical_memory = 0;
|
||||
|
||||
pthread_t os::Aix::_main_thread = ((pthread_t)0);
|
||||
int os::Aix::_page_size = -1;
|
||||
|
||||
// -1 = uninitialized, 0 if AIX, 1 if OS/400 pase
|
||||
int os::Aix::_on_pase = -1;
|
||||
@ -1751,18 +1751,6 @@ static bool uncommit_mmaped_memory(char* addr, size_t size) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
int os::vm_page_size() {
|
||||
// Seems redundant as all get out.
|
||||
assert(os::Aix::page_size() != -1, "must call os::init");
|
||||
return os::Aix::page_size();
|
||||
}
|
||||
|
||||
// Aix allocates memory by pages.
|
||||
int os::vm_allocation_granularity() {
|
||||
assert(os::Aix::page_size() != -1, "must call os::init");
|
||||
return os::Aix::page_size();
|
||||
}
|
||||
|
||||
#ifdef PRODUCT
|
||||
static void warn_fail_commit_memory(char* addr, size_t size, bool exec,
|
||||
int err) {
|
||||
@ -2228,6 +2216,11 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
static void set_page_size(int page_size) {
|
||||
OSInfo::set_vm_page_size(page_size);
|
||||
OSInfo::set_vm_allocation_granularity(page_size);
|
||||
}
|
||||
|
||||
// This is called _before_ the most of global arguments have been parsed.
|
||||
void os::init(void) {
|
||||
// This is basic, we want to know if that ever changes.
|
||||
@ -2284,16 +2277,16 @@ void os::init(void) {
|
||||
// -XX:-Use64KPages.
|
||||
if (Use64KPages) {
|
||||
trcVerbose("64K page mode (faked for data segment)");
|
||||
Aix::_page_size = 64*K;
|
||||
set_page_size(64*K);
|
||||
} else {
|
||||
trcVerbose("4K page mode (Use64KPages=off)");
|
||||
Aix::_page_size = 4*K;
|
||||
set_page_size(4*K);
|
||||
}
|
||||
} else {
|
||||
// .. and not able to allocate 64k pages dynamically. Here, just
|
||||
// fall back to 4K paged mode and use mmap for everything.
|
||||
trcVerbose("4K page mode");
|
||||
Aix::_page_size = 4*K;
|
||||
set_page_size(4*K);
|
||||
FLAG_SET_ERGO(Use64KPages, false);
|
||||
}
|
||||
} else {
|
||||
@ -2302,14 +2295,14 @@ void os::init(void) {
|
||||
// (There is one special case where this may be false: EXTSHM=on.
|
||||
// but we decided to not support that mode).
|
||||
assert0(g_multipage_support.can_use_64K_pages);
|
||||
Aix::_page_size = 64*K;
|
||||
set_page_size(64*K);
|
||||
trcVerbose("64K page mode");
|
||||
FLAG_SET_ERGO(Use64KPages, true);
|
||||
}
|
||||
|
||||
// For now UseLargePages is just ignored.
|
||||
FLAG_SET_ERGO(UseLargePages, false);
|
||||
_page_sizes.add(Aix::_page_size);
|
||||
_page_sizes.add(os::vm_page_size);
|
||||
|
||||
// debug trace
|
||||
trcVerbose("os::vm_page_size %s", describe_pagesize(os::vm_page_size()));
|
||||
|
@ -37,7 +37,6 @@ class os::Aix {
|
||||
|
||||
static julong _physical_memory;
|
||||
static pthread_t _main_thread;
|
||||
static int _page_size;
|
||||
|
||||
// -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)
|
||||
static int _on_pase;
|
||||
@ -86,11 +85,6 @@ class os::Aix {
|
||||
// Given an address, returns the size of the page backing that address
|
||||
static size_t query_pagesize(void* p);
|
||||
|
||||
static int page_size(void) {
|
||||
assert(_page_size != -1, "not initialized");
|
||||
return _page_size;
|
||||
}
|
||||
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "runtime/javaThread.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/objectMonitor.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "runtime/osThread.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
#include "runtime/semaphore.hpp"
|
||||
@ -121,7 +122,6 @@ mach_timebase_info_data_t os::Bsd::_timebase_info = {0, 0};
|
||||
volatile uint64_t os::Bsd::_max_abstime = 0;
|
||||
#endif
|
||||
pthread_t os::Bsd::_main_thread;
|
||||
int os::Bsd::_page_size = -1;
|
||||
|
||||
#if defined(__APPLE__) && defined(__x86_64__)
|
||||
static const int processor_id_unassigned = -1;
|
||||
@ -1477,18 +1477,6 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Virtual Memory
|
||||
|
||||
int os::vm_page_size() {
|
||||
// Seems redundant as all get out
|
||||
assert(os::Bsd::page_size() != -1, "must call os::init");
|
||||
return os::Bsd::page_size();
|
||||
}
|
||||
|
||||
// Solaris allocates memory by pages.
|
||||
int os::vm_allocation_granularity() {
|
||||
assert(os::Bsd::page_size() != -1, "must call os::init");
|
||||
return os::Bsd::page_size();
|
||||
}
|
||||
|
||||
static void warn_fail_commit_memory(char* addr, size_t size, bool exec,
|
||||
int err) {
|
||||
warning("INFO: os::commit_memory(" INTPTR_FORMAT ", " SIZE_FORMAT
|
||||
@ -1666,7 +1654,7 @@ bool os::pd_release_memory(char* addr, size_t size) {
|
||||
|
||||
static bool bsd_mprotect(char* addr, size_t size, int prot) {
|
||||
// Bsd wants the mprotect address argument to be page aligned.
|
||||
char* bottom = (char*)align_down((intptr_t)addr, os::Bsd::page_size());
|
||||
char* bottom = (char*)align_down((intptr_t)addr, os::vm_page_size());
|
||||
|
||||
// According to SUSv3, mprotect() should only be used with mappings
|
||||
// established by mmap(), and mmap() always maps whole pages. Unaligned
|
||||
@ -1675,7 +1663,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
|
||||
// caller if you hit this assert.
|
||||
assert(addr == bottom, "sanity check");
|
||||
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size());
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::vm_page_size());
|
||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
|
||||
return ::mprotect(bottom, size, prot) == 0;
|
||||
}
|
||||
@ -1929,11 +1917,13 @@ extern void report_error(char* file_name, int line_no, char* title,
|
||||
void os::init(void) {
|
||||
char dummy; // used to get a guess on initial stack address
|
||||
|
||||
Bsd::set_page_size(getpagesize());
|
||||
if (Bsd::page_size() == -1) {
|
||||
fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
|
||||
int page_size = getpagesize();
|
||||
OSInfo::set_vm_page_size(page_size);
|
||||
OSInfo::set_vm_allocation_granularity(page_size);
|
||||
if (os::vm_page_size() <= 0) {
|
||||
fatal("os_bsd.cpp: os::init: getpagesize() failed (%s)", os::strerror(errno));
|
||||
}
|
||||
_page_sizes.add(Bsd::page_size());
|
||||
_page_sizes.add(os::vm_page_size());
|
||||
|
||||
Bsd::initialize_system_info();
|
||||
|
||||
|
@ -44,7 +44,6 @@ class os::Bsd {
|
||||
|
||||
static julong _physical_memory;
|
||||
static pthread_t _main_thread;
|
||||
static int _page_size;
|
||||
|
||||
static julong available_memory();
|
||||
static julong physical_memory() { return _physical_memory; }
|
||||
@ -62,9 +61,6 @@ class os::Bsd {
|
||||
|
||||
static pid_t gettid();
|
||||
|
||||
static int page_size(void) { return _page_size; }
|
||||
static void set_page_size(int val) { _page_size = val; }
|
||||
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "runtime/javaThread.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/objectMonitor.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "runtime/osThread.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
@ -162,7 +163,6 @@ uintptr_t os::Linux::_initial_thread_stack_size = 0;
|
||||
int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
|
||||
int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
|
||||
pthread_t os::Linux::_main_thread;
|
||||
int os::Linux::_page_size = -1;
|
||||
bool os::Linux::_supports_fast_thread_cpu_time = false;
|
||||
const char * os::Linux::_libc_version = NULL;
|
||||
const char * os::Linux::_libpthread_version = NULL;
|
||||
@ -605,8 +605,8 @@ static void NOINLINE _expand_stack_to(address bottom) {
|
||||
|
||||
// Adjust bottom to point to the largest address within the same page, it
|
||||
// gives us a one-page buffer if alloca() allocates slightly more memory.
|
||||
bottom = (address)align_down((uintptr_t)bottom, os::Linux::page_size());
|
||||
bottom += os::Linux::page_size() - 1;
|
||||
bottom = (address)align_down((uintptr_t)bottom, os::vm_page_size());
|
||||
bottom += os::vm_page_size() - 1;
|
||||
|
||||
// sp might be slightly above current stack pointer; if that's the case, we
|
||||
// will alloca() a little more space than necessary, which is OK. Don't use
|
||||
@ -1078,8 +1078,8 @@ void os::Linux::capture_initial_stack(size_t max_size) {
|
||||
// lower end of primordial stack; reduce ulimit -s value a little bit
|
||||
// so we won't install guard page on ld.so's data section.
|
||||
// But ensure we don't underflow the stack size - allow 1 page spare
|
||||
if (stack_size >= (size_t)(3 * page_size())) {
|
||||
stack_size -= 2 * page_size();
|
||||
if (stack_size >= (size_t)(3 * os::vm_page_size())) {
|
||||
stack_size -= 2 * os::vm_page_size();
|
||||
}
|
||||
|
||||
// Try to figure out where the stack base (top) is. This is harder.
|
||||
@ -1235,11 +1235,11 @@ void os::Linux::capture_initial_stack(size_t max_size) {
|
||||
// stack top, use it as stack top, and reduce stack size so we won't put
|
||||
// guard page outside stack.
|
||||
stack_top = stack_start;
|
||||
stack_size -= 16 * page_size();
|
||||
stack_size -= 16 * os::vm_page_size();
|
||||
}
|
||||
|
||||
// stack_top could be partially down the page so align it
|
||||
stack_top = align_up(stack_top, page_size());
|
||||
stack_top = align_up(stack_top, os::vm_page_size());
|
||||
|
||||
// Allowed stack value is minimum of max_size and what we derived from rlimit
|
||||
if (max_size > 0) {
|
||||
@ -1249,7 +1249,7 @@ void os::Linux::capture_initial_stack(size_t max_size) {
|
||||
// clamp it at 8MB as we do on Solaris
|
||||
_initial_thread_stack_size = MIN2(stack_size, 8*M);
|
||||
}
|
||||
_initial_thread_stack_size = align_down(_initial_thread_stack_size, page_size());
|
||||
_initial_thread_stack_size = align_down(_initial_thread_stack_size, os::vm_page_size());
|
||||
_initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
|
||||
|
||||
assert(_initial_thread_stack_bottom < (address)stack_top, "overflow!");
|
||||
@ -2594,18 +2594,6 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Virtual Memory
|
||||
|
||||
int os::vm_page_size() {
|
||||
// Seems redundant as all get out
|
||||
assert(os::Linux::page_size() != -1, "must call os::init");
|
||||
return os::Linux::page_size();
|
||||
}
|
||||
|
||||
// Solaris allocates memory by pages.
|
||||
int os::vm_allocation_granularity() {
|
||||
assert(os::Linux::page_size() != -1, "must call os::init");
|
||||
return os::Linux::page_size();
|
||||
}
|
||||
|
||||
// Rationale behind this function:
|
||||
// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable
|
||||
// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get
|
||||
@ -3012,7 +3000,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
|
||||
// Creating guard page is very expensive. Java thread has HotSpot
|
||||
// guard pages, only enable glibc guard page for non-Java threads.
|
||||
// (Remember: compiler thread is a Java thread, too!)
|
||||
return ((thr_type == java_thread || thr_type == compiler_thread) ? 0 : page_size());
|
||||
return ((thr_type == java_thread || thr_type == compiler_thread) ? 0 : os::vm_page_size());
|
||||
}
|
||||
|
||||
void os::Linux::rebuild_nindex_to_node_map() {
|
||||
@ -3423,7 +3411,7 @@ extern char* g_assert_poison; // assertion poison page address
|
||||
|
||||
static bool linux_mprotect(char* addr, size_t size, int prot) {
|
||||
// Linux wants the mprotect address argument to be page aligned.
|
||||
char* bottom = (char*)align_down((intptr_t)addr, os::Linux::page_size());
|
||||
char* bottom = (char*)align_down((intptr_t)addr, os::vm_page_size());
|
||||
|
||||
// According to SUSv3, mprotect() should only be used with mappings
|
||||
// established by mmap(), and mmap() always maps whole pages. Unaligned
|
||||
@ -3432,7 +3420,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
|
||||
// caller if you hit this assert.
|
||||
assert(addr == bottom, "sanity check");
|
||||
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size());
|
||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::vm_page_size());
|
||||
// Don't log anything if we're executing in the poison page signal handling
|
||||
// context. It can lead to reentrant use of other parts of the VM code.
|
||||
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
|
||||
@ -4315,7 +4303,7 @@ extern void report_error(char* file_name, int line_no, char* title,
|
||||
static void check_pax(void) {
|
||||
// Zero doesn't generate code dynamically, so no need to perform the PaX check
|
||||
#ifndef ZERO
|
||||
size_t size = os::Linux::page_size();
|
||||
size_t size = os::vm_page_size();
|
||||
|
||||
void* p = ::mmap(NULL, size, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
@ -4340,12 +4328,14 @@ void os::init(void) {
|
||||
|
||||
clock_tics_per_sec = sysconf(_SC_CLK_TCK);
|
||||
|
||||
Linux::set_page_size(sysconf(_SC_PAGESIZE));
|
||||
if (Linux::page_size() == -1) {
|
||||
int page_size = sysconf(_SC_PAGESIZE);
|
||||
OSInfo::set_vm_page_size(page_size);
|
||||
OSInfo::set_vm_allocation_granularity(page_size);
|
||||
if (os::vm_page_size() <= 0) {
|
||||
fatal("os_linux.cpp: os::init: sysconf failed (%s)",
|
||||
os::strerror(errno));
|
||||
}
|
||||
_page_sizes.add(Linux::page_size());
|
||||
_page_sizes.add(os::vm_page_size());
|
||||
|
||||
Linux::initialize_system_info();
|
||||
|
||||
|
@ -55,7 +55,6 @@ class os::Linux {
|
||||
|
||||
static julong _physical_memory;
|
||||
static pthread_t _main_thread;
|
||||
static int _page_size;
|
||||
|
||||
static julong available_memory();
|
||||
static julong physical_memory() { return _physical_memory; }
|
||||
@ -132,9 +131,6 @@ class os::Linux {
|
||||
static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
|
||||
static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; }
|
||||
|
||||
static int page_size(void) { return _page_size; }
|
||||
static void set_page_size(int val) { _page_size = val; }
|
||||
|
||||
static intptr_t* ucontext_get_sp(const ucontext_t* uc);
|
||||
static intptr_t* ucontext_get_fp(const ucontext_t* uc);
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/objectMonitor.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "runtime/osThread.hpp"
|
||||
#include "runtime/park.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
@ -2862,11 +2863,6 @@ address os::win32::fast_jni_accessor_wrapper(BasicType type) {
|
||||
|
||||
// Virtual Memory
|
||||
|
||||
int os::vm_page_size() { return os::win32::vm_page_size(); }
|
||||
int os::vm_allocation_granularity() {
|
||||
return os::win32::vm_allocation_granularity();
|
||||
}
|
||||
|
||||
// Windows large page support is available on Windows 2003. In order to use
|
||||
// large page memory, the administrator must first assign additional privilege
|
||||
// to the user:
|
||||
@ -3162,7 +3158,7 @@ void os::large_page_init() {
|
||||
}
|
||||
|
||||
_large_page_size = large_page_init_decide_size();
|
||||
const size_t default_page_size = (size_t) vm_page_size();
|
||||
const size_t default_page_size = (size_t) os::vm_page_size();
|
||||
if (_large_page_size > default_page_size) {
|
||||
_page_sizes.add(_large_page_size);
|
||||
}
|
||||
@ -3881,8 +3877,6 @@ int os::current_process_id() {
|
||||
return (_initial_pid ? _initial_pid : _getpid());
|
||||
}
|
||||
|
||||
int os::win32::_vm_page_size = 0;
|
||||
int os::win32::_vm_allocation_granularity = 0;
|
||||
int os::win32::_processor_type = 0;
|
||||
// Processor level is not available on non-NT systems, use vm_version instead
|
||||
int os::win32::_processor_level = 0;
|
||||
@ -3898,8 +3892,8 @@ bool os::win32::_has_exit_bug = true;
|
||||
void os::win32::initialize_system_info() {
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
_vm_page_size = si.dwPageSize;
|
||||
_vm_allocation_granularity = si.dwAllocationGranularity;
|
||||
OSInfo::set_vm_page_size(si.dwPageSize);
|
||||
OSInfo::set_vm_allocation_granularity(si.dwAllocationGranularity);
|
||||
_processor_type = si.dwProcessorType;
|
||||
_processor_level = si.wProcessorLevel;
|
||||
set_processor_count(si.dwNumberOfProcessors);
|
||||
@ -4213,7 +4207,7 @@ void os::init(void) {
|
||||
|
||||
win32::initialize_system_info();
|
||||
win32::setmode_streams();
|
||||
_page_sizes.add(win32::vm_page_size());
|
||||
_page_sizes.add(os::vm_page_size());
|
||||
|
||||
// This may be overridden later when argument processing is done.
|
||||
FLAG_SET_ERGO(UseLargePagesIndividualAllocation, false);
|
||||
|
@ -37,8 +37,6 @@ class os::win32 {
|
||||
friend unsigned __stdcall thread_native_entry(Thread*);
|
||||
|
||||
protected:
|
||||
static int _vm_page_size;
|
||||
static int _vm_allocation_granularity;
|
||||
static int _processor_type;
|
||||
static int _processor_level;
|
||||
static julong _physical_memory;
|
||||
@ -85,12 +83,6 @@ class os::win32 {
|
||||
// Tells whether there can be the race bug during process exit on this platform
|
||||
static bool has_exit_bug() { return _has_exit_bug; }
|
||||
|
||||
// Returns the byte size of a virtual memory page
|
||||
static int vm_page_size() { return _vm_page_size; }
|
||||
|
||||
// Returns the size in bytes of memory blocks which can be allocated.
|
||||
static int vm_allocation_granularity() { return _vm_allocation_granularity; }
|
||||
|
||||
// Read the headers for the executable that started the current process into
|
||||
// the structure passed in (see winnt.h).
|
||||
static void read_executable_headers(PIMAGE_NT_HEADERS);
|
||||
|
@ -49,7 +49,7 @@ inline void os::map_stack_shadow_pages(address sp) {
|
||||
// If we decrement stack pointer more than one page
|
||||
// the OS may not map an intervening page into our space
|
||||
// and may fault on a memory access to interior of our frame.
|
||||
const int page_size = os::win32::vm_page_size();
|
||||
const int page_size = os::vm_page_size();
|
||||
const size_t n_pages = StackOverflow::stack_shadow_zone_size() / page_size;
|
||||
for (size_t pages = 1; pages <= n_pages; pages++) {
|
||||
sp -= page_size;
|
||||
|
@ -236,7 +236,7 @@ static void current_stack_region(address *bottom, size_t *size) {
|
||||
|
||||
// The block of memory returned by pthread_attr_getstack() includes
|
||||
// guard pages where present. We need to trim these off.
|
||||
size_t page_bytes = os::Linux::page_size();
|
||||
size_t page_bytes = os::vm_page_size();
|
||||
assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
|
||||
|
||||
size_t guard_bytes;
|
||||
|
@ -25,8 +25,11 @@
|
||||
#ifndef SHARE_CODE_RELOCINFO_HPP
|
||||
#define SHARE_CODE_RELOCINFO_HPP
|
||||
|
||||
#include "runtime/os.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "oops/oopsHierarchy.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
class nmethod;
|
||||
class CodeBlob;
|
||||
@ -1261,7 +1264,7 @@ class external_word_Relocation : public DataRelocation {
|
||||
// Some address looking values aren't safe to treat as relocations
|
||||
// and should just be treated as constants.
|
||||
static bool can_be_relocated(address target) {
|
||||
assert(target == NULL || (uintptr_t)target >= (uintptr_t)os::vm_page_size(), INTPTR_FORMAT, (intptr_t)target);
|
||||
assert(target == NULL || (uintptr_t)target >= (uintptr_t)OSInfo::vm_page_size(), INTPTR_FORMAT, (intptr_t)target);
|
||||
return target != NULL;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "asm/codeBuffer.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
|
||||
class Mutex;
|
||||
|
||||
// The classes in this file provide a simple framework for the
|
||||
// management of little pieces of machine code - or stubs -
|
||||
// created on the fly and frequently discarded. In this frame-
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "jvm_md.h"
|
||||
#include "metaprogramming/integralConstant.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
@ -371,7 +372,7 @@ class os: AllStatic {
|
||||
// OS interface to Virtual Memory
|
||||
|
||||
// Return the default page size.
|
||||
static int vm_page_size();
|
||||
static int vm_page_size() { return OSInfo::vm_page_size(); }
|
||||
|
||||
// The set of page sizes which the VM is allowed to use (may be a subset of
|
||||
// the page sizes actually available on the platform).
|
||||
@ -412,7 +413,8 @@ class os: AllStatic {
|
||||
const char* base,
|
||||
const size_t size);
|
||||
|
||||
static int vm_allocation_granularity();
|
||||
static int vm_allocation_granularity() { return OSInfo::vm_allocation_granularity(); }
|
||||
|
||||
inline static size_t cds_core_region_alignment();
|
||||
|
||||
// Reserves virtual memory.
|
||||
|
30
src/hotspot/share/runtime/osInfo.cpp
Normal file
30
src/hotspot/share/runtime/osInfo.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
|
||||
int OSInfo::_vm_page_size = -1;
|
||||
int OSInfo::_vm_allocation_granularity = -1;
|
||||
|
57
src/hotspot/share/runtime/osInfo.hpp
Normal file
57
src/hotspot/share/runtime/osInfo.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_RUNTIME_OSINFO_HPP
|
||||
#define SHARE_RUNTIME_OSINFO_HPP
|
||||
|
||||
#include "memory/allStatic.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
|
||||
// Static information about the operating system. Initialized exactly once
|
||||
// at VM start-up and never changes again.
|
||||
class OSInfo : AllStatic {
|
||||
static int _vm_page_size;
|
||||
static int _vm_allocation_granularity;
|
||||
|
||||
public:
|
||||
// Returns the byte size of a virtual memory page
|
||||
static int vm_page_size() { return _vm_page_size; }
|
||||
|
||||
// Returns the size, in bytes, of the granularity with which memory can be reserved using os::reserve_memory().
|
||||
static int vm_allocation_granularity() { return _vm_allocation_granularity; }
|
||||
|
||||
static void set_vm_page_size(int n) {
|
||||
assert(_vm_page_size < 0, "init only once");
|
||||
assert(n > 0, "sanity");
|
||||
_vm_page_size = n;
|
||||
}
|
||||
|
||||
static void set_vm_allocation_granularity(int n) {
|
||||
assert(_vm_allocation_granularity < 0, "init only once");
|
||||
assert(n > 0, "sanity");
|
||||
_vm_allocation_granularity = n;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARE_RUNTIME_OSINFO_HPP
|
@ -26,7 +26,7 @@
|
||||
#define SHARE_RUNTIME_SAFEPOINTMECHANISM_HPP
|
||||
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/osInfo.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#include "utilities/sizes.hpp"
|
||||
@ -63,7 +63,7 @@ class SafepointMechanism : public AllStatic {
|
||||
static intptr_t poll_bit() { return _poll_bit; }
|
||||
|
||||
static address get_polling_page() { return _polling_page; }
|
||||
static bool is_poll_address(address addr) { return addr >= _polling_page && addr < (_polling_page + os::vm_page_size()); }
|
||||
static bool is_poll_address(address addr) { return addr >= _polling_page && addr < (_polling_page + OSInfo::vm_page_size()); }
|
||||
|
||||
struct ThreadData {
|
||||
volatile uintptr_t _polling_word;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "runtime/handles.hpp"
|
||||
|
||||
class BasicLock;
|
||||
class frame;
|
||||
class RegisterMap;
|
||||
class ScopeValue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user