< prev index next >

src/share/vm/runtime/virtualspace.cpp

Print this page
rev 7514 : 8066875: VirtualSpace does not use large pages


 340 VirtualSpace::VirtualSpace() {
 341   _low_boundary           = NULL;
 342   _high_boundary          = NULL;
 343   _low                    = NULL;
 344   _high                   = NULL;
 345   _lower_high             = NULL;
 346   _middle_high            = NULL;
 347   _upper_high             = NULL;
 348   _lower_high_boundary    = NULL;
 349   _middle_high_boundary   = NULL;
 350   _upper_high_boundary    = NULL;
 351   _lower_alignment        = 0;
 352   _middle_alignment       = 0;
 353   _upper_alignment        = 0;
 354   _special                = false;
 355   _executable             = false;
 356 }
 357 
 358 
 359 bool VirtualSpace::initialize(ReservedSpace rs, size_t committed_size) {
 360   const size_t max_commit_granularity = os::page_size_for_region(rs.size(), 1);
 361   return initialize_with_granularity(rs, committed_size, max_commit_granularity);
 362 }
 363 
 364 bool VirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t committed_size, size_t max_commit_granularity) {
 365   if(!rs.is_reserved()) return false;  // allocation failed.
 366   assert(_low_boundary == NULL, "VirtualSpace already initialized");
 367   assert(max_commit_granularity > 0, "Granularity must be non-zero.");
 368 
 369   _low_boundary  = rs.base();
 370   _high_boundary = low_boundary() + rs.size();
 371 
 372   _low = low_boundary();
 373   _high = low();
 374 
 375   _special = rs.special();
 376   _executable = rs.executable();
 377 
 378   // When a VirtualSpace begins life at a large size, make all future expansion
 379   // and shrinking occur aligned to a granularity of large pages.  This avoids
 380   // fragmentation of physical addresses that inhibits the use of large pages


 975     case Default:
 976     case Reserve:
 977       return ReservedSpace(reserve_size_aligned);
 978     case Disable:
 979     case Commit:
 980       return ReservedSpace(reserve_size_aligned,
 981                            os::vm_allocation_granularity(),
 982                            /* large */ false, /* exec */ false);
 983     }
 984   }
 985 
 986   static bool initialize_virtual_space(VirtualSpace& vs, ReservedSpace rs, TestLargePages mode) {
 987     switch(mode) {
 988     default:
 989     case Default:
 990     case Reserve:
 991       return vs.initialize(rs, 0);
 992     case Disable:
 993       return vs.initialize_with_granularity(rs, 0, os::vm_page_size());
 994     case Commit:
 995       return vs.initialize_with_granularity(rs, 0, os::page_size_for_region(rs.size(), 1));
 996     }
 997   }
 998 
 999  public:
1000   static void test_virtual_space_actual_committed_space(size_t reserve_size, size_t commit_size,
1001                                                         TestLargePages mode = Default) {
1002     size_t granularity = os::vm_allocation_granularity();
1003     size_t reserve_size_aligned = align_size_up(reserve_size, granularity);
1004 
1005     ReservedSpace reserved = reserve_memory(reserve_size_aligned, mode);
1006 
1007     assert(reserved.is_reserved(), "Must be");
1008 
1009     VirtualSpace vs;
1010     bool initialized = initialize_virtual_space(vs, reserved, mode);
1011     assert(initialized, "Failed to initialize VirtualSpace");
1012 
1013     vs.expand_by(commit_size, false);
1014 
1015     if (vs.special()) {




 340 VirtualSpace::VirtualSpace() {
 341   _low_boundary           = NULL;
 342   _high_boundary          = NULL;
 343   _low                    = NULL;
 344   _high                   = NULL;
 345   _lower_high             = NULL;
 346   _middle_high            = NULL;
 347   _upper_high             = NULL;
 348   _lower_high_boundary    = NULL;
 349   _middle_high_boundary   = NULL;
 350   _upper_high_boundary    = NULL;
 351   _lower_alignment        = 0;
 352   _middle_alignment       = 0;
 353   _upper_alignment        = 0;
 354   _special                = false;
 355   _executable             = false;
 356 }
 357 
 358 
 359 bool VirtualSpace::initialize(ReservedSpace rs, size_t committed_size) {
 360   const size_t max_commit_granularity = os::largest_page_size_less_than(rs.size());
 361   return initialize_with_granularity(rs, committed_size, max_commit_granularity);
 362 }
 363 
 364 bool VirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t committed_size, size_t max_commit_granularity) {
 365   if(!rs.is_reserved()) return false;  // allocation failed.
 366   assert(_low_boundary == NULL, "VirtualSpace already initialized");
 367   assert(max_commit_granularity > 0, "Granularity must be non-zero.");
 368 
 369   _low_boundary  = rs.base();
 370   _high_boundary = low_boundary() + rs.size();
 371 
 372   _low = low_boundary();
 373   _high = low();
 374 
 375   _special = rs.special();
 376   _executable = rs.executable();
 377 
 378   // When a VirtualSpace begins life at a large size, make all future expansion
 379   // and shrinking occur aligned to a granularity of large pages.  This avoids
 380   // fragmentation of physical addresses that inhibits the use of large pages


 975     case Default:
 976     case Reserve:
 977       return ReservedSpace(reserve_size_aligned);
 978     case Disable:
 979     case Commit:
 980       return ReservedSpace(reserve_size_aligned,
 981                            os::vm_allocation_granularity(),
 982                            /* large */ false, /* exec */ false);
 983     }
 984   }
 985 
 986   static bool initialize_virtual_space(VirtualSpace& vs, ReservedSpace rs, TestLargePages mode) {
 987     switch(mode) {
 988     default:
 989     case Default:
 990     case Reserve:
 991       return vs.initialize(rs, 0);
 992     case Disable:
 993       return vs.initialize_with_granularity(rs, 0, os::vm_page_size());
 994     case Commit:
 995       return vs.initialize_with_granularity(rs, 0, os::largest_page_size_less_than(rs.size()));
 996     }
 997   }
 998 
 999  public:
1000   static void test_virtual_space_actual_committed_space(size_t reserve_size, size_t commit_size,
1001                                                         TestLargePages mode = Default) {
1002     size_t granularity = os::vm_allocation_granularity();
1003     size_t reserve_size_aligned = align_size_up(reserve_size, granularity);
1004 
1005     ReservedSpace reserved = reserve_memory(reserve_size_aligned, mode);
1006 
1007     assert(reserved.is_reserved(), "Must be");
1008 
1009     VirtualSpace vs;
1010     bool initialized = initialize_virtual_space(vs, reserved, mode);
1011     assert(initialized, "Failed to initialize VirtualSpace");
1012 
1013     vs.expand_by(commit_size, false);
1014 
1015     if (vs.special()) {


< prev index next >