[dart2js] Never elide _Enum.index
This ensures that `_Enum.index` is always available for switch strength reduction optimizations. Most real programs use the index of at least one `enum`, so the field is not usually elided. This change makes small tests and benchmarks behave more like real programs where these optimizations happen. Bug: #51657 CoreLibraryReviewExempt: dart2js specific annotation Change-Id: If98e483d7cce265e823fd574565089e328215cca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446481 Reviewed-by: Nate Biggs <natebiggs@google.com> Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
This commit is contained in:
committed by
Commit Queue
parent
5072ac8a47
commit
5492cfd1bc
@@ -136,12 +136,6 @@ class Benchmark extends BenchmarkBase {
|
||||
enum SomeEnum { element }
|
||||
|
||||
void main() {
|
||||
// TODO(http://dartbug.com/51657): dart2js will remove `_Enum.index` in simple
|
||||
// programs that don't appear to use the field. This defeats the enum-switch
|
||||
// optimization that works more reliably in larger programs. Remove this code
|
||||
// that marks `_Enum.index` as used when #51657 is fixed.
|
||||
Expect.equals(0, SomeEnum.element.index);
|
||||
|
||||
final benchmarks = [
|
||||
Benchmark('enum', match_enum.match),
|
||||
Benchmark('int', match_int.match),
|
||||
|
||||
Reference in New Issue
Block a user