diff options
author | Alon Zakai <azakai@google.com> | 2021-03-03 19:53:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-03 11:53:26 -0800 |
commit | 11ec03ce930121736655769b9bbccaae0280b64c (patch) | |
tree | 969ca4dc33027f8054789103c908906f5c00cf6c /src/wasm-s-parser.h | |
parent | a5e5be42cf32e0232ef7a4c3bce67c289623eea6 (diff) | |
download | binaryen-11ec03ce930121736655769b9bbccaae0280b64c.tar.gz binaryen-11ec03ce930121736655769b9bbccaae0280b64c.tar.bz2 binaryen-11ec03ce930121736655769b9bbccaae0280b64c.zip |
[Wasm GC] Parse text field names even of types that end up canonicalized together (#3647)
Names of structurally identical types end up "collapsed" together after the
types are canonicalized, but with this PR we can properly read content that
has structurally identical types with different names.
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 9fb9d4389..6ccc7c36c 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -137,6 +137,14 @@ class SExpressionWasmBuilder { std::map<Name, Signature> functionSignatures; std::unordered_map<cashew::IString, Index> debugInfoFileIndices; + // Maps type indexes to a mapping of field index => name. This is not the same + // as the field names stored on the wasm object, as that maps types after + // their canonicalization. Canonicalization loses information, which means + // that structurally identical types cannot have different names. However, + // while parsing the text format we keep this mapping of type indexes to names + // which does allow reading such content. + std::unordered_map<size_t, std::unordered_map<Index, Name>> fieldNames; + public: // Assumes control of and modifies the input. SExpressionWasmBuilder(Module& wasm, Element& module, IRProfile profile); @@ -272,7 +280,7 @@ private: Expression* makeRttCanon(Element& s); Expression* makeRttSub(Element& s); Expression* makeStructNew(Element& s, bool default_); - Index getStructIndex(const HeapType& type, Element& s); + Index getStructIndex(Element& type, Element& field); Expression* makeStructGet(Element& s, bool signed_ = false); Expression* makeStructSet(Element& s); Expression* makeArrayNew(Element& s, bool default_); |