Skip to content

change TypingMode to use pointer tagging #133336

Closed
@lcnr

Description

@lcnr

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 },
          }
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions