This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate IDs of Wasm things from their names.
Previously, we eagerly generated string names for every Wasm thing, and used that name both as their identity and as their debug name. Now, we clearly separate those concepts: identities are instances of abstract traits such as `FunctionID`, while debug names are `OriginalName`s. Original names are only stored at the definition site, while IDs are used to link definition and use sites. IDs only need to have meaningful `equals` and `hashCode`. This allows to define them as case classes that directly embed `ClassName`s and `MethodName`s (among others), without having to decode them or serialize them. Moreover, since `OriginalName`s are internally represented as UTF-8 strings, we also avoid the cost of decoding and reencoding them when writing binary `.wasm` files. The text writer gets more work to do, but it is not on the performance-sensitive path, so this is not really an issue. For struct field IDs, this change also implies merging field *names* and field *indices*. Since references to fields can now use `FieldID`s as well, it removes a bit of bookkeeping at the `ClassInfo` level. Both instance field indices and method table entry indices are late-bound in the binary emitter. We do not have to eagerly compute them.
- Loading branch information