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

2023-12-11 Thread phuchau1989
On Fri, 19 May 2023 12:42:22 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 [v12]

2023-05-19 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

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

2023-05-18 Thread Vicente Romero
On Thu, 18 May 2023 22:22:25 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 [v11]

2023-05-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

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

2023-05-11 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

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

2023-05-04 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

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

2023-04-26 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

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

2023-04-25 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

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

2023-04-25 Thread Maurizio Cimadamore
On Tue, 25 Apr 2023 10:23:11 GMT, Maurizio Cimadamore wrote: >> test/langtools/tools/javac/patterns/Exhaustiveness.java line 1: >> >>> 1: /* >> >> Isn't `Isn't `testCoversType1` the same as `testExhaustiveStatement3` ? > > Some of the tests called `testExhaustiveStatement` do not seem to test

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

2023-04-25 Thread Maurizio Cimadamore
On Tue, 25 Apr 2023 10:22:40 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Reflecting review changes. > > test/langtools/tools/javac/patterns/Exhaustiveness.java line 1: > >> 1: /* > > I

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

2023-04-25 Thread Maurizio Cimadamore
On Tue, 25 Apr 2023 10:33:33 GMT, Maurizio Cimadamore wrote: >> Some of the tests called `testExhaustiveStatement` do not seem to test >> statements at all > > In the two `testXYZExhaustiveIntersection` the class hierarchy seems the same > - can we reuse it across multiple test cases? I see so

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

2023-04-25 Thread Maurizio Cimadamore
On Mon, 24 Apr 2023 15:16:18 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 [v6]

2023-04-25 Thread Maurizio Cimadamore
On Mon, 24 Apr 2023 15:16:18 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 [v6]

2023-04-24 Thread Vicente Romero
On Mon, 24 Apr 2023 15:16:18 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 [v6]

2023-04-24 Thread Vicente Romero
On Mon, 24 Apr 2023 15:16:18 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 [v6]

2023-04-24 Thread Vicente Romero
On Mon, 24 Apr 2023 15:16:18 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 [v6]

2023-04-24 Thread Vicente Romero
On Mon, 24 Apr 2023 15:16:18 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 [v5]

2023-04-24 Thread Vicente Romero
On Mon, 24 Apr 2023 13:08:44 GMT, Jan Lahoda wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 315: >> >>> 313: Object[] labels = resolvedLabels.resolvedLabels; >>> 314: >>> 315: // Dumbest possible strategy >> >> I guess that given that we can'

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

2023-04-24 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

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

2023-04-24 Thread Jan Lahoda
On Fri, 21 Apr 2023 16:49:54 GMT, Vicente Romero wrote: >> Jan Lahoda has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Adding test. >> - Removing redundant continue, as noted on the review. > > src/java.base/share/classes/java/lang/run

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

2023-04-24 Thread Maurizio Cimadamore
On Mon, 24 Apr 2023 12:53:59 GMT, Jan Lahoda wrote: > In this case, as long as the union type could only be present at the top > level (as opposed to e.g. a type of a record component), we could simply > require all components to be covered for union types for exhaustiveness in > `checkCovered

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

2023-04-24 Thread Jan Lahoda
On Mon, 24 Apr 2023 12:05:35 GMT, Maurizio Cimadamore wrote: > > > I believe the exhaustiveness algorithm needs rules for union types, both > > > in javac and in the JLS: > > > ... > > > I would expect the above switch to be exhaustive, since it covers all > > > possible components of the unio

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

2023-04-24 Thread Maurizio Cimadamore
On Mon, 24 Apr 2023 09:05:56 GMT, Rémi Forax wrote: > > I believe the exhaustiveness algorithm needs rules for union types, both in > > javac and in the JLS: > > ... > > I would expect the above switch to be exhaustive, since it covers all > > possible components of the union type. In other wor

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

2023-04-24 Thread Rémi Forax
On Fri, 21 Apr 2023 16:25:04 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 [v5]

2023-04-24 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 16:25:04 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 [v5]

2023-04-21 Thread Vicente Romero
On Fri, 21 Apr 2023 16:25:04 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 [v5]

2023-04-21 Thread Vicente Romero
On Fri, 21 Apr 2023 16:25:04 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 [v4]

2023-04-21 Thread Vicente Romero
On Fri, 21 Apr 2023 10:56:55 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 [v4]

2023-04-21 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 15:34:32 GMT, Rémi Forax wrote: > > Which compiles correctly, but it doesn't look exhaustive to me (because of > > F) ? > > Can you expand a little more, because for me a Z either implement C or D or > both C and D. Please see my latest comment above. I was confused by the

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

2023-04-21 Thread Jan Lahoda
On Fri, 21 Apr 2023 16:08:41 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Replacing use of mutable callsite with a mutable state. > > src/jdk.compiler/share/classes/com/sun/tools/javac/co

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

2023-04-21 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

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

2023-04-21 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 10:56:55 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 [v4]

2023-04-21 Thread Rémi Forax
On Fri, 21 Apr 2023 15:30:24 GMT, Maurizio Cimadamore wrote: >> Also, surprisingly, if I make C and D classes (instead of interfaces): >> >> class Test { >> sealed interface I permits C, D { } >> final class C implements I { } >> final class D implements I { } >> >> interface F

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

2023-04-21 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 15:17:37 GMT, Maurizio Cimadamore wrote: >> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 915: >> >>> 913: */ >>> 914: private List reduceBindingPatterns(Type >>> selectorType, List patterns) { >>> 915: Set existingBindi

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

2023-04-21 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 10:56:55 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 [v4]

2023-04-21 Thread Maurizio Cimadamore
On Fri, 21 Apr 2023 15:16:03 GMT, Maurizio Cimadamore wrote: >> Jan Lahoda has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Replacing use of mutable callsite with a mutable state. > > src/jdk.compiler/share/classes/com/sun/tools/javac/co

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

2023-04-21 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

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 [v3]

2023-04-20 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

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

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-17 Thread Maurizio Cimadamore
On Fri, 17 Mar 2023 12:15:58 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

2023-04-14 Thread Vicente Romero
On Fri, 17 Mar 2023 12:15:58 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

2023-04-14 Thread Roger Riggs
On Fri, 14 Apr 2023 16:36:59 GMT, Jan Lahoda wrote: >> FWIW... an observation from working on >> [JDK-7176515](https://bugs.openjdk.org/browse/JDK-7176515). This is probably >> redundant but here goes anyway. >> >> In the compiler there are currently three different ways of handling enums >>

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread Jan Lahoda
On Fri, 14 Apr 2023 16:10:49 GMT, Archie L. Cobbs wrote: >> FWIW, a sketch on how avoiding the enum initialization might look like is >> here: >> https://github.com/lahodaj/jdk/compare/JDK-8300543...lahodaj:jdk:JDK-8300543-lazy-enum?expand=1 >> >> more work needed to make that work for `typeSwi

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread Archie L . Cobbs
On Thu, 13 Apr 2023 12:07:00 GMT, Jan Lahoda wrote: >> Note that currently, a `switch` over an enum will already trigger  >> initialisation of the enum class because of the need to compute the relevant >> mapping array by the synthetic helper class, see [JDK‑7176515] for details. >> - https://gi

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread Jan Lahoda
On Thu, 13 Apr 2023 10:59:46 GMT, ExE Boss wrote: >> Hi Christian, >> >> Thanks for the comment. >> >> First, the "Dumbest possible strategy" comment should be interpreted as "we >> would like to do something better", not that using something slow is OK >> permanently. There's an attempt to d

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread ExE Boss
On Thu, 13 Apr 2023 07:49:05 GMT, Jan Lahoda wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 1: >> >>> 1: /* >> >> @lahodaj The way that the boostrap method `enumSwitch` and its >> corresponding implementation method `doEnumSwitch` are implemented right now

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread Jan Lahoda
On Wed, 12 Apr 2023 19:47:25 GMT, Christian Wimmer 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 re

Re: RFR: 8300543 Compiler Implementation for Pattern Matching for switch

2023-04-14 Thread Jan Lahoda
On Fri, 17 Mar 2023 12:15:58 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

2023-04-14 Thread Christian Wimmer
On Fri, 17 Mar 2023 12:15:58 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. > -