Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward Compatibility #7

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Backward Compatibility #7

wants to merge 2 commits into from

Conversation

martin-fink
Copy link
Collaborator

@martin-fink martin-fink commented May 31, 2023

This is a draft PR. Make sure to also check out the custom_sections branch in the wasm-tools repo.

Parse a custom section that replaces instructions with other instructions.
This is a bit hacky, but it's a quick way to prototype backward compatibility.

The custom section has the name mem-safety and is structured in the following way:

(pos len instruction)*

where pos is 64 bits (little endian) and len is a 64 bit leb128 encoded integer, and instruction the encoded instruction (variable length).

  • pos is the offset of the instruction(s) that should be replaced
  • len is the number of instructions that should be replaced

See the following example:

  (func (export "foo") (result i32)
        (local $ptr i64)
        (i64.const 0)
        (i64.const 16)
        ;; pos = 0x3D
        drop
        (local.tee $ptr)
        (i32.const 42)
        (i32.store)

        (local.get $ptr)
        (i32.load)

        (local.get $ptr)
        (i64.const 0)
        (i64.const 16)
        ;; pos = 0x50
        drop
        drop
        drop
        (return)
  )

Hexdump of the custom section:

;; pos                       len   inst
    3D 00 00 00 00 00 00 00  01    FA 02 00 00
    50 00 00 00 00 00 00 00  03    FA 03 00 00          

martin-fink pushed a commit that referenced this pull request Nov 21, 2023
* Change the `len` parameter of `fadvise` to `filesize`.

Fadvise can apply to regions of files larger than the linear memory
address space, so it wants a `filesize` (which is u64) rather than a
`size` (which is u32 on wasm32).

* Update the host implementation accordingly.
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