1679 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); |
1679 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); |
1680 // We need to fit both the NULL page and the heap into the memory budget, while |
1680 // We need to fit both the NULL page and the heap into the memory budget, while |
1681 // keeping alignment constraints of the heap. To guarantee the latter, as the |
1681 // keeping alignment constraints of the heap. To guarantee the latter, as the |
1682 // NULL page is located before the heap, we pad the NULL page to the conservative |
1682 // NULL page is located before the heap, we pad the NULL page to the conservative |
1683 // maximum alignment that the GC may ever impose upon the heap. |
1683 // maximum alignment that the GC may ever impose upon the heap. |
1684 size_t displacement_due_to_null_page = align_up_(os::vm_page_size(), |
1684 size_t displacement_due_to_null_page = align_up((size_t)os::vm_page_size(), |
1685 _conservative_max_heap_alignment); |
1685 _conservative_max_heap_alignment); |
1686 |
1686 |
1687 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page); |
1687 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page); |
1688 NOT_LP64(ShouldNotReachHere(); return 0); |
1688 NOT_LP64(ShouldNotReachHere(); return 0); |
1689 } |
1689 } |
1690 |
1690 |
2761 const julong max_ThreadStackSize = 1 * M; |
2761 const julong max_ThreadStackSize = 1 * M; |
2762 |
2762 |
2763 const julong min_size = min_ThreadStackSize * K; |
2763 const julong min_size = min_ThreadStackSize * K; |
2764 const julong max_size = max_ThreadStackSize * K; |
2764 const julong max_size = max_ThreadStackSize * K; |
2765 |
2765 |
2766 assert(is_aligned_(max_size, (size_t)os::vm_page_size()), "Implementation assumption"); |
2766 assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption"); |
2767 |
2767 |
2768 julong size = 0; |
2768 julong size = 0; |
2769 ArgsRange errcode = parse_memory_size(tail, &size, min_size, max_size); |
2769 ArgsRange errcode = parse_memory_size(tail, &size, min_size, max_size); |
2770 if (errcode != arg_in_range) { |
2770 if (errcode != arg_in_range) { |
2771 bool silent = (option == NULL); // Allow testing to silence error messages |
2771 bool silent = (option == NULL); // Allow testing to silence error messages |
2776 } |
2776 } |
2777 return JNI_EINVAL; |
2777 return JNI_EINVAL; |
2778 } |
2778 } |
2779 |
2779 |
2780 // Internally track ThreadStackSize in units of 1024 bytes. |
2780 // Internally track ThreadStackSize in units of 1024 bytes. |
2781 const julong size_aligned = align_up_(size, K); |
2781 const julong size_aligned = align_up(size, K); |
2782 assert(size <= size_aligned, |
2782 assert(size <= size_aligned, |
2783 "Overflow: " JULONG_FORMAT " " JULONG_FORMAT, |
2783 "Overflow: " JULONG_FORMAT " " JULONG_FORMAT, |
2784 size, size_aligned); |
2784 size, size_aligned); |
2785 |
2785 |
2786 const julong size_in_K = size_aligned / K; |
2786 const julong size_in_K = size_aligned / K; |
2787 assert(size_in_K < (julong)max_intx, |
2787 assert(size_in_K < (julong)max_intx, |
2788 "size_in_K doesn't fit in the type of ThreadStackSize: " JULONG_FORMAT, |
2788 "size_in_K doesn't fit in the type of ThreadStackSize: " JULONG_FORMAT, |
2789 size_in_K); |
2789 size_in_K); |
2790 |
2790 |
2791 // Check that code expanding ThreadStackSize to a page aligned number of bytes won't overflow. |
2791 // Check that code expanding ThreadStackSize to a page aligned number of bytes won't overflow. |
2792 const julong max_expanded = align_up_(size_in_K * K, (size_t)os::vm_page_size()); |
2792 const julong max_expanded = align_up(size_in_K * K, os::vm_page_size()); |
2793 assert(max_expanded < max_uintx && max_expanded >= size_in_K, |
2793 assert(max_expanded < max_uintx && max_expanded >= size_in_K, |
2794 "Expansion overflowed: " JULONG_FORMAT " " JULONG_FORMAT, |
2794 "Expansion overflowed: " JULONG_FORMAT " " JULONG_FORMAT, |
2795 max_expanded, size_in_K); |
2795 max_expanded, size_in_K); |
2796 |
2796 |
2797 *out_ThreadStackSize = (intx)size_in_K; |
2797 *out_ThreadStackSize = (intx)size_in_K; |