changeset 1747:fe08403130db

6979458: VM crashes when -XX:ObjectAlignmentInBytes is too big Summary: Set upper limit 256 for ObjectAlignmentInBytes value. Reviewed-by: never, iveresov
author kvn
date Tue, 05 Oct 2010 08:57:20 -0700
parents 3f9a70eb8b1f
children a3f7f95b0165
files src/share/vm/runtime/arguments.cpp
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp	Tue Oct 05 00:19:21 2010 -0700
+++ b/src/share/vm/runtime/arguments.cpp	Tue Oct 05 08:57:20 2010 -0700
@@ -1261,12 +1261,30 @@
   // Object alignment.
   if (!is_power_of_2(ObjectAlignmentInBytes)) {
     jio_fprintf(defaultStream::error_stream(),
-                "error: ObjectAlignmentInBytes=%d must be power of 2", (int)ObjectAlignmentInBytes);
+                "error: ObjectAlignmentInBytes=%d must be power of 2\n",
+                (int)ObjectAlignmentInBytes);
     return false;
   }
   if ((int)ObjectAlignmentInBytes < BytesPerLong) {
     jio_fprintf(defaultStream::error_stream(),
-                "error: ObjectAlignmentInBytes=%d must be greater or equal %d", (int)ObjectAlignmentInBytes, BytesPerLong);
+                "error: ObjectAlignmentInBytes=%d must be greater or equal %d\n",
+                (int)ObjectAlignmentInBytes, BytesPerLong);
+    return false;
+  }
+  // It does not make sense to have big object alignment
+  // since a space lost due to alignment will be greater
+  // 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",
+                (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",
+                (int)ObjectAlignmentInBytes, os::vm_page_size());
     return false;
   }
   return true;