dart-sdk/sdk/lib
Ömer Sinan Ağacan a332c17c50 [dart2wasm] Refactor JSCM typed list class hierarchy
- Add mixins to the implementation classes rather than the base classes.
  This makes `this.member` calls in the mixed-in members direct calls
  and allows inlining.

- Make immutable classes subclasses of mutable classes. This makes sure
  we have one `[]` implementation per typed list type and allows
  inlining `[]`.

- Implement specialized iterators for each typed list. This allows
  unboxed and unchecked iteration of array elements.

# Final class hierarchy:

- `final class JSARrayBufferImpl implements ByteBuffer`:
  The JS `ArrayBuffer` class.

- `final class JSDataViewImpl implements ByteData`:
  The JS `DataView` class.

- `abstract class JSArrayBase implements TypedData`:
  Base class for all typed array classes. Implements common operations
  on the the `DataView` `externref`.

## Array classes

- `_IntListMixin`:
  Implements `List<int>` operations. Declares unchecked getters and
  setters and uses them when possible for performance.

- `_UnmodifiableIntListMixin`:
  Overrides only `get buffer`, `[]=`, and `setRange` to convert a
  `List<int>` implemented with `_IntListMixin` to unmodifiable.

- `JSUint8ArrayImpl extends JSArrayBase with _IntListMixin implements Uint8List`:
  The `Uint8Array` class.

- One class as above for `Int8Array`, `Uint16Array` etc.

- `UnmodifiableJSUint8Array extends JSUint8ArrayImpl with _UnmodifiableIntListMixin implements UnmodifiableUint8ListView`:
  Same as `JSUint8ArrayImpl`, but made immutable with
  `_UnmodifiableIntListMixin`.

- One class as above for the rest of the int arrays.

- `double` classes have the same structure as the `int` classes.

## Iterator classes

To allow fast iteration with `get iterator`, each array class has its
own iterator class. Compared to a generic iterator shared by all
classes, these classes (1) do direct (instead of virtual) and unchecked
(instead of bound checked) calls to read the elements (2) avoid boxing
the `current` elements by having a field with the right non-nullable
type, `int` or `double`.

# Benchmarks

In a benchmark that decodes a 1.3M large protobuf:

- Before: 35.9 seconds.
- After: 3.2 seconds.

(Remaining performance issues in this benchmark are in the
`dart:convert` implementation for JSCM, which I will be optimizing
separately)

Change-Id: I5f29882600c1ca95972e2a62af22b181787cb73a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334465
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-10 16:40:11 +00:00
..
_http Fix a bug where proxy usernames/passwords containing @ were not correctly parsed. 2023-11-03 19:48:42 +00:00
_internal [dart2wasm] Refactor JSCM typed list class hierarchy 2023-11-10 16:40:11 +00:00
_wasm Reland "[dart2wasm] Use DataView in JS typed arrays" 2023-11-09 10:23:31 +00:00
async Remove some now unnecessary casts 2023-10-24 19:09:22 +00:00
cli [vm] Disable dart:cli waitFor by default 2023-09-14 10:08:29 +00:00
collection Unify splay tree iterators and interables constructor argument names. 2023-10-19 14:07:37 +00:00
convert Refer to unnamed constructors in doc comments with '.new' 2023-10-17 14:42:38 +00:00
core Fix bad link in updated docs. 2023-10-20 14:47:26 +00:00
developer [vm/compiler] Tag non-ffi force-optimized functions idempotent. 2023-08-18 18:27:58 +00:00
ffi Revert "[vm/ffi] Optimize @Native calls" 2023-11-03 09:04:24 +00:00
html [vm] Mark NativeFieldWrapperClasses as base 2023-10-31 10:23:12 +00:00
indexed_db web_audio is not part sky_engine 2023-09-14 10:33:17 +00:00
internal Hide the existence of EfficientLengthIterable better. 2023-09-12 11:08:42 +00:00
io Mention detached processes in exitCode doc 2023-11-07 21:56:55 +00:00
isolate Refer to unnamed constructors in doc comments with '.new' 2023-10-17 14:42:38 +00:00
js Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations" 2023-05-02 15:24:18 +00:00
js_interop [dart:js_interop] Add/fix some js_interop helpers 2023-09-23 18:32:59 +00:00
js_interop_unsafe [dart2wasm] Fix various null toExternRef calls for JS interop 2023-11-09 21:58:33 +00:00
js_util [js_util] Make callMethod take an Object method. 2023-03-23 00:23:00 +00:00
math Adding class modifiers to dart:math. 2023-03-13 14:01:26 +00:00
mirrors [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
svg web_audio is not part sky_engine 2023-09-14 10:33:17 +00:00
typed_data Revert "[typed_data] Deprecate unmodifiable views" 2023-10-27 15:22:54 +00:00
vmservice [vm] Pass offset and script uri for expression compilation 2023-10-12 10:22:38 +00:00
web_audio web_audio is not part sky_engine 2023-09-14 10:33:17 +00:00
web_gl web_audio is not part sky_engine 2023-09-14 10:33:17 +00:00
web_sql web_audio is not part sky_engine 2023-09-14 10:33:17 +00:00
analysis_options.yaml [vm/ffi] Support varargs 2023-01-20 10:30:41 +00:00
libraries.json [dart2wasm] Remove stringref target 2023-11-10 09:49:37 +00:00
libraries.yaml [dart2wasm] Remove stringref target 2023-11-10 09:49:37 +00:00
PRESUBMIT.py [sdk/lib] Better presubmit check for libraries.{json,yaml} 2022-01-10 08:26:20 +00:00
vmservice_libraries.json [Core Libraries] Eliminate the fork in the core libraries. 2020-06-16 23:37:36 +00:00
vmservice_libraries.yaml update the tooling to generate libraries.json from libraries.yaml 2021-07-27 23:02:50 +00:00