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

Generalize StableHashingContext as a trait #53084

Open
brunocodutra opened this issue Aug 5, 2018 · 0 comments
Open

Generalize StableHashingContext as a trait #53084

brunocodutra opened this issue Aug 5, 2018 · 0 comments
Labels
A-const-eval Area: constant evaluation (mir interpretation) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@brunocodutra
Copy link
Contributor

Background

PR #52475 improves the infinite loop detection algorithm during compile time evaluation, the algorithm relies on HashStable to detect whether two evaluation contexts are potentially identical as an optimization to avoid unnecessarily cloning the entire evaluation context.

The Problem

The current implementation of HashStable throughout the compiler relies on a hashing context represented by StableHashingContext. This context however provides no way to resolve AllocIds to Allocations, so the implementation of HashStable for AllocId relies on the
global TyCtxt::alloc_map, thus bypassing the current transient allocations in Memory. This has the inconvenient side effect of increasing the probability of hash conflicts, thus increasing the probability of unnecessarily cloning the evaluation context.

The Solution

@oli-obk suggested StableHashingContext could be generalized as a trait that could be implemented for Memory, which would provide a way to directly resolve AllocIds.

@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-eval Area: constant evaluation (mir interpretation) labels Jan 27, 2019
@Enselic Enselic added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: constant evaluation (mir interpretation) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants