< prev index next >

src/share/vm/memory/virtualspace.cpp

Print this page




 485   }
 486 
 487   // Keep heap at HeapBaseMinAddress.
 488   if (_base == NULL) {
 489 
 490     // Try to allocate the heap at addresses that allow efficient oop compression.
 491     // Different schemes are tried, in order of decreasing optimization potential.
 492     //
 493     // For this, try_reserve_heap() is called with the desired heap base addresses.
 494     // A call into the os layer to allocate at a given address can return memory
 495     // at a different address than requested.  Still, this might be memory at a useful
 496     // address. try_reserve_heap() always returns this allocated memory, as only here
 497     // the criteria for a good heap are checked.
 498 
 499     // Attempt to allocate so that we can run without base and scale (32-Bit unscaled compressed oops).
 500     // Give it several tries from top of range to bottom.
 501     if (aligned_heap_base_min_address + size <= (char *)UnscaledOopHeapMax) {
 502 
 503       // Calc address range within we try to attach (range of possible start addresses).
 504       char* const highest_start = (char *)align_ptr_down((char *)UnscaledOopHeapMax - size, attach_point_alignment);
 505       char* const lowest_start  = (char *)align_ptr_up  (        aligned_heap_base_min_address             , attach_point_alignment);
 506       try_reserve_range(highest_start, lowest_start, attach_point_alignment,
 507                         aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, large);
 508     }
 509 
 510     // zerobased: Attempt to allocate in the lower 32G.
 511     // But leave room for the compressed class pointers, which is allocated above
 512     // the heap.
 513     char *zerobased_max = (char *)OopEncodingHeapMax;
 514     const size_t class_space = align_size_up(CompressedClassSpaceSize, alignment);
 515     // For small heaps, save some space for compressed class pointer
 516     // space so it can be decoded with no base.
 517     if (UseCompressedClassPointers && !UseSharedSpaces &&
 518         OopEncodingHeapMax <= KlassEncodingMetaspaceMax &&
 519         (uint64_t)(aligned_heap_base_min_address + size + class_space) <= KlassEncodingMetaspaceMax) {
 520       zerobased_max = (char *)OopEncodingHeapMax - class_space;
 521     }
 522 
 523     // Give it several tries from top of range to bottom.
 524     if (aligned_heap_base_min_address + size <= zerobased_max &&    // Zerobased theoretical possible.
 525         ((_base == NULL) ||                        // No previous try succeeded.




 485   }
 486 
 487   // Keep heap at HeapBaseMinAddress.
 488   if (_base == NULL) {
 489 
 490     // Try to allocate the heap at addresses that allow efficient oop compression.
 491     // Different schemes are tried, in order of decreasing optimization potential.
 492     //
 493     // For this, try_reserve_heap() is called with the desired heap base addresses.
 494     // A call into the os layer to allocate at a given address can return memory
 495     // at a different address than requested.  Still, this might be memory at a useful
 496     // address. try_reserve_heap() always returns this allocated memory, as only here
 497     // the criteria for a good heap are checked.
 498 
 499     // Attempt to allocate so that we can run without base and scale (32-Bit unscaled compressed oops).
 500     // Give it several tries from top of range to bottom.
 501     if (aligned_heap_base_min_address + size <= (char *)UnscaledOopHeapMax) {
 502 
 503       // Calc address range within we try to attach (range of possible start addresses).
 504       char* const highest_start = (char *)align_ptr_down((char *)UnscaledOopHeapMax - size, attach_point_alignment);
 505       char* const lowest_start  = (char *)align_ptr_up(aligned_heap_base_min_address, attach_point_alignment);
 506       try_reserve_range(highest_start, lowest_start, attach_point_alignment,
 507                         aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, large);
 508     }
 509 
 510     // zerobased: Attempt to allocate in the lower 32G.
 511     // But leave room for the compressed class pointers, which is allocated above
 512     // the heap.
 513     char *zerobased_max = (char *)OopEncodingHeapMax;
 514     const size_t class_space = align_size_up(CompressedClassSpaceSize, alignment);
 515     // For small heaps, save some space for compressed class pointer
 516     // space so it can be decoded with no base.
 517     if (UseCompressedClassPointers && !UseSharedSpaces &&
 518         OopEncodingHeapMax <= KlassEncodingMetaspaceMax &&
 519         (uint64_t)(aligned_heap_base_min_address + size + class_space) <= KlassEncodingMetaspaceMax) {
 520       zerobased_max = (char *)OopEncodingHeapMax - class_space;
 521     }
 522 
 523     // Give it several tries from top of range to bottom.
 524     if (aligned_heap_base_min_address + size <= zerobased_max &&    // Zerobased theoretical possible.
 525         ((_base == NULL) ||                        // No previous try succeeded.


< prev index next >