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

internal: Build source map for hir_def::TypeRefs #18074

Merged
merged 7 commits into from
Oct 28, 2024

Commits on Oct 25, 2024

  1. Build source map for hir_def::TypeRefs

    So that given a `TypeRef` we will be able to trace it back to source code.
    
    This is necessary to be able to provide diagnostics for lowering to chalk tys, since the input to that is `TypeRef`.
    
    This means that `TypeRef`s now have an identity, which means storing them in arena and not interning them, which is an unfortunate (but necessary) loss but also a pretty massive change. Luckily, because of the separation layer we have for IDE and HIR, this change never crosses the IDE boundary.
    ChayimFriedman2 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    89c0ffa View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1fae57f View commit details
    Browse the repository at this point in the history
  3. Reuse empty GenericParams

    This saves back 15mb that went for typeref source maps.
    ChayimFriedman2 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    39747cb View commit details
    Browse the repository at this point in the history
  4. Shrink ItemTreeSourceMaps

    This saves 16mb on `analysis-stats .`.
    ChayimFriedman2 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    d0933cc View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    bccf006 View commit details
    Browse the repository at this point in the history
  6. Shrink Path to 16 bytes

    Thanks to the observation (supported by counting) that the vast majority paths have neither generics no type anchors, and thanks to a new datastructure `ThinVecWithHeader` that is essentially `(T, Box<[U]>)` but with the size of a single pointer, we are able to reach this feat.
    
    This (together with `ThinVecWithHeader`) makes the possibility to shrink `TypeRef`, because most types are paths.
    ChayimFriedman2 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    061e5d7 View commit details
    Browse the repository at this point in the history
  7. Shrink TypeRef from 16 from 32 bytes

    Only references and arrays need to be boxed, and they comprise only 9.4% of the types (according to counting on r-a's code).
    
    This saves 17mb.
    ChayimFriedman2 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    bf7edd3 View commit details
    Browse the repository at this point in the history