yurydelendik opened PR #2556 from bug1684861
to main
:
Related isseue https://bugzilla.mozilla.org/show_bug.cgi?id=1684861
There are two parts:
- cranelift/wasm/src/code_translator.rs the logic required for SM to work properly
- rest of it is testing of the broken logic
I don't think it is necessary to check alignment in the
fold_atomic_mem_addr
though it is the only way at this moment to verify/test fix in the wasmtime.Does makes sense for
wasmtime_memory_atomic_
to operate with 64-bit address instead of 32-bit one? But that's different question we have to address.TODO:
- [ ] check for i32 adderss overflow?
yurydelendik requested julian-seward1 for a review on PR #2556.
yurydelendik edited PR #2556 from bug1684861
to main
:
Related isseue https://bugzilla.mozilla.org/show_bug.cgi?id=1684861
There are two parts:
- cranelift/wasm/src/code_translator.rs the logic required for SM to work properly
- rest of it is testing of the broken logic
I don't think it is necessary to check alignment in the
fold_atomic_mem_addr
though it is the only way at this moment to verify/test fix in the wasmtime.Does it make sense for
wasmtime_memory_atomic_
to operate with 64-bit address instead of 32-bit one? But that's different question we have to address.TODO:
- [ ] check for i32 address overflow?
yurydelendik edited PR #2556 from bug1684861
to main
:
Related isseue https://bugzilla.mozilla.org/show_bug.cgi?id=1684861
There are two parts:
- cranelift/wasm/src/code_translator.rs the logic required for SM to work properly
- rest of it is testing of the broken logic
I don't think it is necessary to check alignment in the
fold_atomic_mem_addr
though it is the only way at this moment to verify/test fix in the wasmtime.Does it make sense for
wasmtime_memory_atomic_
to operate with 64-bit address instead of 32-bit one? But that's different question we have to address.TODO:
- [x] check for i32 address overflow?
yurydelendik updated PR #2556 from bug1684861
to main
:
Related isseue https://bugzilla.mozilla.org/show_bug.cgi?id=1684861
There are two parts:
- cranelift/wasm/src/code_translator.rs the logic required for SM to work properly
- rest of it is testing of the broken logic
I don't think it is necessary to check alignment in the
fold_atomic_mem_addr
though it is the only way at this moment to verify/test fix in the wasmtime.Does it make sense for
wasmtime_memory_atomic_
to operate with 64-bit address instead of 32-bit one? But that's different question we have to address.TODO:
- [x] check for i32 address overflow?
alexcrichton submitted PR Review.
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
I figured that we already had a function somewhere in this file to calculate an address, could that perhaps be used instead of duplicating the logic here? That handles things with the guard page and whatnot too to deduplicate checks.
alexcrichton created PR Review Comment:
Due to the relative cost of these functions, could the distinction between local/imported memories be removed to halve the number of intrinsics added?
alexcrichton created PR Review Comment:
Similar to above I figured we'd already have alignment checks somewhere else for other atomic ops
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
In Cranelift memory instructions directlt get an offset as argument, so there is probably no need for such a function.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
I could not find specifically one that combines offsets, I saw only those that calculate a pointer based on memory base.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
yep, I copied a part of the logic from
finalise_atomic_mem_addr
though it calculates a host memory pointer.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
I agree, though I adapted a pattern used by
imported_memory_fill
/imemory_fill
orimported_memory32_grow
/memory32_grow
. Are there plans to do the same with above?
julian-seward1 submitted PR Review.
julian-seward1 created PR Review Comment:
@bjorn3 But for atomic wait/notify, the actual handling code is generated by calling
environ.translate_atomic_wait
etc. And that takes only the final linear memory offset as an argument. There's no way to pass it an additional constant offset as a second arg. Hence we have no option here but to "manually" fold inmemarg.offset
(and adding a second bounds check, sigh.)
julian-seward1 submitted PR Review.
julian-seward1 created PR Review Comment:
@yurydelendik Do any of these tests test the case where the test created in
fold_atomic_mem_addr
fails? I mean, where the checklinear_mem_addr + memarg.offset >= 0x_1_0000_0000u64
? If not, can you add one? If yes, can you add a one-liner comment above each test, to say what case it tests?
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
Indeed. I was reacting to
I figured that we already had a function somewhere in this file to calculate an address
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
yes, line of 18 of the wast tests that
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
Eventually I'd like to get to those and do the same yeah, we did it awhile ago for a few reference types intrinsics but haven't gotten around to fixing things generally.
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
Could raw pointers get passed to the native functions which handle the implementation? The bounds-checking code is so tricky it seems like it'd be best to avoid duplicating it if we can.
julian-seward1 submitted PR Review.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
Yep, raised the related question at https://bugzilla.mozilla.org/show_bug.cgi?id=1684861#c7 (consumer side)
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
Opened https://github.com/bytecodealliance/wasmtime/issues/2561 to address it in the future.
yurydelendik merged PR #2556.
Last updated: Dec 23 2024 at 12:05 UTC