Skip to content

feat: add typed memory accessors to Wasmtime::Memory#601

Open
takahashim wants to merge 1 commit into
bytecodealliance:mainfrom
takahashim:feat-typed-memory-access
Open

feat: add typed memory accessors to Wasmtime::Memory#601
takahashim wants to merge 1 commit into
bytecodealliance:mainfrom
takahashim:feat-typed-memory-access

Conversation

@takahashim
Copy link
Copy Markdown
Contributor

Motivation

Currently, to retrieve an integer value from linear memory, we need to write something like memory.read(out_p, 4).unpack1("l<").
This approach is verbose, difficult to understand, and prone to errors.
Therefore, we want to enable writing memory.read_i32(out_p) instead.

Changes

Introduce paired read/write methods for the WebAssembly numeric types (little-endian):

  • #read_i32 / #write_i32
  • #read_u32 / #write_u32
  • #read_i64 / #write_i64
  • #read_u64 / #write_u64
  • #read_f32 / #write_f32
  • #read_f64 / #write_f64

Out-of-bounds access raises Wasmtime::Error, consistent with #read / #write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant