WebAssembly / interface-types

Other
641 stars 57 forks source link

Instructions #80

Closed fgmccabe closed 4 years ago

fgmccabe commented 4 years ago

Started a document intended to act as a cheat sheet of introduced adapter instructions.

fgmccabe commented 4 years ago

On Mon, Oct 28, 2019 at 10:52 AM Jacob Gravelle notifications@github.com wrote:

@jgravelle-google approved this pull request.

Looks generally good, agree this is a useful reference to have

In proposals/interface-types/working-notes/instr.md https://github.com/WebAssembly/interface-types/pull/80#discussion_r339703537 :

+| s64-to-i32x | u64 .. => i32 .. | Map signed 64 bit to i32, error if overflow | +| s8-to-i64 | s8 .. => i64 .. | Map signed 8 bit to i64 | +| u8-to-i64 | u8 .. => i64 .. | Map unsigned 8 bit to i64 | +| s16-to-i64 | s16 .. => i64 .. | Map signed 16 bit to i64 | +| u16-to-i64 | u16 .. => i64 .. | Map unsigned 16 bit to i64 | +| s32-to-i64 | s32 .. => i64 .. | Map signed 32 bit to i64 | +| u32-to-i64 | u32 .. => i64 .. | Map unsigned 32 bit to i64 | +| s64-to-i64 | s64 .. => i64 .. | Map signed 64 bit to i64 | +| u64-to-i64 | u64 .. => i64 .. | Map unsigned 64 bit to i64 | + + +### pack and unpack + +These instructions construct and deconstruct records into their constituent parts. + +| | |

Missing a | which messes up the rendering

Will fix.


In proposals/interface-types/working-notes/instr.md https://github.com/WebAssembly/interface-types/pull/80#discussion_r339707116 :

+| i64-to-s8 | i64 .. => s8 .. | Lift least significant 8 bits as signed 8 bit integer | +| i64-to-s8x | i64 .. => s8 .. | Lift ls 8 bits as signed 8 bit integer, error if more than 7 bits significant | +| i64-to-u8 | i64 .. => u8 .. | Lift least significant 8 bits as unsigned 8 bit integer | +| i64-to-s16 | i64 .. => s16 .. | Lift least significant 16 bits as signed 16 bit integer | +| i64-to-s16x | i64 .. => s16 .. | Lift least significant 16 bits as signed 16 bit integer, error if more than 15 bits significant | +| i64-to-u16 | i64 .. => u16 .. | Lift least significant 16 bits as unsigned 16 bit integer | +| i64-to-s32 | i64 .. => s32 .. | Lift i64 to signed 32 bit integer | +| i64-to-s32x | i64 .. => s32 .. | Lift i64 to signed 32 bit integer, error if more than 31 bits significant | +| i64-to-u32 | i64 .. => u32 .. | Lift i64 to unsigned 32 bit integer | +| i64-to-s64 | i64 .. => s64 .. | Lift i64 to signed 64 bit integer, with sign extension | +| i64-to-u64 | i64 .. => u64 .. | Lift i64 to unsigned 64 bit integer, zero filled | + + +| | | | +| ----- | ----------- | ---------- | +| s8-to-i32 | s8 .. => i32 .. | Map signed 8 bit to i32 |

Does this sign-extend the top 24 bits, or zero them?

The idea (in my head anyway) is that s8-to-xx sign extends whereas u8-to-i32 does not.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WebAssembly/interface-types/pull/80?email_source=notifications&email_token=AAQAXUDP4JGOLZUCAYRSRRLQQ4REFA5CNFSM4JFKIYU2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCJODGVI#pullrequestreview-308032341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQAXUFAFWRGLN7EW4YR4RLQQ4REFANCNFSM4JFKIYUQ .

-- Francis McCabe SWE

fgmccabe commented 4 years ago

On Mon, Oct 28, 2019 at 11:11 AM Luke Wagner notifications@github.com wrote:

@lukewagner commented on this pull request.

Seems like a good idea to have a big list, kinda like the one for core wasm https://webassembly.github.io/spec/core/appendix/index-instructions.html

In proposals/interface-types/working-notes/instr.md https://github.com/WebAssembly/interface-types/pull/80#discussion_r339716598 :

@@ -0,0 +1,87 @@ +# Interface Type Instructions + +## Lifting and lowering + +### ixx-to-sxx + +The numeric lifting and lowering instructions map between WASM's view of numbers and IT's view of numbers. + + +| | | | +| ----- | ----------- | ---------- | +| i32-to-s8 | i32 .. => s8 .. | Lift least significant 8 bits as signed 8 bit integer | +| i32-to-s8x | i32 .. => s8 .. | Lift least 8 bits as signed 8 bit integer, error if more than 7 bits significant |

I don't recall discussing this x-suffixed variant before. I'm not necessarily opposed, or anything, but, I'm still a little confused; it seems like the goal is to trap instead of silently ignoring bits. Two thoughts/questions:

  • shouldn't there by x-suffixed variants for both s8 and u8? (I only see the former)
  • x as a suffix seems vaguely suggestive of "extend", maybe t for "trapping"?

x was meant to suggest exceptional :) How about 'v' for 'verify'?

We did not discuss this directly. I am leaving a bit of space here too: whether to trap or to throw an exception. My preference is actually for the latter (with trap being the result if there is no exception handler in scope)

I did wonder about the unsigned case. Except that it is kind of arbitrary to assume semantics for any particular bit pattern in the unsigned case. (trap on non-zero?)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WebAssembly/interface-types/pull/80?email_source=notifications&email_token=AAQAXUAHOT3CDFGGRJDLKPLQQ4TNBA5CNFSM4JFKIYU2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCJOHMUI#pullrequestreview-308049489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQAXUGEMKWOKBHOCTMDQPTQQ4TNBANCNFSM4JFKIYUQ .

-- Francis McCabe SWE