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

change TypingMode to use pointer tagging #133336

Closed
lcnr opened this issue Nov 22, 2024 · 1 comment
Closed

change TypingMode to use pointer tagging #133336

lcnr opened this issue Nov 22, 2024 · 1 comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 22, 2024

Right now TypingMode has a size of 16 bytes, which, given that we use it a lot of queries and in the global trait solver caches, results in a small, but noticeable perf cost. We should be able to convert it use a tagged pointer instead, copying the impl of GenericArg

struct TypingMode<'tcx> {
    ptr: NonNull<()>,
    marker: PhantomData<&'tcx ty::List<DefId>>,
}

enum TypingModeKind<'tcx> {
     Coherence,
     Analysis {
        defining_opaque_types: I::DefiningOpaqueTypes,
    },
    PostAnalysis,
}

impl<'tcx> TypingModeKind<'tcx> {
     fn pack(self) -> TypingMode<'tcx> {
          match self {
               Coherence => TypingMode { ptr: 0x1 },
               PostAnalysis => TypingMode { ptr: 0x2 },
              Analysis { defining_opaque_types } => TypingMode { ptr: defining_opaque_types },
          }
     }
}
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 22, 2024
@lcnr lcnr added C-cleanup Category: PRs that clean code up or issues documenting cleanup. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 22, 2024
@fmease fmease added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 25, 2024
@lcnr
Copy link
Contributor Author

lcnr commented Nov 28, 2024

realized that this is not going to work once we add all the typing modes we need 😅 better idea: just intern typing_mode

@lcnr lcnr closed this as completed Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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