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

Upstreaming fns from walrus_ops to walrus #20

Closed
vados-cosmonic opened this issue Oct 5, 2023 · 5 comments
Closed

Upstreaming fns from walrus_ops to walrus #20

vados-cosmonic opened this issue Oct 5, 2023 · 5 comments

Comments

@vados-cosmonic
Copy link
Contributor

vados-cosmonic commented Oct 5, 2023

Hey @guybedford thanks for this awesome project.

I'd want to make use of the code around injecting data and bumping the stack appropriately in a project I'm working on (basically what the project does is modify data segments in an existing wasm module dynamically) and while copying it (with attribution of course) is cool, importing it is even cooler.

To that end, I was wondering if some of the walrus_ops stuff could/should be upstreamed to walrus (or maybe some sort of walrus-extras crate)?

[EDIT] to be clear -- I'd be willing to do the work here, assuming we can figure out a way you'd like to do it!

@guybedford
Copy link
Collaborator

@vados-cosmonic thanks for looking into it. I'm open to upstreaming methods that make sense into Walrus, although we need to be careful to ensure they are as well-defined as possible. That might be a little tricky since the stack bumping technique is based on a lot of assumptions about the shape of the Wasm binary, and to formalize it requires formalizing those assumptions as well. That is, I don't think this is something that can just be copying and pasting the code unfortunately. So not to say no, but to say we need to have some clear guidelines for the process.

@vados-cosmonic
Copy link
Contributor Author

vados-cosmonic commented Oct 6, 2023

Hey thanks for the feedback, this makes sense... So I'll have to be really careful about what's worth even trying to take (if we can find anything that works at all).

How do you feel about the following, they seem somewhat general:

fn name notes
get_memory_id Maybe renamed to something like get_first_memory_id(). I could see this being much less important as multi-memory stuff lands/gains usage
get_exported_func Maybe renamed to get_exported_func_by_name?
add_stub_exported_func Maybe renamed to swap_exported_function? I could see this generalized to take a Fn that builds the function body? Or taking the Function as a whole?
stub_imported_func Same as above
remove_exported_func This could be useful in the general case even though it's very simple... definitely more of a walrus-extras kind of function... Also adding remove_imported_func may make sense of course.

Basically I've included everything but the bumping stuff... But if we know that the bumping work for core modules, preview1 and preview2 (?) then maybe it's fine to just check for only those cases and reject all other cases to be overly cautious?

Really feeling like a walrus-extras makes sense for some of this functionality.

@guybedford
Copy link
Collaborator

This is a really good list, thanks for thinking about what makes the most general sense here.

get_memory_id and get_exported_func both seem absolutely fine and without concern for upstreaming.

Then I wonder if we could replace both add_stub_exported_func and stub_imported_func with a singular replace_function_by_id? One that could take eg some type of builder as input say as well so the stubbing aspect becomes just the null case of that?

Having both ModuleFunctions.remove for both imports and exports also seems like a more general pattern to me as well.

vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 10, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 10, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
@vados-cosmonic
Copy link
Contributor Author

vados-cosmonic commented Oct 10, 2023

Hey @guybedford I've got a little draft PR up if you'd like to take a look -- rustwasm/walrus#248 .

Mostly what I'm wondering about is how we can differentiate in the more general functions between imports and exports... I'd like to use/overload FunctionKind but it doesn't have Export as a variant (and that seems like a much bigger change, since all we're trying to convey is location).

vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 12, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 13, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 13, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 13, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/walrus that referenced this issue Oct 13, 2023
WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>
guybedford pushed a commit to rustwasm/walrus that referenced this issue Oct 14, 2023
* feat: upstream ops from WASI-virt

WASI-virt contains functions that are helpful for manipulating modules
and dealing with exports/imports, which would be helpful to an even
wider group if upstreamed here to walrus.

This commit copies and upstreams some operations that were introduced
in WASI-virt for wider use via walrus.

See also: bytecodealliance/WASI-Virt#20

Signed-off-by: Victor Adossi <[email protected]>

* fix(tests): update WAT used in tests

The excellent pre-existing test suite contains a lot of WAT files as
test-cases that seem to have older syntax in them.

The breakage is introduced because the current test suite runs stable,
latest and nightly versions of Rust while conducting tests. While the
rest of the Wasm toolchain (binaryen, wabt, etc) are hard-coded to versions that should
stay compatible with the WAT as they were written, the upstreaming of
various changes to Rust itself seems to be causing failures when using
the existing WAT for tests.

This PR updates the WAT (mostly operation renaming) that have changed
in order to get tests running again.

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 18, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 19, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 20, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 20, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 20, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
@vados-cosmonic
Copy link
Contributor Author

Changes have been upstreamed to walrus and almost made their way completely in the codebase (#24 ), closing this!

vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20

Signed-off-by: Victor Adossi <[email protected]>
vados-cosmonic added a commit to vados-cosmonic/WASI-Virt that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: bytecodealliance#20
see: rustwasm/walrus#252

Signed-off-by: Victor Adossi <[email protected]>
guybedford pushed a commit that referenced this issue Oct 23, 2023
After the work done upstreaming operations used in `src/walrus_ops.rs`
to walrus, the code for WASI-Virt can be updated to use the new APIs
and reduce custom code.

This commit updates the WASI-Virt codebase to use the upstreamed
functions and adds some light refactors to the more mechanical pieces
of code for stubbing/denying/stripping.

see: #20
see: rustwasm/walrus#252

Signed-off-by: Victor Adossi <[email protected]>
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

No branches or pull requests

2 participants