alexcrichton opened PR #5683 from remove-store-from-instance-pre
to main
:
This commit relaxes a requirement of the
InstancePre
API, notably its construction viaLinker::instantiate_pre
. Previously this function required aStore<T>
to be present to be able to perform type-checking on the contents of the linker, and now this requirement has been removed.Items stored within a linker are either a
HostFunc
, which has type information inside of it, or anExtern
, which doesn't have type information inside of it. Due to the usage ofExtern
this is why aStore
was required during theInstancePre
construction process, it's used to extract the type of anExtern
. This commit implements a solution where the type information of anExtern
is stored alongside theExtern
itself, meaning that theInstancePre
construction process no longer requires aStore<T>
.One caveat of this implementation is that some items, such as tables and memories, technically have a "dynamic type" where during type checking their current size is consulted to match against the minimum size required of an import. This no longer works when using
Linker::instantiate_pre
as the current size used is the one when it was inserted into the linker rather than the one available at instantiation time. It's hoped, however, that this is a relatively esoteric use case that doesn't impact many real-world users.Additionally note that this is an API-breaking change. Not only is the
Store
argument removed fromLinker::instantiate_pre
, but some other methods such asLinker::define
grew aStore
argument as the type needs to be extracted when an item is inserted into a linker.Closes #5675
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton requested pchickey for a review on PR #5683.
alexcrichton updated PR #5683 from remove-store-from-instance-pre
to main
.
alexcrichton closed without merge PR #5683.
alexcrichton reopened PR #5683 from remove-store-from-instance-pre
to main
.
alexcrichton updated PR #5683 from remove-store-from-instance-pre
to main
.
abrown submitted PR review.
abrown submitted PR review.
abrown created PR review comment:
/// Note that providing a `store` here is not required for correctness
alexcrichton updated PR #5683 from remove-store-from-instance-pre
to main
.
pchickey submitted PR review.
alexcrichton merged PR #5683.
Last updated: Nov 22 2024 at 16:03 UTC