Module bounds_checks

Source
Expand description

Implementation of Wasm to CLIF memory access translation.

Given

  • a dynamic Wasm memory index operand,
  • a static offset immediate, and
  • a static access size,

bounds check the memory access and translate it into a native memory access.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! !!! !!! THIS CODE IS VERY SUBTLE, HAS MANY SPECIAL CASES, AND IS ALSO !!! !!! ABSOLUTELY CRITICAL FOR MAINTAINING THE SAFETY OF THE WASM HEAP !!! !!! SANDBOX. !!! !!! !!! !!! A good rule of thumb is to get two reviews on any substantive !!! !!! changes in here. !!! !!! !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Enumsยง

AddrPcc ๐Ÿ”’
Which facts do we want to emit for proof-carrying code, if any, on address computations?

Functionsยง

bounds_check_and_compute_addr
Helper used to emit bounds checks (as necessary) and compute the native address of a heap access.
cast_index_to_pointer_ty ๐Ÿ”’
compute_addr ๐Ÿ”’
Emit code for the native address computation of a Wasm address, without any bounds checks or overflow checks.
explicit_check_oob_condition_and_compute_addr ๐Ÿ”’
Emit explicit checks on the given out-of-bounds condition for the Wasm address and return the native address.
get_dynamic_heap_bound ๐Ÿ”’
Get the bound of a dynamic heap as an ir::Value.
offset_plus_size ๐Ÿ”’