Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[analysis][NFC] Rename makeLeastUpperBound to join and move it to lattice #6035

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

tlively
Copy link
Member

@tlively tlively commented Oct 21, 2023

In general, the operation of taking the least upper bound of two lattice
elements may depend on some state stored in the lattice object rather than in
the elements themselves. To avoid forcing the elements to be larger and more
complicated in that case (by storing a parent pointer back to the lattice), move
the least upper bound operation to make it a method of the lattice rather than
the lattice element. This is also more consistent with where we put e.g. the
compare method.

While we are at it, rename makeLeastUpperBound to join, which is much
shorter and nicer. Usually we avoid using esoteric mathematical jargon like
this, but "join" as a normal verb actually describes the operation nicely, so I
think it is ok in this case.


// Calculates the LUB of this element with some other element and sets
// this element to the LUB in place. Returns true if this element before
// this method call was different than the LUB.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe comment on how the name is a shorthand, as explained in the PR description?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 yes please

// fits with the conception of the stack starting at the top and having
// an infinite bottom, which allows stacks of different height and scope
// to be easily joined.
bool join(Element& self, const Element& other) const noexcept {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Seems a bit weird to call the first element "self" as it implies the instance of the StackLattice class. Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Not sure what better to call them than a and b or something similarly unimaginative, though. Do you have ideas?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Obj-C dev in me quite liked the previous naming of makeLeastUpperBound because it encoded mutability at the function's call site.

Since the first argument always has to match the LUB, maybe we can call it LUB?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the first argument is the LUB at the end of the method, but not necessarily at the beginning. It would be nice to have names that make sense both before and after.

Maybe joinee and joiner?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do this globally as a follow-up.

@tlively
Copy link
Member Author

tlively commented Oct 25, 2023

Merge activity

  • Oct 25, 1:00 PM: @tlively started a stack merge that includes this pull request via Graphite.
  • Oct 25, 1:01 PM: Graphite rebased this pull request as part of a merge.
  • Oct 25, 1:43 PM: @tlively merged this pull request with Graphite.

Base automatically changed from simplify-analyzer to main October 25, 2023 17:00
… lattice

In general, the operation of taking the least upper bound of two lattice
elements may depend on some state stored in the lattice object rather than in
the elements themselves. To avoid forcing the elements to be larger and more
complicated in that case (by storing a parent pointer back to the lattice), move
the least upper bound operation to make it a method of the lattice rather than
the lattice element. This is also more consistent with where we put e.g. the
`compare` method.

While we are at it, rename `makeLeastUpperBound` to `join`, which is much
shorter and nicer. Usually we avoid using esoteric mathematical jargon like
this, but "join" as a normal verb actually describes the operation nicely, so I
think it is ok in this case.
@tlively tlively merged commit 9af7abd into main Oct 25, 2023
13 checks passed
@tlively tlively deleted the join branch October 25, 2023 17:43
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
… lattice (WebAssembly#6035)

In general, the operation of taking the least upper bound of two lattice
elements may depend on some state stored in the lattice object rather than in
the elements themselves. To avoid forcing the elements to be larger and more
complicated in that case (by storing a parent pointer back to the lattice), move
the least upper bound operation to make it a method of the lattice rather than
the lattice element. This is also more consistent with where we put e.g. the
`compare` method.

While we are at it, rename `makeLeastUpperBound` to `join`, which is much
shorter and nicer. Usually we avoid using esoteric mathematical jargon like
this, but "join" as a normal verb actually describes the operation nicely, so I
think it is ok in this case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants