Maybe switch to using views instead of arrays?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start by reading issues #3 and #2, then compare the proposed view heap type and view.convert_array approach with the alternative of using array i8 types. Done requires a decided design for view mutability, conversion semantics, load/store typing, and whether array.convert_view is in scope.
Written by the indexing model from the issue text.
Description
If we were to implement my suggestion for supporting all numeric array types, I thought it could be useful to introduce a new view heap type that could represent untyped binary data, and make the load/store instructions work on view types instead of array types.
To facilitate this, a new instruction along the lines of view.convert_array would need to be added, which converts a numeric array type to a view. The view type would be an immediate subtype of eq and a sibling type to array. There would be both mutable and immutable views, depending on the mutability of the array they were converted from. The view would point to the same underlying memory as the array type it was converted from, and the conversion should be done in constant time.
I feel this has several advantages compared to working with arrays directly:
- If my suggestion for supporting all numeric array types were to be implemented, code may need to branch depending on the array type to use the instruction with the correct immediate type, even though the underlying logic and semantics are the same.
- This would make the binary format simpler, because instead of having a type immediate in the instruction, we could simply reserve another bit in memarg to denote whether the view is mutable or not. This might turn out to not even be necessary, because the semantics could allow for
loadinstructions to work on both mutable and immutable views, andstores would only work on mutable views. - This would also resolve the question regarding 8-bit accesses, because since we would no longer be working with arrays, they would be needed anyway.
- While not strictly necessary for this proposal, we could add another instruction like
array.convert_view, which would complete the loop and effectively allow reinterpret-casting of numeric arrays, e.g.(array (mut f32)) -> (view (mut)) -> (array (mut i32)). This is not currently possible, as the gc proposal does not allow for casting between any two array types. Note that this would not replace the functionality of this proposal: array indexing only supports aligned loads and stores, while this proposal supports unaligned accesses, as well as SIMD load/store instructions with more complicated semantics, e.g.v128.store8_lane,v128.load32x2_u,v128.load16_splat, etc.
If it turns out that adding a new view heap type would be too complicated or would slow down this proposal, we could alternatively continue using the (array i8) and (array (mut i8)) types, and I think most of the advantages I described above would still apply.
Let me know what you think about this @brendandahl.
- Dominant language
- WebAssembly
- Stars
- 4
- Forks
- 1
- Avg merge
- 16h 35m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/multibyte-array-access
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
WebAssembly/multibyte-array-access#8 · 1 comment ·
-
Dart SIMD use case. Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/multibyte-array-access#5 · 8 comments · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/multibyte-array-access#3 · 5 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Text Format Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
WebAssembly/multibyte-array-access#1 · 1 comment ·
All issues in WebAssembly/multibyte-array-access
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
objectionary/jeo-maven-plugin#1774 ·
-
compiler/runtime
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
leanprover/lean4#15255 ·
-
bot-triaged module: correctness (silent) module: fx release triage triage review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Grammar Gap: activated › effect clause › {self} deals damage equal to its power to target creature Openarea:mechanics ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
fil-donadoni/tolaria#4317 ·