richardpringle opened PR #9525 from richardpringle:main
to bytecodealliance:main
:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->Not necessarily trying to get this merged, just using it as an example for my comment here
alexcrichton commented on PR #9525:
What I might recommend for your use case is to store a
TypedFunc<P, R>
within theT
of yourStore<T>
. That'd probably start asOption<TypedFunc<...>>
and beNone
on store construction. After instantiation you'd load the function, set it in the store, and then all your host functions have access to that allocation function.Alternatively if you want the absolute fastest route what I think you'd do is:
- Load a
Module
- Load the export and type-check it manually
- Load the
ModuleExport
- Use
InstancePre
to instantiate quickly- Use the
ModuleExport
to get the exported function- Use
TypedFunc::new_unchecked
with the resulting functionThat front-loads as much as possible at the cost of safety, so I'd recommend using
.get_typed_func
if possible after the initial instantiation of the module.
alexcrichton commented on PR #9525:
(although if you'd like adding the API like in this PR I also think is reasonable!)
richardpringle updated PR #9525.
richardpringle has marked PR #9525 as ready for review.
richardpringle requested alexcrichton for a review on PR #9525.
richardpringle requested wasmtime-core-reviewers for a review on PR #9525.
richardpringle submitted PR review.
richardpringle created PR review comment:
Docs are effectively a copy/paste of
Instance::get_module_export
. Happy to take recommendations or if you want to make a suggestion, I will definitely accept it. I thinksee [Instance::get_module_export] for details
would probably also be fine so long as it's clear that thecaller
has access to the instance (wasn't clear to me without looking at the code).
alexcrichton submitted PR review:
Looks good to me! Mind adding a small smoke test too?
richardpringle updated PR #9525.
richardpringle commented on PR #9525:
Looks good to me! Mind adding a small smoke test too?
@alexcrichton not sure if this is what you meant by a smoke test, but it works as one, haha :sweat_smile: .
richardpringle updated PR #9525.
richardpringle requested alexcrichton for a review on PR #9525.
alexcrichton submitted PR review:
Thanks!
alexcrichton merged PR #9525.
Last updated: Nov 22 2024 at 16:03 UTC