RFR: 8342090: Infer::IncorporationBinaryOp::equals can produce side-effects [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Oct 23 10:23:06 UTC 2024


On Wed, 23 Oct 2024 05:22:47 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Type inference uses a cache to store incorporation operations already done. This way we can avoid redoing operations that once done won't produce any change. This can reduce the compilation time when the number of inference variables involved is not trivial. The elements in the cache are implemented with class `com.sun.tools.javac.comp.Infer::IncorporationBinaryOp` the problem here is that the equals method of this class can produce side effects, implying that after a comparison the compared objects can mutate. This patch is fixing this issue,
>> 
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   stress tests

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java line 1276:

> 1274:          */
> 1275:         Type undetVarToTVar(Type t) {
> 1276:             return types.subst(t, ic.undetvars, ic.inferencevars);

Maybe this should be another mapping in the InferenceContext - similar to how we deal with `asInst` ?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21651#discussion_r1812428265


More information about the compiler-dev mailing list