< prev index next >

src/hotspot/share/memory/virtualspace.cpp

Print this page

 512     // For this, try_reserve_heap() is called with the desired heap base addresses.
 513     // A call into the os layer to allocate at a given address can return memory
 514     // at a different address than requested.  Still, this might be memory at a useful
 515     // address. try_reserve_heap() always returns this allocated memory, as only here
 516     // the criteria for a good heap are checked.
 517 
 518     // Attempt to allocate so that we can run without base and scale (32-Bit unscaled compressed oops).
 519     // Give it several tries from top of range to bottom.
 520     if (aligned_heap_base_min_address + size <= (char *)UnscaledOopHeapMax) {
 521 
 522       // Calc address range within we try to attach (range of possible start addresses).
 523       char* const highest_start = align_down((char *)UnscaledOopHeapMax - size, attach_point_alignment);
 524       char* const lowest_start  = align_up(aligned_heap_base_min_address, attach_point_alignment);
 525       try_reserve_range(highest_start, lowest_start, attach_point_alignment,
 526                         aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, page_size);
 527     }
 528 
 529     // zerobased: Attempt to allocate in the lower 32G.
 530     // But leave room for the compressed class pointers, which is allocated above
 531     // the heap.




 532     char *zerobased_max = (char *)OopEncodingHeapMax;
 533     const size_t class_space = align_up(CompressedClassSpaceSize, alignment);
 534     // For small heaps, save some space for compressed class pointer
 535     // space so it can be decoded with no base.
 536     if (UseCompressedClassPointers && !UseSharedSpaces &&
 537         OopEncodingHeapMax <= KlassEncodingMetaspaceMax &&
 538         (uint64_t)(aligned_heap_base_min_address + size + class_space) <= KlassEncodingMetaspaceMax) {
 539       zerobased_max = (char *)OopEncodingHeapMax - class_space;
 540     }
 541 
 542     // Give it several tries from top of range to bottom.
 543     if (aligned_heap_base_min_address + size <= zerobased_max &&    // Zerobased theoretical possible.
 544         ((_base == NULL) ||                        // No previous try succeeded.
 545          (_base + size > zerobased_max))) {        // Unscaled delivered an arbitrary address.
 546 
 547       // Calc address range within we try to attach (range of possible start addresses).
 548       char *const highest_start = align_down(zerobased_max - size, attach_point_alignment);
 549       // Need to be careful about size being guaranteed to be less
 550       // than UnscaledOopHeapMax due to type constraints.
 551       char *lowest_start = aligned_heap_base_min_address;

 512     // For this, try_reserve_heap() is called with the desired heap base addresses.
 513     // A call into the os layer to allocate at a given address can return memory
 514     // at a different address than requested.  Still, this might be memory at a useful
 515     // address. try_reserve_heap() always returns this allocated memory, as only here
 516     // the criteria for a good heap are checked.
 517 
 518     // Attempt to allocate so that we can run without base and scale (32-Bit unscaled compressed oops).
 519     // Give it several tries from top of range to bottom.
 520     if (aligned_heap_base_min_address + size <= (char *)UnscaledOopHeapMax) {
 521 
 522       // Calc address range within we try to attach (range of possible start addresses).
 523       char* const highest_start = align_down((char *)UnscaledOopHeapMax - size, attach_point_alignment);
 524       char* const lowest_start  = align_up(aligned_heap_base_min_address, attach_point_alignment);
 525       try_reserve_range(highest_start, lowest_start, attach_point_alignment,
 526                         aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, page_size);
 527     }
 528 
 529     // zerobased: Attempt to allocate in the lower 32G.
 530     // But leave room for the compressed class pointers, which is allocated above
 531     // the heap.
 532     // Note Lilliput: the advantages of this strategy were questionable before
 533     //  (since CDS=off + Compressed oops + heap large enough to suffocate us out of lower 32g
 534     //  is rare) and with Lilliput the encoding range drastically shrank. We may just do away
 535     //  with this altogether.
 536     char *zerobased_max = (char *)OopEncodingHeapMax;
 537     const size_t class_space = align_up(CompressedClassSpaceSize, alignment);
 538     // For small heaps, save some space for compressed class pointer
 539     // space so it can be decoded with no base.
 540     if (UseCompressedClassPointers && !UseSharedSpaces &&
 541         OopEncodingHeapMax <= KlassEncodingMetaspaceMax &&
 542         (uint64_t)(aligned_heap_base_min_address + size + class_space) <= KlassEncodingMetaspaceMax) {
 543       zerobased_max = (char *)OopEncodingHeapMax - class_space;
 544     }
 545 
 546     // Give it several tries from top of range to bottom.
 547     if (aligned_heap_base_min_address + size <= zerobased_max &&    // Zerobased theoretical possible.
 548         ((_base == NULL) ||                        // No previous try succeeded.
 549          (_base + size > zerobased_max))) {        // Unscaled delivered an arbitrary address.
 550 
 551       // Calc address range within we try to attach (range of possible start addresses).
 552       char *const highest_start = align_down(zerobased_max - size, attach_point_alignment);
 553       // Need to be careful about size being guaranteed to be less
 554       // than UnscaledOopHeapMax due to type constraints.
 555       char *lowest_start = aligned_heap_base_min_address;
< prev index next >