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 OriginalNames. 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 ClassNames and MethodNames (among others), without having to decode them or serialize them.
Moreover, since OriginalNames 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 FieldIDs 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.
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 areOriginalName
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
andhashCode
. This allows to define them as case classes that directly embedClassName
s andMethodName
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 theClassInfo
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.