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.
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:
- Remove this feature from
Linker
. I'm not honestly sure how useful it is anyway.- Change
Linker::get_export
to something likeLinker::get_func::<(i32, i32), (i32,)>(...)
where you specify types as input.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.
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.
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>
- @peterhuene
</details>
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
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.
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.
aleksmelnikov commented on Issue #1454:
@alexcrichton , I think should be relied on your experience.
aleksmelnikov edited a comment on Issue #1454:
@alexcrichton , I think should be trust in your experience.
alexcrichton commented on Issue #1454:
I've made a proposal for an API in https://github.com/bytecodealliance/wasmtime/pull/1480
aleksmelnikov commented on Issue #1454:
@alexcrichton , very interesting improvements. Сan't wait to try to work with them. Thank you!
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