Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Allow jit to examine type of initonly static ref typed fields #20886

Merged

Commits on Nov 12, 2018

  1. Allow jit to examine type of initonly static ref typed fields

    The jit incorporates the value of integer and float typed initonly static
    fields into its codegen, if the class initializer has already run.
    
    The jit can't incorporate the values of ref typed initonly static fields,
    but the types of those values can't change, and the jit can use this knowledge
    to enable type based optimizations like devirtualization.
    
    In particular for static fields initialized by complex class factory logic the
    jit can now see the end result of that logic instead of having to try and deduce
    the type of object that will initialize or did initialize the field.
    
    Examples of this factory pattern in include `EqualityComparer<T>.Default` and
    `Comparer<T>.Default`. The former is already optimized in some cases by via
    special-purpose modelling in the framework, jit, and runtime (see dotnet#14125) but
    the latter is not. With this change calls through `Comparer<T>.Default` may now
    also devirtualize (though won't yet inline as the devirtualization happens
    late).
    
    Addresses #4108.
    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    7e39a00 View commit details
    Browse the repository at this point in the history
  2. fix build issue

    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    c007a9f View commit details
    Browse the repository at this point in the history
  3. ensure class is fully initialized

    Also remove assert for collectible classes and fix typo.
    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    ccbbc71 View commit details
    Browse the repository at this point in the history
  4. isInitOnly -> isSpeculative

    Flip the sense of the return flag for getStaticFieldCurrentClass and update
    remainder of code accordingly.
    
    Change jit to not ask for speculative results.
    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    5085778 View commit details
    Browse the repository at this point in the history
  5. Review feedback

    Rename bool out parameters to have `p` prefix for clarity.
    
    Defer fetching field attributes if class is not initialized.
    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    577d924 View commit details
    Browse the repository at this point in the history
  6. add test case

    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    64deef4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2df3553 View commit details
    Browse the repository at this point in the history
  8. improve error message

    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    c32f9c8 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    d3b07c5 View commit details
    Browse the repository at this point in the history
  10. use sstring

    AndyAyersMS committed Nov 12, 2018
    Configuration menu
    Copy the full SHA
    bf3c1a5 View commit details
    Browse the repository at this point in the history