Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Vicente Romero
On Thu, 20 Apr 2023 16:54:20 GMT, Jan Lahoda wrote: >> could you explain a bit more the relation between `lazyDoEnumSwitch` and >> `doEnumSwitch` because my understanding is that `lazyDoEnumSwitch` is >> invoking `doEnumSwitch` so to me whenever `lazyDoEnumSwitch` is invoked >> there will be a

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Vicente Romero
On Thu, 20 Apr 2023 17:08:10 GMT, Jan Lahoda wrote: >> That's in my upcoming update. > > The startIndex checks are part of this change: > https://github.com/openjdk/jdk/pull/13074/commits/bb59254e409821c9b14287c73a35ebe2dd2cbda9 > > Thanks for the comment! Oh I see, thanks! - PR R

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Tue, 18 Apr 2023 13:43:45 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Re

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Tue, 18 Apr 2023 14:31:46 GMT, Maurizio Cimadamore wrote: >> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 1021: >> >>> 1019: *on patterns in the chosen column, as described above >>> 1020: */ >>> 1021: var grouppedPerRecordC

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Tue, 18 Apr 2023 14:17:02 GMT, Maurizio Cimadamore wrote: >> I've also found an infinite loop with this: >> >> >> class Test { >> sealed interface I0 permits I1, I2 { } >> sealed interface I00 permits I1, I2 { } >> >> sealed interface I1 extends I0, I00 permits B, C { } >>

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Thu, 20 Apr 2023 16:40:31 GMT, Jan Lahoda wrote: >> and regarding checking that `startIndex` should be `>= 0`? shouldn't we >> check for that? > > That's in my upcoming update. The startIndex checks are part of this change: https://github.com/openjdk/jdk/pull/13074/commits/bb59254e409821c9b1

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Tue, 18 Apr 2023 20:24:33 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Reflecti

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Thu, 20 Apr 2023 16:31:33 GMT, Vicente Romero wrote: >> yep I found a similar test case triggering this code > > could you explain a bit more the relation between `lazyDoEnumSwitch` and > `doEnumSwitch` because my understanding is that `lazyDoEnumSwitch` is > invoking `doEnumSwitch` so to me

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Thu, 20 Apr 2023 16:32:33 GMT, Vicente Romero wrote: >> I see, thanks > > and regarding checking that `startIndex` should be `>= 0`? shouldn't we check > for that? That's in my upcoming update. - PR Review Comment: https://git.openjdk.org/jdk/pull/13074#discussion_r1172848770

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Vicente Romero
On Thu, 20 Apr 2023 14:07:01 GMT, Vicente Romero wrote: >> The intent here is to avoid eager initialization of enums - so, until the >> enum is initialized, `lazyDoEnumSwitch` will be used (which, by itself, >> won't compute any results, except the result for `null`), which is then >> replaced

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Vicente Romero
On Thu, 20 Apr 2023 13:41:05 GMT, Jan Lahoda wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 279: >> >>> 277: } >>> 278: >>> 279: private static int lazyDoEnumSwitch(Enum target, int >>> startIndex, Object[] labels, MethodHandles.Lookup lookup, Class

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Wed, 19 Apr 2023 16:45:06 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Reflecti

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Vicente Romero
On Thu, 20 Apr 2023 13:33:17 GMT, Jan Lahoda wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 170: >> >>> 168: } else if (label instanceof EnumDesc enumDesc) { >>> 169: if (target.getClass().isEnum() && >>> 170: ((

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Wed, 19 Apr 2023 15:36:08 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Reflecti

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-20 Thread Jan Lahoda
On Wed, 19 Apr 2023 04:06:00 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Reflecti

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-19 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-19 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-19 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-19 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Vicente Romero
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 14:31:30 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Re

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 13:54:52 GMT, Maurizio Cimadamore wrote: > I've also found an infinite loop with this: I believe this has to do with the fact that the list of pattern is not a set - so we can end up adding the same pattern descriptions over and over. - PR Review Comment: http

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 13:43:17 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Re

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Maurizio Cimadamore
On Tue, 18 Apr 2023 09:13:01 GMT, Jan Lahoda wrote: >> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: >> >> - the pattern matching for switch and record patterns features are made >> final, together with updates to tests. >> - parenthesized patterns are removed.

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Jan Lahoda
On Mon, 17 Apr 2023 11:33:56 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Re

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Jan Lahoda
On Fri, 14 Apr 2023 18:30:56 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with six additional >> commits since the last revision: >> >> - Fixing infinite loop where a binding pattern is replaced with a binding >> pattern for the same type. >> - Reflecti

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Jan Lahoda
On Fri, 14 Apr 2023 16:45:36 GMT, Roger Riggs wrote: >> Well, I'm aware of this, and https://github.com/openjdk/jdk/pull/9779 even >> optimizes the case where the `enumSwitch` only gets enum constants as >> parameters. >> >> And, overall, it is fairly easy to implement, I think I've had at lea

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch [v2]

2023-04-18 Thread Jan Lahoda
> This is the first draft of a patch for JEP 440 and JEP 441. Changes included: > > - the pattern matching for switch and record patterns features are made > final, together with updates to tests. > - parenthesized patterns are removed. > - qualified enum constants are supported for case label