dart-sdk/sdk/lib/internal
Vyacheslav Egorov c121db286a [lib] Improve IndexedIterable performance on VM
* Check against raw `EfficientLengthIterable` instead of specifying
  its type parameter. Both checks are equivalent in this context as
  `EfficientLengthIterable` is an internal marker interface and an
  instance of `Iterable<T>` can never be an instance of
  `EfficientLengthIterable` but not an instance of
  `EfficientLengthIterable<T>`.
  VM compiler is currently not good enough to eliminate the
  `is` check if involves an uninstantiated type
  (see https://dartbug.com/53445).
* Force inlining of `IndexedIterable` factory,
  `IndexedIterable.get iterator` and `IterableExtensions.indexed`.

These changes significantly reduce overhead of for-in-indexed
when compared to baseline classical loop: before these changes
for-in-indexed is 13x slower than classical loop, after these
changes it is only 2.8x slower.

Performance comparison was using the following benchmark kernels:

```dart
final list = List<int>.generate(10000, (i) => i);

// For for-in-indexed
var result = 0;
for (var (i, e) in list.indexed) {
  result ^= (i & e);
}

// For classical loop
var result = 0;
for (var i = 0; i < list.length; i++) {
  result ^= (i & list[i]);
}
```

CoreLibraryReviewExempt: No API changes, VM specific optimisations.
Change-Id: Ic935a2aab2eda0837981184d872ee1eeef89ee7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324461
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-06 14:09:11 +00:00
..
async_cast.dart [Core Libraries] Eliminate the fork in the core libraries. 2020-06-16 23:37:36 +00:00
bytes_builder.dart Add class modifiers to dart:_internal. 2023-03-20 13:16:06 +00:00
cast.dart Tighten types on error stream handler to avoid dynamic calls. 2022-05-07 00:24:21 +00:00
errors.dart Remove LateInitializationError. 2021-01-12 20:21:33 +00:00
internal.dart [cfe] Check @patch annotations 2023-06-13 07:27:08 +00:00
internal_sources.gni [cfe] Add support for using backend defined sentinels in late lowering 2020-09-23 08:07:26 +00:00
iterable.dart [lib] Improve IndexedIterable performance on VM 2023-09-06 14:09:11 +00:00
linked_list.dart Make Iterable be the default implementation of itself. 2023-04-04 21:45:19 +00:00
list.dart Add more class modifiers to dart:collection. 2023-04-04 10:39:48 +00:00
lowering.dart [cfe] Add support for using backend defined sentinels in late lowering 2020-09-23 08:07:26 +00:00
patch.dart Make internal/patch.part a part of dart:_internal 2022-09-29 11:52:37 +00:00
print.dart [Core Libraries] Eliminate the fork in the core libraries. 2020-06-16 23:37:36 +00:00
sort.dart Spelling sdk 2022-12-19 22:31:18 +00:00
symbol.dart Clean up unused internal Symbol API. 2021-07-26 17:49:06 +00:00