-
Notifications
You must be signed in to change notification settings - Fork 51
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
Correctly handle padding in JS2 #660
Correctly handle padding in JS2 #660
Conversation
This fixes rust-diplomat#656 but not rust-diplomat#657 The scalarpair struct part of the second test happens to pass since rust-diplomat#657 is only relevant for argument passing
Partially handles rust-diplomat#657
Forgot to handle end-padding .Done now. |
f9f623c
to
6871dc1
Compare
|
||
assertValue() { | ||
let functionCleanupArena = new diplomatRuntime.CleanupArena(); | ||
wasm.ScalarPairWithPadding_assert_value(...this._intoFFI()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: the WASM ABI expects a padding zero for every byte, not just for every i32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The padding fields can have different sizes, ranging from i8 to i32, based on the preceding field. That's what the first half of this PR fixes.
// There's no padding needed | ||
(0 | 1, _) => ForcePaddingStatus::NoForce, | ||
// Non-structs don't care | ||
_ if !matches!(&field.ty, &hir::Type::Struct(_)) => ForcePaddingStatus::NoForce, | ||
// 2-field struct contained in 2-field struct, caller decides | ||
(2, 2) => { | ||
needs_force_padding = true; | ||
ForcePaddingStatus::PassThrough | ||
} | ||
// Outer struct has > 3 fields, always pad | ||
(2, 3..) => ForcePaddingStatus::Force, | ||
// Larger fields will always have padding anyway | ||
_ => ForcePaddingStatus::NoForce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought: Wow, very specific rules. I trust this is the result of your research
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah
This PR:
It also generally cleans up the padding code and makes it reusable.