Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Structs and arrays share one cache, the
Exported GC Object cache, which maps an address to its JavaScript wrapper.But in the Core Spec struct addresses and array addresses are separate address spaces (each indexes
its own store component,
structsandarrays),So a struct and an array can have the same address, and the cache, keyed by the address alone, technically cannot tell them apart, since each is just a natural number.
Therefore,
a new Exported GC Objectalgorithm may return a struct's wrapper for an array, or an array's for a struct.For example, with
If these are the first struct and the first array in the store, both would get address 0.
When
makeStruct()returns, converting the struct to JavaScript creates its wrapper and caches it at address 0.When
makeArray()returns, converting the array to JavaScript looks the cache up by address 0, finds the struct's entry, and returns the cached struct's wrapper.This PR splits it into one cache per address space,
and picks the map by
objectkind; the lookups stay keyed by the address:P.S. Alternatives would be keying this cache by the pair (objectkind, objectaddr),
or by the reference value itself (
ref.struct a/ref.array a).I went with separate caches to keep this one consistent with the other caches here,
each of which maps uses single kind of address as a key,
but I'm happy to switch if either is preferred.