RFR: 8279619: [JVMCI] improve EncodedSpeculationReason

Doug Simon dnsimon at openjdk.org
Fri Feb 17 08:25:18 UTC 2023


On Fri, 17 Feb 2023 04:58:27 GMT, Tom Rodriguez <never at openjdk.org> wrote:

>> This PR enhances `jdk.vm.ci.meta.EncodedSpeculationReason.encode` such that the `groupName` parameter is included in the encoding. This mitigates the possibility of 2 unrelated speculation objects having the same hash which, in turn, mitigates the possibility of missing a speculation based optimization opportunity.
>
> src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/EncodedSpeculationReason.java line 64:
> 
>> 62:             encoding = encodingSupplier.get();
>> 63:             encoding.addInt(groupId);
>> 64:             encoding.addInt(groupName.hashCode());
> 
> Why aren't we adding the whole String?  I think we should either add the whole string or update the javadoc to document the current implementation, where the groupName is simply a nice name provided for printing and it's up to the user to provide a stable definitions of group ids.

Adding the whole string won't change much as it is hashed anyway as part of the digest being generated by `encoding`. Adding the whole string also increases the average size of the array returned by `jdk.vm.ci.hotspot.HotSpotSpeculationEncoding.getByteArray()`.

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

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


More information about the hotspot-compiler-dev mailing list