-
Notifications
You must be signed in to change notification settings - Fork 319
Add support for the Wasm memory64 proposal
#1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows to share code and state between MemoryType and MemoryTypeBuilder. The type itself is internal to the memory submodule and not part of the public API of the memory type.
The incorrect behavior was that memory64 was true for all memories if the flag was enabled in the Config. This is nonsense since memory64 allows memories to be of either 32-bit or 64-bit and does not turn all memories into 64-bit. Thus, now the translator queries the particular memory type which is the correct behavior.
This was only done to fix bugs with the old and incorrect memory64 query behavior.
The issue was that Wasmi translation handled all 3 parameters to memory.init as i64 type values just like it has to handle all the other memory instructions. However, memory.init is special in that its len and data_src parameters remain i32 types. This is probably because memory64 allows for 64-bit memories and tables but not for 64-bit data and element segments. As of now I do not have an explanation or rational for this but it is what it is.
This is so we can easily re-use it for TableType later.
This is going to be useful later.
|
Since the official Wasm spec testsuite was ported over to Wasm 3.0 and Wasmi does not (yet) support Wasm 3.0 we need to have 2 different Wasm spec testsuite Git submodules in our tree: the main one tracking the most up-to-date state so we keep most tests up-to-date, and another one specifically based on |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1371 +/- ##
==========================================
+ Coverage 70.79% 70.97% +0.18%
==========================================
Files 153 154 +1
Lines 14324 14534 +210
==========================================
+ Hits 10141 10316 +175
- Misses 4183 4218 +35 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I just ran the benchmarks to compare |
Closes #1357.
ToDo
memory64MemoryType,MemoryTypeBuilderandMemorytypes.memory64support for the following instructions:memory.growmemory.sizememory.copymemory.fillmemory.initloadinstructionsmemory64tests.storeinstructionsmemory64tests.loadinstructions to supportptrandoffsetvalues of typei64.storeinstructions to supportptrandoffsetvalues of typei64.table64TableTypeandTabletypes.table64support for the following instructions:table.growtable.sizetable.copytable.filltable.inittable.gettable.setcall_indirectreturn_call_indirectTechnical ToDos
Address32that hasTryFrom<u64>and is infallibly convertible tou64.Load32Atinstead ofConst32<u64>type.Offset16that hasTryFrom<u64>and is infallibly convertible toOffser64Load32Offset16instead ofConst16<u64>type.New Load Instruction Design
Load32andLoad64I32Load8sI32Load8uI32Load16sI32Load16uI64Load8sI64Load8uI64Load16sI64Load16uI64Load32sI64Load32umemoryfield now is optionally appended to the new encoding scheme.offsetasoffset_loand the upper 32-bit ofoffsetasoffset_hi.offset_loandoffset_hiare combined as(offset_hi << 32) | offset_loto formoffset.memoryindex is used.(offset_hi << 32) | offset_lobefore performing the load operation.Example for
Load32.Load64is very similar.Load32AtandLoad64Atptr+offset(address) fits into au32value.0function local constant ifaddressdoes not fit in au32.addresscan only ever not fit in au32ifmemory64is enabled.I32LoadAt8sI32LoadAt8uI32LoadAt16sI32LoadAt16uI64LoadAt8sI64LoadAt8uI64LoadAt16sI64LoadAt16uI64LoadAt32sI64LoadAt32uLoad32Offset16andLoad64Offset16offsetcan be encoded asu16value.I32Load8sOffset16I32Load8uOffset16I32Load16sOffset16I32Load16uOffset16I64Load8sOffset16I64Load8uOffset16I64Load16sOffset16I64Load16uOffset16I64Load32sOffset16I64Load32uOffset16New Store Instruction Design
Store32andStore64memoryfield now is optionally appended to the new encoding scheme.offsetasoffset_loand the upper 32-bit ofoffsetasoffset_hi.offset_loandoffset_hiare combined as(offset_hi << 32) | offset_loto formoffset.memoryindex is used.(offset_hi << 32) | offset_lobefore performing the store operation.I32StoreImm16I32Store8I32Store8ImmI32Store16I32Store16ImmI64StoreImm16I64Store8I64Store8ImmI64Store16I64Store16ImmI64Store32I64Store32ImmExample
Store32Store32AtandStore64Atptr+offset(address) fits into au32value.0function local constant ifaddressdoes not fit in au32.addresscan only ever not fit in au32ifmemory64is enabled.I32StoreAtImm16I32Store8AtImmI32Store16AtImmI64StoreAtImm16I64Store8AtImmI64Store16AtImmI64Store32AtImm16Store32Offset16andStore64Offset16offsetfits into au16value.I32Store8Offset16I32Store8Offset16ImmI32Store16Offset16I32Store16Offset16ImmI64Store8Offset16I64Store8Offset16ImmI64Store16Offset16I64Store16Offset16ImmI64Store16Offset32I64Store16Offset32Imm16