-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: support component type introspection #7804
feat: support component type introspection #7804
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! At a high level this looks pretty good, although there's two parts of this I'd have a comment on. One is that from a component model point of view an instance does not have imports, only exports and their types. In that sense Instance::import_types
is not necessarily a component-model-based primitive here, and that's where Component::imports()
would show up instead. I suspect though that this is critical to your use case, though.
To handle this I might recommend a slightly updated approach. From a Linker
it should be possible to acquire a types::Component
from a component::Component
. This would synthesize the "InstanceType" data internally required to get a Handle
which is more-or-less a glorified resource mapping. That would be a built-in way of asking "If I instantiate this component using this linker what resource would correspond to this import?" (happy to jump on a call to explain this more too)
The second thing is mostly minor API adjustments here and there, but nothing requiring major refactoring, so I'll note those later.
Thanks for the quick response, is this what you mean 56f68d5 ? |
Yep exactly! I'll go over this with a more fine-toothed comb tonight so you can have a review for when you wake up |
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
…s/results Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
56f68d5
to
d48e9f3
Compare
@alexcrichton I've studied the I've added a test case reusing a big chunk of the |
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
7b22dc9
to
a1760af
Compare
@alexcrichton although in our conversation yesterday we discussed that the static module and "instance item bag" case type indexes should be constructed somewhere along the way and thrown out, that did not seem to be the case in all occurrences, therefore in the proposed approach the static module type is "synthesized" from compiled artifacts on |
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
a1760af
to
76c827a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks!
Nice work! |
This allows for embedders to introspect the component type to e.g. construct
Val
s of complex types expected by the components at runtime.Closes #7726
I'll work on adding a simple test once I verify this covers my own use case
cc @alexcrichton