Skip to content

Commit 9432d40

Browse files
tlivelyradekdoulik
authored andcommitted
[analysis][NFC] Rename parameters to join and meet methods (WebAssembly#6056)
Since these methods, which operate on lattice elements, moved to the lattice types, it no longer makes much sense for their parameters to be called `self` and `other`. Rename them to `joinee` and `joiner` for joins and `meetee` and `meeter` for meets.
1 parent 342c205 commit 9432d40

File tree

8 files changed

+64
-64
lines changed

8 files changed

+64
-64
lines changed

src/analysis/lattices/bool.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ struct Bool {
3030
LatticeComparison compare(Element a, Element b) const noexcept {
3131
return a > b ? GREATER : a == b ? EQUAL : LESS;
3232
}
33-
bool join(Element& self, Element other) const noexcept {
34-
if (!self && other) {
35-
self = other;
33+
bool join(Element& joinee, Element joiner) const noexcept {
34+
if (!joinee && joiner) {
35+
joinee = joiner;
3636
return true;
3737
}
3838
return false;
3939
}
40-
bool meet(Element& self, Element other) const noexcept {
41-
if (self && !other) {
42-
self = other;
40+
bool meet(Element& meetee, Element meeter) const noexcept {
41+
if (meetee && !meeter) {
42+
meetee = meeter;
4343
return true;
4444
}
4545
return false;

src/analysis/lattices/flat.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ struct Flat {
6969
}
7070
}
7171

72-
bool join(Element& self, const Element& other) const noexcept {
73-
switch (compare(self, other)) {
72+
bool join(Element& joinee, const Element& joiner) const noexcept {
73+
switch (compare(joinee, joiner)) {
7474
case LESS:
75-
self = other;
75+
joinee = joiner;
7676
return true;
7777
case NO_RELATION:
78-
self = Element{Top{}};
78+
joinee = Element{Top{}};
7979
return true;
8080
case GREATER:
8181
case EQUAL:

src/analysis/lattices/int.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ struct Integer {
3838
LatticeComparison compare(Element a, Element b) const noexcept {
3939
return a > b ? GREATER : a == b ? EQUAL : LESS;
4040
}
41-
bool join(Element& self, Element other) const noexcept {
42-
if (self < other) {
43-
self = other;
41+
bool join(Element& joinee, Element joiner) const noexcept {
42+
if (joinee < joiner) {
43+
joinee = joiner;
4444
return true;
4545
}
4646
return false;
4747
}
48-
bool meet(Element& self, Element other) const noexcept {
49-
if (self > other) {
50-
self = other;
48+
bool meet(Element& meetee, Element meeter) const noexcept {
49+
if (meetee > meeter) {
50+
meetee = meeter;
5151
return true;
5252
}
5353
return false;

src/analysis/lattices/inverted.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ template<FullLattice L> struct Inverted {
3737
LatticeComparison compare(const Element& a, const Element& b) const noexcept {
3838
return lattice.compare(b, a);
3939
}
40-
bool join(Element& self, Element other) const noexcept {
41-
return lattice.meet(self, other);
40+
bool join(Element& joinee, Element joiner) const noexcept {
41+
return lattice.meet(joinee, joiner);
4242
}
43-
bool meet(Element& self, Element other) const noexcept {
44-
return lattice.join(self, other);
43+
bool meet(Element& meetee, Element meeter) const noexcept {
44+
return lattice.join(meetee, meeter);
4545
}
4646
};
4747

src/analysis/lattices/lift.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ template<Lattice L> struct Lift {
6060
}
6161
}
6262

63-
bool join(Element& self, const Element& other) const noexcept {
64-
if (self.isBottom() && other.isBottom()) {
63+
bool join(Element& joinee, const Element& joiner) const noexcept {
64+
if (joinee.isBottom() && joiner.isBottom()) {
6565
return false;
66-
} else if (self.isBottom()) {
67-
self = other;
66+
} else if (joinee.isBottom()) {
67+
joinee = joiner;
6868
return true;
69-
} else if (other.isBottom()) {
69+
} else if (joiner.isBottom()) {
7070
return false;
7171
} else {
72-
return lattice.join(*self, *other);
72+
return lattice.join(*joinee, *joiner);
7373
}
7474
}
7575
};

src/analysis/lattices/powerset-impl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ inline size_t FiniteIntPowersetLattice::Element::count() const {
7979
// both sides. We return true if a bit is flipped in-place on the left so the
8080
// worklist algorithm will know if when to enqueue more work.
8181
inline bool
82-
FiniteIntPowersetLattice::join(Element& self,
83-
const Element& other) const noexcept {
82+
FiniteIntPowersetLattice::join(Element& joinee,
83+
const Element& joiner) const noexcept {
8484
// Both must be from powerset lattice of the same set.
85-
assert(other.bitvector.size() == self.bitvector.size());
85+
assert(joiner.bitvector.size() == joinee.bitvector.size());
8686

8787
bool modified = false;
88-
for (size_t i = 0; i < self.bitvector.size(); ++i) {
89-
// Bit is flipped on self only if self is false and other is true when self
90-
// and other are OR'ed together.
91-
modified |= (!self.bitvector[i] && other.bitvector[i]);
92-
self.bitvector[i] = self.bitvector[i] || other.bitvector[i];
88+
for (size_t i = 0; i < joinee.bitvector.size(); ++i) {
89+
// Bit is flipped on joinee only if joinee is false and joiner is true when
90+
// joinee and joiner are OR'ed together.
91+
modified |= (!joinee.bitvector[i] && joiner.bitvector[i]);
92+
joinee.bitvector[i] = joinee.bitvector[i] || joiner.bitvector[i];
9393
}
9494

9595
return modified;

src/analysis/lattices/powerset.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ class FiniteIntPowersetLattice {
8585
// Returns an instance of the bottom lattice element.
8686
Element getBottom() const noexcept;
8787

88-
// Modifies `self` to be the join (aka least upper bound) of `self` and
89-
// `other`. Returns true if `self` was modified, i.e. if it was not already an
90-
// upper bound of `other`.
91-
bool join(Element& self, const Element& other) const noexcept;
88+
// Modifies `joinee` to be the join (aka least upper bound) of `joinee` and
89+
// `joiner`. Returns true if `joinee` was modified, i.e. if it was not already
90+
// an upper bound of `joiner`.
91+
bool join(Element& joinee, const Element& joiner) const noexcept;
9292
};
9393

9494
// A layer of abstraction over FiniteIntPowersetLattice which maps
@@ -150,8 +150,8 @@ template<typename T> class FinitePowersetLattice {
150150

151151
Element getBottom() const noexcept { return intLattice.getBottom(); }
152152

153-
bool join(Element& self, const Element& other) const noexcept {
154-
return intLattice.join(self, other);
153+
bool join(Element& joinee, const Element& joiner) const noexcept {
154+
return intLattice.join(joinee, joiner);
155155
}
156156
};
157157

src/analysis/lattices/stack.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -215,25 +215,25 @@ template<Lattice L> class StackLattice {
215215
}
216216
}
217217

218-
// When taking the LUB, we take the LUBs of the elements of each stack
219-
// starting from the top of the stack. So, LUB([b, a], [b', a']) is
220-
// [LUB(b, b'), LUB(a, a')]. If one stack is higher than the other,
221-
// the bottom of the higher stack will be kept, while the LUB of the
222-
// corresponding tops of each stack will be taken. For instance,
223-
// LUB([d, c, b, a], [b', a']) is [d, c, LUB(b, b'), LUB(a, a')].
218+
// When taking the join, we take the joins of the elements of each stack
219+
// starting from the top of the stack. So, join([b, a], [b', a']) is [join(b,
220+
// b'), join(a, a')]. If one stack is higher than the other, the bottom of the
221+
// higher stack will be kept, while the join of the corresponding tops of each
222+
// stack will be taken. For instance, join([d, c, b, a], [b', a']) is [d, c,
223+
// join(b, b'), join(a, a')].
224224
//
225-
// We start at the top because it makes taking the LUB of stacks with
226-
// different scope easier, as mentioned at the top of the file. It also
227-
// fits with the conception of the stack starting at the top and having
228-
// an infinite bottom, which allows stacks of different height and scope
229-
// to be easily joined.
230-
bool join(Element& self, const Element& other) const noexcept {
225+
// We start at the top because it makes taking the join of stacks with
226+
// different scope easier, as mentioned at the top of the file. It also fits
227+
// with the conception of the stack starting at the top and having an infinite
228+
// bottom, which allows stacks of different height and scope to be easily
229+
// joined.
230+
bool join(Element& joinee, const Element& joiner) const noexcept {
231231
// Top element cases, since top elements don't actually have the stack
232232
// value.
233-
if (self.isTop()) {
233+
if (joinee.isTop()) {
234234
return false;
235-
} else if (other.isTop()) {
236-
self.stackValue.reset();
235+
} else if (joiner.isTop()) {
236+
joinee.stackValue.reset();
237237
return true;
238238
}
239239

@@ -242,18 +242,18 @@ template<Lattice L> class StackLattice {
242242
// Merge the shorter height stack with the top of the longer height
243243
// stack. We do this by taking the LUB of each pair of matching elements
244244
// from both stacks.
245-
auto selfIt = self.stackValue->rbegin();
246-
auto otherIt = other.stackValue->crbegin();
247-
for (; selfIt != self.stackValue->rend() &&
248-
otherIt != other.stackValue->crend();
249-
++selfIt, ++otherIt) {
250-
modified |= lattice.join(*selfIt, *otherIt);
245+
auto joineeIt = joinee.stackValue->rbegin();
246+
auto joinerIt = joiner.stackValue->crbegin();
247+
for (; joineeIt != joinee.stackValue->rend() &&
248+
joinerIt != joiner.stackValue->crend();
249+
++joineeIt, ++joinerIt) {
250+
modified |= lattice.join(*joineeIt, *joinerIt);
251251
}
252252

253-
// If the other stack is higher, append the bottom of it to our current
253+
// If the joiner stack is higher, append the bottom of it to our current
254254
// stack.
255-
for (; otherIt != other.stackValue->crend(); ++otherIt) {
256-
self.stackValue->push_front(*otherIt);
255+
for (; joinerIt != joiner.stackValue->crend(); ++joinerIt) {
256+
joinee.stackValue->push_front(*joinerIt);
257257
modified = true;
258258
}
259259

0 commit comments

Comments
 (0)