hotspot/src/share/vm/runtime/virtualspace.cpp
changeset 30158 bd6094906ef8
parent 29580 a67a581cfe11
child 30166 a85188117643
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp	Thu Apr 02 16:42:24 2015 -0400
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp	Tue Apr 07 10:53:51 2015 +0200
@@ -37,13 +37,21 @@
     _alignment(0), _special(false), _executable(false) {
 }
 
-ReservedSpace::ReservedSpace(size_t size) {
+ReservedSpace::ReservedSpace(size_t size, bool prefer_large_pages) {
   // Want to use large pages where possible and pad with small pages.
   size_t page_size = os::page_size_for_region_unaligned(size, 1);
   bool large_pages = page_size != (size_t)os::vm_page_size();
-  // Don't force the alignment to be large page aligned,
-  // since that will waste memory.
-  size_t alignment = os::vm_allocation_granularity();
+  size_t alignment;
+  if (large_pages && prefer_large_pages) {
+    alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity());
+    // ReservedSpace initialization requires size to be aligned to the given
+    // alignment. Align the size up.
+    size = align_size_up(size, alignment);
+  } else {
+    // Don't force the alignment to be large page aligned,
+    // since that will waste memory.
+    alignment = os::vm_allocation_granularity();
+  }
   initialize(size, alignment, large_pages, NULL, false);
 }