feat: support custom-page-size proposal#8307
feat: support custom-page-size proposal#8307HerrCai0907 wants to merge 5 commits intoWebAssembly:mainfrom
Conversation
kripken
left a comment
There was a problem hiding this comment.
Comments on the first 1/4 or so. Nice work!
|
;; i32 (pagesize 1)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory 0xFFFF_FFFF (pagesize 1)))
"unknown import")
;; i32 (default pagesize)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory 65536 (pagesize 65536)))
"unknown import") |
|
5c7061e can resolve the RAM usage issue, should I split it to another PR? |
|
Hmm, why does that commit fix it? I think the fix might be to use a limit on allocation size. Here is where we do it for GC allocations: binaryen/src/wasm-interpreter.h Lines 2246 to 2250 in 204c3f8 Something similar for memories and tables makes sense to me? |
|
In spec test, they do trick for it. It declare a non-existed import to make the module initialization failure. But in binaryen, we init the memory before analyzing import and export. It will allocate lots of RAM and slow down the whole test. That commit swap the order to let the initialization fast failed. ;;
;; These modules are valid, but instantiating them is unnecessary
;; and would only allocate very large memories and slow down running
;; the spec tests. Therefore, add an invalid import so that it cannot
;; be instantiated and use `assert_unlinkable`. This approach
;; enforces that the module itself is still valid, but that its
;; instantiation fails early (hopefully before any memories are
;; actually allocated).
;; Helper module that exports a non-matching value.
(module
(memory (export "unknown") 0))
(register "test")
;; i32 (pagesize 1)
(assert_unlinkable
(module
(import "test" "unknown" (func))
(memory 0xFFFF_FFFF (pagesize 1)))
"unknown import") |
|
I see, thanks. I still think my suggested fix is better, though - it is consistent with how we handle possible OOMs in other parts of the code, and will automatically work for any new tests added later in the spec? |
|
Both changes sound good to me FWIW. Based on the test and the spec here: , we are free to check imports before initializing the memory (which is all that |
I think that imports should always be checked before initializing memory, regardless of this PR. Limiting the max ram is also reasonable. But maybe we could focus on custom page size proposal in this PR firstly. Personally I prefer to create a new PR for the latest commit (order of import checking and memory initializing), WDYT? |

custom page size proposal
Fixed: #6873
Original PR: #7694