rvolosatovs edited PR #7804.
rvolosatovs edited PR #7804:
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 casecc @alexcrichton
rvolosatovs commented on PR #7804:
@alexcrichton I've studied the
wasmtime_environ
implementation a little bit and looks like I came up with a solution that makes sense (after all types are resolved, "synthesize" aTypeComponent
and store inComponentTypes
onfinish
).I've added a test case reusing the
dynamic::everything
(it does not actually contain everything, but hopefully this is "good enough"). PTAL
rvolosatovs has marked PR #7804 as ready for review.
rvolosatovs requested alexcrichton for a review on PR #7804.
rvolosatovs requested wasmtime-core-reviewers for a review on PR #7804.
rvolosatovs edited a comment on PR #7804:
@alexcrichton I've studied the
wasmtime_environ
implementation a little bit and looks like I came up with a solution that makes sense (after all types are resolved, "synthesize" aTypeComponent
and store inComponentTypes
onfinish
).I've added a test case reusing a big chunk of the
dynamic::everything
component (it does not actually contain everything, but hopefully this is "good enough"). PTAL
rvolosatovs edited a comment on PR #7804:
@alexcrichton I've studied the
wasmtime_environ
implementation a little bit and looks like I came up with a solution that makes sense (after all types are resolved, "synthesize" aTypeComponent
and store inComponentTypes
onfinish
to acquire a type index, which is then propagated further).
I had to also add the type index info to exports, which was missing.I've added a test case reusing a big chunk of the
dynamic::everything
component (it does not actually contain everything, but hopefully this is "good enough"). PTAL
rvolosatovs updated PR #7804.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
This is the main thing that I'm worried about with this PR right now. This means that if a component exports a locally-defined core wasm module and/or a "bag of items" instance then wasmtime will lie and not actually report the export from the type. I think it should be possible to implement this though with some more type-threading-around, however. All the types of all intermediate values are present and accounted for during validation, we just need to pluck it out at the right time and thread it through the system to show up here.
rvolosatovs updated PR #7804.
rvolosatovs updated PR #7804.
rvolosatovs commented on PR #7804:
@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
finish
and for cases where instance type is not assigned yet, that is also done recursively in the same step.
Note that updated test case - I duplicated, for the most part, test cases that were causing panics during development due to type not being available (in particular, the "instance item bag" case)
rvolosatovs edited a comment on PR #7804:
@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
finish
for cases where instance type is not assigned yet, that is also done recursively in the same step.
Note that updated test case - I duplicated, for the most part, test cases that were causing panics during development due to type not being available (in particular, the "instance item bag" case)
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
It appears that we can pluck most of these out, but not for all cases, see updated implementation
rvolosatovs requested alexcrichton for a review on PR #7804.
rvolosatovs updated PR #7804.
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
@alexcrichton I'm getting a bit lost here, is
ty
here the correct type index or is it actually the parent instance type index?
rvolosatovs deleted PR review comment.
rvolosatovs edited a comment on PR #7804:
@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
finish
for cases where instance type is not assigned yet, that is also done recursively in the same step.
Note the updated test case - I duplicated, for the most part, test cases that were causing panics during development due to type not being available (in particular, the "instance item bag" case)
alexcrichton submitted PR review:
Looks great to me, thanks!
alexcrichton merged PR #7804.
Nice work!
Last updated: Dec 23 2024 at 13:07 UTC