> Please review this small fix.
> 
> **Problem:**
> 
> G1 only supports region sizes from 1 MiB up to 32 MiB on 32-bit platforms or 
> 512 MiB on 64-bit platforms. However, an invalid value such as `16` is 
> silently adjusted to 1 MiB before the constraint is checked:
> 
> 
> $ java -XX:G1HeapRegionSize=16 -XX:+PrintFlagsFinal -version | grep 
> G1HeapRegionSize
>    size_t G1HeapRegionSize                         = 1048576                  
>                  {product} {command line, ergonomic}
> openjdk version "28-internal" 2027-03-23
> OpenJDK Runtime Environment (build 28-internal-adhoc.zhangyunbo)
> OpenJDK 64-Bit Server VM (build 28-internal-adhoc.zhangyunbo, mixed mode, 
> sharing)
> 
> 
> **Fix:**
> 
> - Move the `G1HeapRegionSize` constraint from `AfterMemoryInit` to 
> `AfterErgo`, so it is checked after GC selection but before the value is 
> adjusted during heap initialization.
> - Keep `0` as the valid ergonomic value and reject non-zero values below 1 
> MiB.
> - Update `MemoryManagement.java` to use the valid minimum value `1m` instead 
> of relying on an invalid value being adjusted.
> 
> **Testing:**
> 
> - gc/arguments:47 passed, 0 failed, 2 skipped
> - tier1:all pass
> - MemoryManagement.java & TestG1HeapRegionSize.java: pass
> 
> 
> $ java -XX:G1HeapRegionSize=16 -version
> G1HeapRegionSize (16) must be greater than or equal to ergonomic heap region 
> minimum size
> Error: Could not create the Java Virtual Machine.
> Error: A fatal exception has occurred. Program will exit.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Yunbo Zhang has updated the pull request incrementally with one additional 
commit since the last revision:

  8311029: Address review comments

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/32749/files
  - new: https://git.openjdk.org/jdk/pull/32749/files/9e6cd385..88834000

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=32749&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=32749&range=01-02

  Stats: 3 lines in 2 files changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/32749.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32749/head:pull/32749

PR: https://git.openjdk.org/jdk/pull/32749

Reply via email to