[code-reflection] RFR: 8337158: Modeling and lowering of switch statement [v13]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Aug 16 14:20:02 UTC 2024
On Fri, 16 Aug 2024 14:07:40 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Add a test case of switch statement model
>> - Runtime tests of switch statement
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 1676:
>
>> 1674:
>> 1675: @Override
>> 1676: public void visitSwitch(JCTree.JCSwitch tree) {
>
> This method seems 90% the same as the one for switch expression, we should try to consolidate. I've left a comment on how to maybe simplify the logic to add a throwing default - let's see where we are after that's addressed.
In particular, this big chunk of code:
for (JCTree.JCCase c : tree.cases) {
...
switch (c.caseKind) {
Seems to be virtually identical for both switch expression and statement, except for _one_ line:
bodies.add(stack.body);
Which is added more lazily in the cases of switch expressions. I'm not super sure as to what is the reason for that discrepancy. If we could somehow eliminate that, at least all this big portion of code could be shared. (and, even if the difference cannot be eliminated, perhaps a shared routine which returns the default body would enable clients to use that as they see fit).
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/211#discussion_r1719907121
More information about the babylon-dev
mailing list