Stream: git-wasmtime

Topic: wasmtime / Issue #1454 Add a new method Linker::get_expor...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 14:46):

aleksmelnikov opened Issue #1454:

Feature

<!-- What is the feature or code improvement you would like to do in
Cranelift/Wasmtime? -->

I would like to change my code from:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = instance1.get_export("funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

to:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = linker.get_export("env","funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

Benefit

<!-- What is the value of adding this in Cranelift/Wasmtime? -->

Get exports from one source (Linker).

Implementation

<!-- Do you have an implementation plan, and/or ideas for data structures or
algorithms to use? -->

Add a new method Linker::get_export(module,name).

Alternatives

<!-- Have you considered alternative implementations? If so, how are they
better or worse than your proposal? -->

Please, see the existing solution above.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 16:52):

alexcrichton commented on Issue #1454:

Oh one thing I forgot about when originally thinking about this was that you can actually define the same name multiple times for different types. That would make this API a bit more complicated and we might have to solve it via one of two methods:

I think I'd honestly lean towards removing the ability to define the same name twice in the linker under different types. That feels overly complicated and not really necessary for most practical use cases.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 16:52):

alexcrichton labeled Issue #1454:

Feature

<!-- What is the feature or code improvement you would like to do in
Cranelift/Wasmtime? -->

I would like to change my code from:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = instance1.get_export("funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

to:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = linker.get_export("env","funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

Benefit

<!-- What is the value of adding this in Cranelift/Wasmtime? -->

Get exports from one source (Linker).

Implementation

<!-- Do you have an implementation plan, and/or ideas for data structures or
algorithms to use? -->

Add a new method Linker::get_export(module,name).

Alternatives

<!-- Have you considered alternative implementations? If so, how are they
better or worse than your proposal? -->

Please, see the existing solution above.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 16:52):

github-actions[bot] commented on Issue #1454:

Subscribe to Label Action

This issue or pull request has been labeled: "wasmtime:api"

<details> <summary>Users Subscribed to "wasmtime:api"</summary>

</details>

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 17:51):

aleksmelnikov commented on Issue #1454:

Basically, I wouldn't want that changing API will decrease functionality. It seems to me Linker stores function signatures (types). Right? So, theoretically can get a right function.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2020 at 21:25):

alexcrichton commented on Issue #1454:

It's possible, yeah, but we actually wanted behavior like this in Linker before, and I don't really have strong reasons for the complications of allowing one definition per type, so I'd personally be fine at least removing the support.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 03 2020 at 11:17):

aleksmelnikov commented on Issue #1454:

@alexcrichton , I think should be relied on your experience.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 03 2020 at 13:33):

aleksmelnikov edited a comment on Issue #1454:

@alexcrichton , I think should be trust in your experience.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2020 at 17:27):

alexcrichton commented on Issue #1454:

I've made a proposal for an API in https://github.com/bytecodealliance/wasmtime/pull/1480

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2020 at 19:20):

aleksmelnikov commented on Issue #1454:

@alexcrichton , very interesting improvements. Сan't wait to try to work with them. Thank you!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2020 at 23:17):

alexcrichton closed Issue #1454:

Feature

<!-- What is the feature or code improvement you would like to do in
Cranelift/Wasmtime? -->

I would like to change my code from:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = instance1.get_export("funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

to:

    let module1 = Module::from_file(&store, "a.wasm")?;
    let instance1 = linker.instantiate(&module1)?;
    linker.instance("env", &instance1)?;
    let run = linker.get_export("env","funca").and_then(|e| e.func()).unwrap();
    let run = run.get0::<()>()?;
    run()?;

Benefit

<!-- What is the value of adding this in Cranelift/Wasmtime? -->

Get exports from one source (Linker).

Implementation

<!-- Do you have an implementation plan, and/or ideas for data structures or
algorithms to use? -->

Add a new method Linker::get_export(module,name).

Alternatives

<!-- Have you considered alternative implementations? If so, how are they
better or worse than your proposal? -->

Please, see the existing solution above.


Last updated: Dec 23 2024 at 12:05 UTC