-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2wasm] Add ImmutableWasmArray to dart:_wasm
Dart does not incorporate immutability into it's type system. Though the WasmGC type system does have such a concept: * mutable wasm arrays: they are invariant in the element type * immutable wasm arrays: they are covariant in the element type Currently we use the mutable wasm array types for e.g. const foo = const WasmArray<WasmI32>.literal([0]); which will be compiled to (type $Array<WasmI32> () (array (field (mut i32)))) (global $globalFoo (ref $Array<WasmI32>) (i32.const 0) (array.new_fixed $Array<WasmI32> 1 ) => Notice the **mut** in `array (field (mut i32))` This CL introduces a `ImmutableWasmArray` which is analogous to `WasmArray`. The array supports only reading methods since the contents of the array cannot be modified. Future CLs will make use of this new array type in various places. => This will allow binaryen to optimize things better as it knows the array contents cannot change. => So loads from a (final) global with immutable contents can be folded away at compile time if the index is known at compile-time. NOTE: The `WasmArray`& `ImmutableArray` classes are not related to each other. The reason is that in WasmGC a mutable array isn't a subtype of a immutable array. Change-Id: I3a764b5aaa3ac47827332f3064035133ab01f1b2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392900 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
- Loading branch information
1 parent
a975466
commit a96ad1b
Showing
8 changed files
with
194 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.