提交 47e1eca9 编写于 作者: H hseigel

8005076: Creating a CDS archive with one alignment and running another causes a crash.

Summary: Save the alignment when writing the CDS and compare it when reading the CDS.
Reviewed-by: kvn, coleenp
上级 694ed223
......@@ -119,6 +119,7 @@ void FileMapInfo::populate_header(size_t alignment) {
_header._magic = 0xf00baba2;
_header._version = _current_version;
_header._alignment = alignment;
_header._obj_alignment = ObjectAlignmentInBytes;
// The following fields are for sanity checks for whether this archive
// will function correctly with this JVM and the bootclasspath it's
......@@ -473,6 +474,12 @@ bool FileMapInfo::validate() {
" version or build of HotSpot.");
return false;
}
if (_header._obj_alignment != ObjectAlignmentInBytes) {
fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
" does not equal the current ObjectAlignmentInBytes of %d.",
_header._obj_alignment, ObjectAlignmentInBytes);
return false;
}
// Cannot verify interpreter yet, as it can only be created after the GC
// heap has been initialized.
......
......@@ -63,6 +63,7 @@ private:
int _magic; // identify file type.
int _version; // (from enum, above.)
size_t _alignment; // how shared archive should be aligned
int _obj_alignment; // value of ObjectAlignmentInBytes
struct space_info {
int _file_offset; // sizeof(this) rounded to vm page size
......
......@@ -1331,14 +1331,14 @@ bool verify_object_alignment() {
// then a saved space from compressed oops.
if ((int)ObjectAlignmentInBytes > 256) {
jio_fprintf(defaultStream::error_stream(),
"error: ObjectAlignmentInBytes=%d must not be greater then 256\n",
"error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
(int)ObjectAlignmentInBytes);
return false;
}
// In case page size is very small.
if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
jio_fprintf(defaultStream::error_stream(),
"error: ObjectAlignmentInBytes=%d must be less then page size %d\n",
"error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
(int)ObjectAlignmentInBytes, os::vm_page_size());
return false;
}
......@@ -2997,11 +2997,6 @@ void Arguments::set_shared_spaces_flags() {
FLAG_SET_DEFAULT(UseLargePages, false);
}
// Add 2M to any size for SharedReadOnlySize to get around the JPRT setting
if (DumpSharedSpaces && !FLAG_IS_DEFAULT(SharedReadOnlySize)) {
SharedReadOnlySize = 14*M;
}
if (DumpSharedSpaces) {
if (RequireSharedSpaces) {
warning("cannot dump shared archive while using shared archive");
......
......@@ -1830,7 +1830,7 @@ class CommandLineFlags {
\
product(intx, CMSIsTooFullPercentage, 98, \
"An absolute ceiling above which CMS will always consider the " \
"perm gen ripe for collection") \
"unloading of classes when class unloading is enabled") \
\
develop(bool, CMSTestInFreeList, false, \
"Check if the coalesced range is already in the " \
......@@ -1899,13 +1899,13 @@ class CommandLineFlags {
"Metadata deallocation alot interval") \
\
develop(bool, TraceMetadataChunkAllocation, false, \
"Trace humongous metadata allocations") \
"Trace chunk metadata allocations") \
\
product(bool, TraceMetadataHumongousAllocation, false, \
"Trace humongous metadata allocations") \
\
develop(bool, TraceMetavirtualspaceAllocation, false, \
"Trace humongous metadata allocations") \
"Trace virtual space metadata allocations") \
\
notproduct(bool, ExecuteInternalVMTests, false, \
"Enable execution of internal VM tests.") \
......@@ -3537,10 +3537,10 @@ class CommandLineFlags {
/* Shared spaces */ \
\
product(bool, UseSharedSpaces, true, \
"Use shared spaces in the permanent generation") \
"Use shared spaces for metadata") \
\
product(bool, RequireSharedSpaces, false, \
"Require shared spaces in the permanent generation") \
"Require shared spaces for metadata") \
\
product(bool, DumpSharedSpaces, false, \
"Special mode: JVM reads a class list, loads classes, builds " \
......@@ -3551,16 +3551,16 @@ class CommandLineFlags {
"Print usage of shared spaces") \
\
product(uintx, SharedReadWriteSize, NOT_LP64(12*M) LP64_ONLY(16*M), \
"Size of read-write space in permanent generation (in bytes)") \
"Size of read-write space for metadata (in bytes)") \
\
product(uintx, SharedReadOnlySize, NOT_LP64(12*M) LP64_ONLY(16*M), \
"Size of read-only space in permanent generation (in bytes)") \
"Size of read-only space for metadata (in bytes)") \
\
product(uintx, SharedMiscDataSize, NOT_LP64(2*M) LP64_ONLY(4*M), \
"Size of the shared data area adjacent to the heap (in bytes)") \
"Size of the shared miscellaneous data area (in bytes)") \
\
product(uintx, SharedMiscCodeSize, 120*K, \
"Size of the shared code area adjacent to the heap (in bytes)") \
"Size of the shared miscellaneous code area (in bytes)") \
\
product(uintx, SharedDummyBlockSize, 0, \
"Size of dummy block used to shift heap addresses (in bytes)") \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册