< prev index next >
src/share/vm/runtime/virtualspace.cpp
Print this page
rev 7280 : 8064457: Introduce compressed oops mode "disjoint base" and improve compressed heap handling.
*** 68,77 ****
--- 68,97 ----
return false; // did not fail
if (base != NULL) {
// Different reserve address may be acceptable in other cases
// but for compressed oops heap should be at requested address.
+
+ // Or at least in the requested mode.
+ if ((uint64_t)base >= HeapBaseMinAddress) {
+ if ((uint64_t)requested_address + size < UnscaledOopHeapMax) {
+ // Requested unscaled mode.
+ if ((uint64_t)base + size < UnscaledOopHeapMax) {
+ // Reserved unscaled mode.
+ if (PrintCompressedOopsMode) {
+ tty->print("base: %p, req_addr: %p, base+size: %p but fulfills unscaled criteria.\n", base, requested_address, base+size);
+ }
+ return false;
+ }
+ } else if ((uint64_t)requested_address + size < OopEncodingHeapMax &&
+ (uint64_t)base + size < OopEncodingHeapMax) {
+ // Requested and reserved zerobased mode.
+ tty->print("base: %p, req_addr: %p, base+size: %p but fulfills zerobased criteria.\n", base, requested_address, base+size);
+ return false;
+ }
+ }
+
assert(UseCompressedOops, "currently requested address used only for compressed oops");
if (PrintCompressedOopsMode) {
tty->cr();
tty->print_cr("Reserved memory not at requested address: " PTR_FORMAT " vs " PTR_FORMAT, base, requested_address);
}
*** 280,310 ****
_executable = false;
}
}
void ReservedSpace::protect_noaccess_prefix(const size_t size) {
- assert( (_noaccess_prefix != 0) == (UseCompressedOops && _base != NULL &&
- (Universe::narrow_oop_base() != NULL) &&
- Universe::narrow_oop_use_implicit_null_checks()),
- "noaccess_prefix should be used only with non zero based compressed oops");
// If there is no noaccess prefix, return.
if (_noaccess_prefix == 0) return;
assert(_noaccess_prefix >= (size_t)os::vm_page_size(),
"must be at least page size big");
// Protect memory at the base of the allocated region.
// If special, the page was committed (only matters on windows)
if (!os::protect_memory(_base, _noaccess_prefix, os::MEM_PROT_NONE,
_special)) {
fatal("cannot protect protection page");
}
if (PrintCompressedOopsMode) {
tty->cr();
tty->print_cr("Protected page at the reserved heap base: " PTR_FORMAT " / " INTX_FORMAT " bytes", _base, _noaccess_prefix);
}
_base += _noaccess_prefix;
_size -= _noaccess_prefix;
assert((size == _size) && ((uintptr_t)_base % _alignment == 0),
"must be exactly of required size and alignment");
--- 300,333 ----
_executable = false;
}
}
void ReservedSpace::protect_noaccess_prefix(const size_t size) {
// If there is no noaccess prefix, return.
if (_noaccess_prefix == 0) return;
assert(_noaccess_prefix >= (size_t)os::vm_page_size(),
"must be at least page size big");
+ if (true
+ WIN64_ONLY(&& !UseLargePages)
+ AIX_ONLY(&& os::vm_page_size() != SIZE_64K)) {
// Protect memory at the base of the allocated region.
// If special, the page was committed (only matters on windows)
if (!os::protect_memory(_base, _noaccess_prefix, os::MEM_PROT_NONE,
_special)) {
fatal("cannot protect protection page");
}
if (PrintCompressedOopsMode) {
tty->cr();
tty->print_cr("Protected page at the reserved heap base: " PTR_FORMAT " / " INTX_FORMAT " bytes", _base, _noaccess_prefix);
}
+ assert(Universe::narrow_oop_use_implicit_null_checks() == true, "not initialized?");
+ } else {
+ Universe::set_narrow_oop_use_implicit_null_checks(false);
+ }
_base += _noaccess_prefix;
_size -= _noaccess_prefix;
assert((size == _size) && ((uintptr_t)_base % _alignment == 0),
"must be exactly of required size and alignment");
*** 312,333 ****
ReservedHeapSpace::ReservedHeapSpace(size_t size, size_t alignment,
bool large, char* requested_address) :
ReservedSpace(size, alignment, large,
requested_address,
! (UseCompressedOops && (Universe::narrow_oop_base() != NULL) &&
! Universe::narrow_oop_use_implicit_null_checks()) ?
! lcm(os::vm_page_size(), alignment) : 0) {
if (base() > 0) {
MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap);
}
// Only reserved space for the java heap should have a noaccess_prefix
// if using compressed oops.
protect_noaccess_prefix(size);
}
// Reserve space for code segment. Same as Java heap only we mark this as
// executable.
ReservedCodeSpace::ReservedCodeSpace(size_t r_size,
size_t rs_align,
bool large) :
--- 335,359 ----
ReservedHeapSpace::ReservedHeapSpace(size_t size, size_t alignment,
bool large, char* requested_address) :
ReservedSpace(size, alignment, large,
requested_address,
! (UseCompressedOops && (requested_address == NULL || requested_address+size > (char*)OopEncodingHeapMax) ?
! noaccess_prefix_size(alignment) : 0)) {
!
if (base() > 0) {
MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap);
}
// Only reserved space for the java heap should have a noaccess_prefix
// if using compressed oops.
protect_noaccess_prefix(size);
}
+ size_t ReservedHeapSpace::noaccess_prefix_size(size_t alignment) {
+ return lcm(os::vm_page_size(), alignment);
+ }
// Reserve space for code segment. Same as Java heap only we mark this as
// executable.
ReservedCodeSpace::ReservedCodeSpace(size_t r_size,
size_t rs_align,
bool large) :
< prev index next >