JDK-8243393 : Improve ReservedSpace constructor resolution
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-22
  • Updated: 2020-05-04
  • Resolved: 2020-04-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b21Fixed
Related Reports
Relates :  
Relates :  
Description
We have

  ReservedSpace(size_t size, size_t alignment, bool large,
                         char* requested_address = NULL);

and 

  ReservedSpace(size_t size, size_t alignment, bool large, bool executable);

It is way too easy to accidentally get the wrong constructor without getting a build warning. E.g. passing an "address" instead of a char* to the first variant will get me always the second variant, resulting in weird runtime errors later.

This should be less fragile.

Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/647dbb655363 User: coleenp Date: 2020-04-28 11:35:58 +0000
28-04-2020

Sure, I'll take this if the patch is useful to you. I was trying to go further in another direction - to see if the large parameter could be restricted to the things that actually use large pages, but it ran into problems with ambiguity with these constructors: ReservedSpace(size_t size, size_t preferred_page_size = 0); ReservedSpace(size_t size, size_t alignment, bool large, char* requested_address = NULL); And there's a test for random mapping using large pages. It seems to me that knowledge of alignment is sprinkled in way too many places that shouldn't care about it. I see you're working on that.
27-04-2020

Definitely better and would solve my problem. Want to take the issue over? Ultimately I would love to revise some of the ReservedSpace class, it has so many weird angles (like the ambiguous "alignment" parameter - is it for starting address or size? And what is its relationship to the page size?). But that is a big can of worms, and doing it in tiny steps is a good way.
25-04-2020

These extra constructors have always bothered me. Like this? open webrev at http://cr.openjdk.java.net/~coleenp/2020/8243393.01/webrev I was trying to see which memory areas UseLargePages.
24-04-2020