fitzgen opened PR #10401 from fitzgen:drc-transitive-dec-ref
to bytecodealliance:main
:
Previously, the DRC collector only performed shallow reference counting where if an object's ref count was decremented and reached zero, then we would deallocate that object, but we would not decrement the reference counts of any other object that was referenced by it. This commit changes that, so that now we will decrement the reference counts of other objects referenced by an object that is being deallocated.
This requires some method of tracing an object's outgoing edges. To avoid needing to keep around and dispatch upon type-specific information about which struct fields are GC references, for example, we instead pack all GC references at the start of the object, just after its header. We additionally keep a count of how many GC references an object has in its header. This allows us to create a slice of any object's GC references, and we can uniformly trace any GC object's outgoing edges. We don't need to reflect on the GC object's actual type.
A final detail: the DRC collector was previously storing the object size in the common GC header's reserved bits. It now stores the number of GC refs there instead, and the object size is stored in its own field in the DRC-specific header, next to the ref count. This is nice because, since we are making the DRC header larger anyways, it raises the DRC collector's implementation limit on object size from
u27::MAX
tou32::MAX
.Fixes #9701
<!--
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
-->
fitzgen requested pchickey for a review on PR #10401.
fitzgen requested wasmtime-core-reviewers for a review on PR #10401.
pchickey submitted PR review.
fitzgen updated PR #10401.
fitzgen updated PR #10401.
fitzgen has enabled auto merge for PR #10401.
fitzgen updated PR #10401.
github-actions[bot] commented on PR #10401:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen updated PR #10401.
fitzgen updated PR #10401.
fitzgen updated PR #10401.
fitzgen has enabled auto merge for PR #10401.
fitzgen merged PR #10401.
Last updated: Apr 17 2025 at 00:13 UTC