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

Add support for cross module inlining and cross module generic compilation to Crossgen2 #68919

Merged
merged 22 commits into from
Jun 20, 2022

Commits on Jun 10, 2022

  1. Add support for cross module inlining and cross module generic compil…

    …ation to Crossgen2
    
    - Refactor Module into ModuleBase and Module
      - The goal is to have allow a subset version of Module which can only hold refs, this is to be used by the manifest module in an R2R image to allow for version resilient cross module references.
      - Update handling of ModuleBase so that its used everywhere that tokens are parsed from R2R
      - Remove ENCODE_MODULE_ID_FOR_STATICS and ENCODE_ACTIVE_DEPENDENCY
        - These were only used for NGEN, and conflict with easy impelmentation for the ModuleBase concept
      - Remove locking in ENCODE_STRING_HANDLE processing, and tweak comments. Comments applied to the removed ngen based code, and the lock was only necessary for the old ngen thing.
      - Adjust ComputeLoaderModuleWorker for locating loader module
        - Follow comment more accurately, to avoid putting every generic into its definition module. This will make R2R function lookup able to find compiled instantiations in some cases. This may be what we want long term, it may not.
      - Remove MemberRefToDesc map and replace with LookupMap like the other token types. We no longer make use of the hot table, so this is more efficient
        - Also reduces complexity of implementation of ModuleBase
    
    - Build fixup to describe a single method as a standalone blob of data
      - There are parallel implementations in Crossgen2 and in the runtime
      - They produce binary identical output
      - Basic R2RDump support for new fixup
    
    - Adjust module indices used within the R2R format to support a module index which refers to the R2R manifest metadata. This requires bumping the R2R version to 6.2
      - Add a module index between the set of assembly refs in the index 0 module and the set of assembly refs in the R2R manifest metadata
    
    - Adjust compilation dependency rules to include a few critical AsyncStateMachineBox methods
    
    - Remove PEImage handling of native metadata which was duplicative
    
    - Do not enable any more devirtualization than was already in use, even in the cross module compilation scenario. In particular, do not enable devirtualization of methods where the decl method isn't within the version bubble, even if the decl method could be represented with a cross-module reference token. (This could be fixed, but is out of scope for this initial investigation)
    
    Make the compilation deterministic in this new model, even though we are generating new tokens on demand
      - Implement this by detecting when we need new tokens during a compile, and recompiling with new tokens when necessary
      - This may result in compiling the same code as much as twice
    
    Compile the right set of methods with cross module inlining enabled
    - Add support for compiling the called virtual methods on generic types
      - This catches the List<T> and Dictionary<TKey,TValue> scenarios
    
    - Add command line switches to enable/disable the new behavior
    
    NOTE: Module::IsInSameVersionBubble doesn't actually behave as expected. Currently we're generating a native manifest metadata in all circumstances, which will cause all modules to be treated as having InputBubble semantics. However, fortunately, we don't actually do anything like that at runtime. The only use of IsInSameVersionBubble is used to control R2R function lookup, which will not cause a problem.
    davidwrighton committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    5aa5f79 View commit details
    Browse the repository at this point in the history
  2. Temporary workaround

    davidwrighton committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    acf28b3 View commit details
    Browse the repository at this point in the history
  3. Disable cross module pinvoke inlining

    - We don't model the details necessary to prevent this from possibly being a problem at this time
    davidwrighton committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    313792b View commit details
    Browse the repository at this point in the history
  4. Fix Mono.Linker.Tests

    davidwrighton committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    6a5130f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e31e8bf View commit details
    Browse the repository at this point in the history
  6. Address code review feedback, and fix naming for native side of Ready…

    …ToRunStandaloneMethodMetadata
    davidwrighton committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    308c5c1 View commit details
    Browse the repository at this point in the history

Commits on Jun 11, 2022

  1. Update the R2R docs

    davidwrighton committed Jun 11, 2022
    Configuration menu
    Copy the full SHA
    7326b39 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2022

  1. Configuration menu
    Copy the full SHA
    ca1d623 View commit details
    Browse the repository at this point in the history
  2. Fix markdownlint

    davidwrighton committed Jun 13, 2022
    Configuration menu
    Copy the full SHA
    0a4247f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    55a8164 View commit details
    Browse the repository at this point in the history
  4. Adjust command line switches for new behavior to be disabled, and exp…

    …licitly declared to be experimental
    davidwrighton committed Jun 13, 2022
    Configuration menu
    Copy the full SHA
    64a63b9 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2022

  1. Fix the build

    davidwrighton committed Jun 14, 2022
    Configuration menu
    Copy the full SHA
    3cbce96 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c46fe1d View commit details
    Browse the repository at this point in the history

Commits on Jun 15, 2022

  1. Configuration menu
    Copy the full SHA
    45fed21 View commit details
    Browse the repository at this point in the history

Commits on Jun 16, 2022

  1. Configuration menu
    Copy the full SHA
    93a041f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a47ab4f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    85831bb View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2022

  1. Address feedback final

    davidwrighton committed Jun 17, 2022
    Configuration menu
    Copy the full SHA
    7d6e658 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7ab7301 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2e1541b View commit details
    Browse the repository at this point in the history

Commits on Jun 18, 2022

  1. Configuration menu
    Copy the full SHA
    6af05fd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bd13931 View commit details
    Browse the repository at this point in the history