RFR: 8364490: Fatal error on large SpecTrapLimitExtraEntries value

Anton Seoane Ampudia aseoane at openjdk.org
Mon Nov 24 15:57:56 UTC 2025


This PR addresses VM crashes on very large values for `SpecTrapLimitExtraEntries`.

The experimental `SpecTrapLimitExtraEntries` allows for a user-specified number of extra method data trap entries for speculation. Currently, this number is implemented with an `int`, which means that users can specify very large values that will translate into huge `MethodData` objects that cannot be allocated in Metaspace.

An `int` range of values should not be allowed, as negative `SpecTrapLimitExtraEntries` do not make any sense, and very high values (such as the ones that cause this crash) are equally nonsensical. This changeset adds a range to the flag values to address these issues.

`SpecTrapLimitExtraEntries` is `MAX`ed with HotSpot's computed heuristic, which means that in any case it can only serve as a buffer above the heuristic. Based on benchmarks where I logged heuristic-derived values for extra `DataLayout` cells, even a value of 50 for `SpecTrapLimitExtraEntries` is more than sufficient. To provide some headroom and keep things simple, I have set the upper limit to 100.

**Testing:** passes tiers 1-2

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

Commit messages:
 - Limit SpecTrapLimitExtraEntries to a sane range

Changes: https://git.openjdk.org/jdk/pull/28451/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28451&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8364490
  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/28451.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28451/head:pull/28451

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


More information about the hotspot-compiler-dev mailing list