RFR: 8346107: Generators: testing utility for random value generation [v6]

Theo Weidmann tweidmann at openjdk.org
Wed Jan 8 14:56:47 UTC 2025


On Tue, 7 Jan 2025 14:22:53 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> But what is it good for to draw from a range with no elements? What is supposed to happen then?
>
> Well, it is more about this:
> I want to be able to draw from restricted ranges in the Templates. But the distribution should be random. Maybe the solution is just to make sure that for `Generators.ints`, we always mix in uniform, but at a very low weight. That way, if all other sub-distribution of a mixed distribution fall away (empty), we at least still have the uniform distribution.
> Because if the template wants a range, then we must sample something from that range.
> Does that make sense?

As discussed I have added G.safeRestrict* Methods that will try to call restrict but instead return a uniform generator of the same range in case the restriction is impossible.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22941#discussion_r1907308740


More information about the hotspot-compiler-dev mailing list