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