Repository navigation
wasm2c: missing guard force_read error with escape hatch - #2826
Conversation
|
@sbc100 I have split out the change as requested. As noted above, this is a change I definitely want to land and use soon due to the performance implications. |
cebcc4e to
f7b161c
Compare
|
@sbc100 I have updated the commit and description to be a reflect that this is general force_read usage cleanup. Please have a look when you get a chance. |
keithw
left a comment
There was a problem hiding this comment.
This all lgtm, with the understanding that we are going to clean up this forest of preprocessor macros in some future version of wasm2c. :-)
Yup, I think we can start on this incrementally. I think the way to tackle this is probably start the split from macros into a compile time flag one-by-one starting with the guard-page vs bounds-check emission. This is mostly cleanly separable --- the only funny edge case is non-64k wasm memory sizes (the code right not does malloc even if mmap is requested which is very confusing). I'll cleanup the macro version of that first in a separate PR, before we start with splitting things into compile time flags |
This PR ensures that when guard pages are used the force_read macro is either
WASM_RT_NONCONFORMING_ALLOW_OOB_READ_ELIMINATIONrather than silently failing to define it for unknown platforms
This change also allows the embedder to opt to disable force_reads (this is off by default, since it is non conforming). This is independently a performance optimization when Wasm conformance is not required as it speeds up several sandboxing workloads by a large amount
wasm2c is not the first compiler to add the option for an embedder to disable dead reads. Currently Wamr and aWsm enable this by default and don't have a way to disable it, while Wasmer enables it by default and has a switch to disable it. I think wasm2c should remain conformant and not go that far, but it can provide an off-by-default option for this. The actual feature is only about 5 lines so is easy enough to maintain.