This PR allows "software-bounds-checked" memories and "guard-page-checked" memories to coexist in the same module.
It creates two versions of every memory operation: an unrestricted version (that works with any memory) and a _default32 version (for memories with default page size and i32 indexing).
The unrestricted version calls MEMCHECK_GENERAL, which does a 64-bit software RANGE_CHECK to check that the operation reads/writes within the bounds of the memory.
The _default32 version calls MEMCHECK_DEFAULT32, which is the same as the old MEMCHECK: if the runtime declares WASM_RT_MEMCHECK_GUARD_PAGES, it will do nothing. Otherwise it will do a 32-bit software RANGE_CHECK (which seems to be one less instruction than the 64-bit RANGE_CHECK).
This is a stepping stone to supporting custom-page-sizes (which will need to be software bounds-checked) (#2508).
@sbc100 Did you want to review this one? @shravanrn would prefer to land #2506 and #2507 together, so I was planning to wait until everybody is comfortable with this one before merging either.
(Sequenced behind #2506)
This PR allows "software-bounds-checked" memories and "guard-page-checked" memories to coexist in the same module.
It creates two versions of every memory operation: an unrestricted version (that works with any memory) and a
_default32
version (for memories with default page size and i32 indexing).The unrestricted version calls
MEMCHECK_GENERAL
, which does a 64-bit softwareRANGE_CHECK
to check that the operation reads/writes within the bounds of the memory.The
_default32
version callsMEMCHECK_DEFAULT32
, which is the same as the oldMEMCHECK
: if the runtime declaresWASM_RT_MEMCHECK_GUARD_PAGES
, it will do nothing. Otherwise it will do a 32-bit softwareRANGE_CHECK
(which seems to be one less instruction than the 64-bitRANGE_CHECK
).This is a stepping stone to supporting custom-page-sizes (which will need to be software bounds-checked) (#2508).