8016075: Win32 crash with CDS enabled and small heap size
Summary: Fixed MetaspaceShared::is_in_shared_space
Reviewed-by: coleenp, hseigel
--- a/hotspot/src/share/vm/memory/filemap.cpp Wed Jun 26 11:00:11 2013 +0200
+++ b/hotspot/src/share/vm/memory/filemap.cpp Thu Jun 27 10:03:21 2013 -0700
@@ -549,3 +549,13 @@
return false;
}
+
+void FileMapInfo::print_shared_spaces() {
+ gclog_or_tty->print_cr("Shared Spaces:");
+ for (int i = 0; i < MetaspaceShared::n_regions; i++) {
+ struct FileMapInfo::FileMapHeader::space_info* si = &_header._space[i];
+ gclog_or_tty->print(" %s " INTPTR_FORMAT "-" INTPTR_FORMAT,
+ shared_region_name[i],
+ si->_base, si->_base + si->_used);
+ }
+}
--- a/hotspot/src/share/vm/memory/filemap.hpp Wed Jun 26 11:00:11 2013 +0200
+++ b/hotspot/src/share/vm/memory/filemap.hpp Thu Jun 27 10:03:21 2013 -0700
@@ -149,6 +149,7 @@
// Return true if given address is in the mapped shared space.
bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
+ void print_shared_spaces() NOT_CDS_RETURN;
};
#endif // SHARE_VM_MEMORY_FILEMAP_HPP
--- a/hotspot/src/share/vm/memory/metaspaceShared.cpp Wed Jun 26 11:00:11 2013 +0200
+++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp Thu Jun 27 10:03:21 2013 -0700
@@ -826,35 +826,15 @@
bool reading() const { return true; }
};
-
-// Save bounds of shared spaces mapped in.
-static char* _ro_base = NULL;
-static char* _rw_base = NULL;
-static char* _md_base = NULL;
-static char* _mc_base = NULL;
-
// Return true if given address is in the mapped shared space.
bool MetaspaceShared::is_in_shared_space(const void* p) {
- if (_ro_base == NULL || _rw_base == NULL) {
- return false;
- } else {
- return ((p >= _ro_base && p < (_ro_base + SharedReadOnlySize)) ||
- (p >= _rw_base && p < (_rw_base + SharedReadWriteSize)));
- }
+ return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_space(p);
}
void MetaspaceShared::print_shared_spaces() {
- gclog_or_tty->print_cr("Shared Spaces:");
- gclog_or_tty->print(" read-only " INTPTR_FORMAT "-" INTPTR_FORMAT,
- _ro_base, _ro_base + SharedReadOnlySize);
- gclog_or_tty->print(" read-write " INTPTR_FORMAT "-" INTPTR_FORMAT,
- _rw_base, _rw_base + SharedReadWriteSize);
- gclog_or_tty->cr();
- gclog_or_tty->print(" misc-data " INTPTR_FORMAT "-" INTPTR_FORMAT,
- _md_base, _md_base + SharedMiscDataSize);
- gclog_or_tty->print(" misc-code " INTPTR_FORMAT "-" INTPTR_FORMAT,
- _mc_base, _mc_base + SharedMiscCodeSize);
- gclog_or_tty->cr();
+ if (UseSharedSpaces) {
+ FileMapInfo::current_info()->print_shared_spaces();
+ }
}
@@ -874,6 +854,11 @@
assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces");
+ char* _ro_base = NULL;
+ char* _rw_base = NULL;
+ char* _md_base = NULL;
+ char* _mc_base = NULL;
+
// Map each shared region
if ((_ro_base = mapinfo->map_region(ro)) != NULL &&
(_rw_base = mapinfo->map_region(rw)) != NULL &&