From 5b9344a4802fc5736b42a5e427fd456ddb8acf4c Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Fri, 23 Aug 2024 17:58:14 +0300 Subject: [PATCH] Missing sync elements --- EqSat/include/Luau/EGraph.h | 5 ++--- EqSat/include/Luau/Language.h | 7 ------- EqSat/include/Luau/LanguageHash.h | 1 + EqSat/src/UnionFind.cpp | 3 +++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/EqSat/include/Luau/EGraph.h b/EqSat/include/Luau/EGraph.h index 8344b0e5..480aa07d 100644 --- a/EqSat/include/Luau/EGraph.h +++ b/EqSat/include/Luau/EGraph.h @@ -5,7 +5,6 @@ #include "Luau/Id.h" #include "Luau/Language.h" #include "Luau/UnionFind.h" -#include "Luau/VecDeque.h" #include #include @@ -145,7 +144,7 @@ private: /// The hashcons 𝐻 is a map from e-nodes to e-class ids. std::unordered_map hashcons; - VecDeque> worklist; + std::vector> worklist; private: void canonicalize(L& enode) @@ -183,7 +182,7 @@ private: for (Id operand : enode.operands()) get(operand).parents.push_back({enode, id}); - worklist.push_back({enode, id}); + worklist.emplace_back(enode, id); hashcons.insert_or_assign(enode, id); return id; diff --git a/EqSat/include/Luau/Language.h b/EqSat/include/Luau/Language.h index 4aeb6c32..8855d851 100644 --- a/EqSat/include/Luau/Language.h +++ b/EqSat/include/Luau/Language.h @@ -7,7 +7,6 @@ #include "Luau/Variant.h" #include -#include #include #include @@ -233,12 +232,6 @@ struct Language final { } - Language(const Language&) noexcept = default; - Language& operator=(const Language&) noexcept = default; - - Language(Language&&) noexcept = default; - Language& operator=(Language&&) noexcept = default; - int index() const noexcept { return v.index(); diff --git a/EqSat/include/Luau/LanguageHash.h b/EqSat/include/Luau/LanguageHash.h index 7226132c..506f352b 100644 --- a/EqSat/include/Luau/LanguageHash.h +++ b/EqSat/include/Luau/LanguageHash.h @@ -3,6 +3,7 @@ #include #include +#include namespace Luau::EqSat { diff --git a/EqSat/src/UnionFind.cpp b/EqSat/src/UnionFind.cpp index 3c4825be..619c3f47 100644 --- a/EqSat/src/UnionFind.cpp +++ b/EqSat/src/UnionFind.cpp @@ -11,6 +11,7 @@ Id UnionFind::makeSet() Id id{parents.size()}; parents.push_back(id); ranks.push_back(0); + return id; } @@ -32,6 +33,7 @@ Id UnionFind::find(Id id) parents[size_t(id)] = set; id = parent; } + return set; } @@ -47,6 +49,7 @@ void UnionFind::merge(Id a, Id b) std::swap(aSet, bSet); parents[size_t(bSet)] = aSet; + if (ranks[size_t(aSet)] == ranks[size_t(bSet)]) ranks[size_t(aSet)]++; }