diff options
author | Thomas Lively <tlively@google.com> | 2024-06-18 18:20:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 01:20:49 +0000 |
commit | 2df678e4670517eaac40d1d2d9541d3b706b324b (patch) | |
tree | 3a47da6a20834dad1e43a8953ea428eb12fcb13c /src/tools/wasm-fuzz-lattices.cpp | |
parent | 829e228d4b2ccb314ea1e653fd16154ae3fd31b3 (diff) | |
download | binaryen-2df678e4670517eaac40d1d2d9541d3b706b324b.tar.gz binaryen-2df678e4670517eaac40d1d2d9541d3b706b324b.tar.bz2 binaryen-2df678e4670517eaac40d1d2d9541d3b706b324b.zip |
[threads] Shared basic heap types (#6667)
Implement binary and text parsing and printing of shared basic heap types and
incorporate them into the type hierarchy.
To avoid the massive amount of code duplication that would be necessary if we
were to add separate enum variants for each of the shared basic heap types, use
bit 0 to indicate whether the type is shared and replace `getBasic()` with
`getBasic(Unshared)`, which clears that bit. Update all the use sites to record
whether the original type was shared and produce shared or unshared output
without code duplication.
Diffstat (limited to 'src/tools/wasm-fuzz-lattices.cpp')
-rw-r--r-- | src/tools/wasm-fuzz-lattices.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/tools/wasm-fuzz-lattices.cpp b/src/tools/wasm-fuzz-lattices.cpp index d74bc5148..551ddbaf1 100644 --- a/src/tools/wasm-fuzz-lattices.cpp +++ b/src/tools/wasm-fuzz-lattices.cpp @@ -185,7 +185,7 @@ using LatticeVariant = std::variant<RandomFullLattice, ArrayLattice, Vector<RandomLattice>, TupleLattice, - Shared<RandomLattice>>; + SharedPath<RandomLattice>>; struct RandomLattice::LatticeImpl : LatticeVariant {}; @@ -196,7 +196,7 @@ using LatticeElementVariant = typename ArrayLattice::Element, typename Vector<RandomLattice>::Element, typename TupleLattice::Element, - typename Shared<RandomLattice>::Element>; + typename SharedPath<RandomLattice>::Element>; struct RandomLattice::ElementImpl : LatticeElementVariant {}; @@ -271,7 +271,7 @@ RandomLattice::RandomLattice(Random& rand, size_t depth) : rand(rand) { return; case FullLatticePicks + 5: lattice = std::make_unique<LatticeImpl>( - LatticeImpl{Shared{RandomLattice{rand, depth + 1}}}); + LatticeImpl{SharedPath{RandomLattice{rand, depth + 1}}}); return; } WASM_UNREACHABLE("unexpected pick"); @@ -375,7 +375,7 @@ RandomLattice::Element RandomLattice::makeElement() const noexcept { typename TupleLattice::Element{std::get<0>(l->lattices).makeElement(), std::get<1>(l->lattices).makeElement()}}; } - if (const auto* l = std::get_if<Shared<RandomLattice>>(lattice.get())) { + if (const auto* l = std::get_if<SharedPath<RandomLattice>>(lattice.get())) { auto elem = l->getBottom(); l->join(elem, l->lattice.makeElement()); return ElementImpl{elem}; @@ -489,8 +489,9 @@ void printElement(std::ostream& os, indent(os, depth); os << ")\n"; } else if (const auto* e = - std::get_if<typename Shared<RandomLattice>::Element>(&*elem)) { - os << "Shared(\n"; + std::get_if<typename SharedPath<RandomLattice>::Element>( + &*elem)) { + os << "SharedPath(\n"; printElement(os, **e, depth + 1); indent(os, depth); os << ")\n"; |