mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 02:24:40 +02:00
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
Use a single range check with MetaspaceObj::_shared_metaspace_{base,top} Reviewed-by: jiangli, redestad, shade
This commit is contained in:
parent
dcb4e73a38
commit
a3cb6e9204
15 changed files with 93 additions and 90 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, 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
|
||||
|
@ -659,7 +659,7 @@ ReservedSpace FileMapInfo::reserve_shared_memory() {
|
|||
static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData",
|
||||
"String1", "String2", "OpenArchive1", "OpenArchive2" };
|
||||
|
||||
char* FileMapInfo::map_region(int i) {
|
||||
char* FileMapInfo::map_region(int i, char** top_ret) {
|
||||
assert(!MetaspaceShared::is_heap_region(i), "sanity");
|
||||
struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
|
||||
size_t used = si->_used;
|
||||
|
@ -686,6 +686,12 @@ char* FileMapInfo::map_region(int i) {
|
|||
MemTracker::record_virtual_memory_type((address)base, mtClassShared);
|
||||
#endif
|
||||
|
||||
|
||||
if (!verify_region_checksum(i)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*top_ret = base + size;
|
||||
return base;
|
||||
}
|
||||
|
||||
|
@ -1040,27 +1046,6 @@ bool FileMapInfo::validate_header() {
|
|||
return status;
|
||||
}
|
||||
|
||||
// The following method is provided to see whether a given pointer
|
||||
// falls in the mapped shared metadata space.
|
||||
// Param:
|
||||
// p, The given pointer
|
||||
// Return:
|
||||
// True if the p is within the mapped shared space, otherwise, false.
|
||||
bool FileMapInfo::is_in_shared_space(const void* p) {
|
||||
for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) {
|
||||
char *base;
|
||||
if (_header->_space[i]._used == 0) {
|
||||
continue;
|
||||
}
|
||||
base = _header->region_addr(i);
|
||||
if (p >= base && p < base + _header->_space[i]._used) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if a given address is within one of the shared regions
|
||||
bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
|
||||
assert(idx == MetaspaceShared::ro ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue