dart-sdk/sdk/lib
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
..
_http [standalone, io] Don't register service extensions in product mode. 2023-08-30 21:46:17 +00:00
_internal [vm, compiler] Add TestRangeInstr. 2023-09-05 19:56:07 +00:00
_wasm [dart2wasm] Fix Wasm{Int,Float}Array.fill value types 2023-08-08 15:27:37 +00:00
async [vm] Treat Future.then(..., onError:...) as catch all handler 2023-08-31 11:47:54 +00:00
cli
collection [lib] Improve IndexedIterable performance on VM 2023-09-06 14:09:11 +00:00
convert
core Remove duplicate doc in Uri.encodeQueryComponent() 2023-08-08 18:11:51 +00:00
developer [vm/compiler] Tag non-ffi force-optimized functions idempotent. 2023-08-18 18:27:58 +00:00
ffi [vm/ffi] Closure callbacks for sync callbacks 2023-08-25 03:35:44 +00:00
html [dart:html] Fix incorrect parameter mention in drawImageScaledFromSource docs 2023-08-23 00:25:29 +00:00
indexed_db/dart2js
internal [lib] Improve IndexedIterable performance on VM 2023-09-06 14:09:11 +00:00
io [standalone, io] Don't register service extensions in product mode. 2023-08-30 21:46:17 +00:00
isolate Mark packageConfigSync and resolvePackageUriSync as released in 3.2 2023-08-22 08:05:19 +00:00
js
js_interop [dart:js_interop] Add JS types for Symbol/BigInt 2023-08-21 21:54:15 +00:00
js_interop_unsafe
js_util
math
mirrors
svg/dart2js
typed_data
vmservice
web_audio/dart2js
web_gl/dart2js
web_sql/dart2js
analysis_options.yaml
libraries.json [dart2wasm] Make implementation libraries part of core to hide internals 2023-08-14 11:09:10 +00:00
libraries.yaml [dart2wasm] Make implementation libraries part of core to hide internals 2023-08-14 11:09:10 +00:00
PRESUBMIT.py
vmservice_libraries.json
vmservice_libraries.yaml