8241395: Factor out platform independent code for os::xxx_memory_special()
Reviewed-by: mbaesken, mdoerr, lucy
This commit is contained in:
parent
b5897fe4ed
commit
40173c5042
@ -2528,17 +2528,13 @@ void os::large_page_init() {
|
|||||||
return; // Nothing to do. See query_multipage_support and friends.
|
return; // Nothing to do. See query_multipage_support and friends.
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||||
// reserve_memory_special() is used to allocate large paged memory. On AIX, we implement
|
fatal("os::reserve_memory_special should not be called on AIX.");
|
||||||
// 64k paged memory reservation using the normal memory allocation paths (os::reserve_memory()),
|
|
||||||
// so this is not needed.
|
|
||||||
assert(false, "should not be called on AIX");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
// Detaching the SHM segment will also delete it, see reserve_memory_special().
|
fatal("os::release_memory_special should not be called on AIX.");
|
||||||
Unimplemented();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2133,12 +2133,12 @@ void os::large_page_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||||
fatal("os::reserve_memory_special should not be called on BSD.");
|
fatal("os::reserve_memory_special should not be called on BSD.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
fatal("os::release_memory_special should not be called on BSD.");
|
fatal("os::release_memory_special should not be called on BSD.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4145,7 +4145,7 @@ char* os::Linux::reserve_memory_special_huge_tlbfs(size_t bytes,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, size_t alignment,
|
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment,
|
||||||
char* req_addr, bool exec) {
|
char* req_addr, bool exec) {
|
||||||
assert(UseLargePages, "only for large pages");
|
assert(UseLargePages, "only for large pages");
|
||||||
|
|
||||||
@ -4161,9 +4161,6 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment,
|
|||||||
if (UseNUMAInterleaving) {
|
if (UseNUMAInterleaving) {
|
||||||
numa_make_global(addr, bytes);
|
numa_make_global(addr, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The memory is committed
|
|
||||||
MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, CALLER_PC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
@ -4178,22 +4175,7 @@ bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) {
|
|||||||
return pd_release_memory(base, bytes);
|
return pd_release_memory(base, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
bool res;
|
|
||||||
if (MemTracker::tracking_level() > NMT_minimal) {
|
|
||||||
Tracker tkr(Tracker::release);
|
|
||||||
res = os::Linux::release_memory_special_impl(base, bytes);
|
|
||||||
if (res) {
|
|
||||||
tkr.record((address)base, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
res = os::Linux::release_memory_special_impl(base, bytes);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool os::Linux::release_memory_special_impl(char* base, size_t bytes) {
|
|
||||||
assert(UseLargePages, "only for large pages");
|
assert(UseLargePages, "only for large pages");
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
|
@ -2606,12 +2606,12 @@ bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) {
|
char* os::pd_reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) {
|
||||||
fatal("os::reserve_memory_special should not be called on Solaris.");
|
fatal("os::reserve_memory_special should not be called on Solaris.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
fatal("os::release_memory_special should not be called on Solaris.");
|
fatal("os::release_memory_special should not be called on Solaris.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3176,7 +3176,7 @@ bool os::can_execute_large_page_memory() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr,
|
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, char* addr,
|
||||||
bool exec) {
|
bool exec) {
|
||||||
assert(UseLargePages, "only for large pages");
|
assert(UseLargePages, "only for large pages");
|
||||||
|
|
||||||
@ -3214,17 +3214,14 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr,
|
|||||||
// normal policy just allocate it all at once
|
// normal policy just allocate it all at once
|
||||||
DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
||||||
char * res = (char *)VirtualAlloc(addr, bytes, flag, prot);
|
char * res = (char *)VirtualAlloc(addr, bytes, flag, prot);
|
||||||
if (res != NULL) {
|
|
||||||
MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, CALLER_PC);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
assert(base != NULL, "Sanity check");
|
assert(base != NULL, "Sanity check");
|
||||||
return release_memory(base, bytes);
|
return pd_release_memory(base, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::print_statistics() {
|
void os::print_statistics() {
|
||||||
|
@ -1748,6 +1748,7 @@ bool os::uncommit_memory(char* addr, size_t bytes) {
|
|||||||
bool os::release_memory(char* addr, size_t bytes) {
|
bool os::release_memory(char* addr, size_t bytes) {
|
||||||
bool res;
|
bool res;
|
||||||
if (MemTracker::tracking_level() > NMT_minimal) {
|
if (MemTracker::tracking_level() > NMT_minimal) {
|
||||||
|
// Note: Tracker contains a ThreadCritical.
|
||||||
Tracker tkr(Tracker::release);
|
Tracker tkr(Tracker::release);
|
||||||
res = pd_release_memory(addr, bytes);
|
res = pd_release_memory(addr, bytes);
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -1804,6 +1805,35 @@ void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
|||||||
pd_realign_memory(addr, bytes, alignment_hint);
|
pd_realign_memory(addr, bytes, alignment_hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* os::reserve_memory_special(size_t size, size_t alignment,
|
||||||
|
char* addr, bool executable) {
|
||||||
|
|
||||||
|
assert(is_aligned(addr, alignment), "Unaligned request address");
|
||||||
|
|
||||||
|
char* result = pd_reserve_memory_special(size, alignment, addr, executable);
|
||||||
|
if (result != NULL) {
|
||||||
|
// The memory is committed
|
||||||
|
MemTracker::record_virtual_memory_reserve_and_commit((address)result, size, CALLER_PC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool os::release_memory_special(char* addr, size_t bytes) {
|
||||||
|
bool res;
|
||||||
|
if (MemTracker::tracking_level() > NMT_minimal) {
|
||||||
|
// Note: Tracker contains a ThreadCritical.
|
||||||
|
Tracker tkr(Tracker::release);
|
||||||
|
res = pd_release_memory_special(addr, bytes);
|
||||||
|
if (res) {
|
||||||
|
tkr.record((address)addr, bytes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = pd_release_memory_special(addr, bytes);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WINDOWS
|
#ifndef _WINDOWS
|
||||||
/* try to switch state from state "from" to state "to"
|
/* try to switch state from state "from" to state "to"
|
||||||
* returns the state set after the method is complete
|
* returns the state set after the method is complete
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -144,6 +144,10 @@ class os: AllStatic {
|
|||||||
static void pd_free_memory(char *addr, size_t bytes, size_t alignment_hint);
|
static void pd_free_memory(char *addr, size_t bytes, size_t alignment_hint);
|
||||||
static void pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint);
|
static void pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint);
|
||||||
|
|
||||||
|
static char* pd_reserve_memory_special(size_t size, size_t alignment,
|
||||||
|
char* addr, bool executable);
|
||||||
|
static bool pd_release_memory_special(char* addr, size_t bytes);
|
||||||
|
|
||||||
static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned);
|
static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned);
|
||||||
|
|
||||||
// Get summary strings for system information in buffer provided
|
// Get summary strings for system information in buffer provided
|
||||||
|
Loading…
Reference in New Issue
Block a user