Skip to content

Do not optimize case with null value to switch#6443

Merged
headius merged 2 commits intojruby:jruby-9.2from
headius:no_switch_with_null_case
Oct 21, 2020
Merged

Do not optimize case with null value to switch#6443
headius merged 2 commits intojruby:jruby-9.2from
headius:no_switch_with_null_case

Conversation

@headius
Copy link
Member

@headius headius commented Oct 21, 2020

Optimized Fixnum switch is only possible when we have a case
value and the when values are all int-ranged literal numbers.
The NPE in #6440 was due to us also trying to optimize homogeneous
int case/when even if the case value was null (omitted in source).

This patch limits the optimized switch generation to situations
where we have a non-null case value.

Fixes #6440.

Optimized Fixnum switch is only possible when we have a `case`
value and the `when` values are all int-ranged literal numbers.
The NPE in jruby#6440 was due to us also trying to optimize homogeneous
int case/when even if the case value was null (omitted in source).

This patch limits the optimized switch generation to situations
where we have a non-null `case` value.

Fixes jruby#6440.
@headius headius added this to the JRuby 9.2.14.0 milestone Oct 21, 2020
See jruby#6440 for an example of this situation breaking
homogeneous case optimizations.
@headius headius merged commit 69da94a into jruby:jruby-9.2 Oct 21, 2020
@headius headius deleted the no_switch_with_null_case branch October 21, 2020 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java::JavaLang::NullPointerException () --> JRuby 9.2.13.0 on Windows 10

1 participant