- Remove `GetDomain` functions on `MethodDesc`, `MethodTable`, `TypeDesc`, and `TypeHandle`. They always return the single current app domain.
- Remove `GetDomain` functions and variables on `Assembly`, `DomainAssembly`, and `Module`. The actual domain they are constructed with is always the single current app domain.
Setting this to non-zero forces the JIT to generate debuggable
code. Normally, debuggable code is generated by the choice of
the debugger or if the IL code is marked as debug. This setting
allows one additional mechanism for forcing debuggable code.
Contributes to #94280
- Fixed `MethodDesc::SetNativeCodeInterlocked` to use the passed-in expected entry point instead of the current entry point. It seems this is how it used to work before https://github.com/dotnet/runtime/pull/57707.
- It's possible for a method to get jitted multiple times on the same thread due to reentry through class construction. Once a native code version is updated with an entry point, it can run and there are times when it's necessary to look up the native code version corresponding to the currently running code, such as when installing patchpoints. That would be impossible if the entry point is changed meanwhile to a different entry point.
Fixes https://github.com/dotnet/runtime/issues/93849
Add ICorDebugFunction5::DisableOpimizations with support for inliners in r2r and jit methods.
Co-authored-by: Mikelle <mirogers@microsoft.com>
Co-authored-by: Juan Sebastian Hoyos Ayala <juan.hoyos@microsoft.com>
* Skip type validation by default in ReadyToRun images
- Technically, this is a breaking change, so I've provided a means for disabling the type validation skip
- The model is that the C# compile won't get these details wrong, so disable the checks when run through crossgen2. The idea is that we'll get these things checked during normal, non-R2R usage of the app, and publish won't check these details.
* Replace expensive lookups of generic parameter and nested class data with R2R optimized forms
* Store index of MethodDesc as well as ChunkIndex. Makes MethodDesc::GetTemporaryEntryPoint *much* faster
* Optimize the path for computing if a method is eligible for tiered compilation
* Remove CanShareVtableChunksFrom concept
- it was only needed to support NGen
* Fix up some more issues
* Bring back late virtual propagation in the presence of covariant overrides only
* Check correct flag on EEClass
* Drive by fix for GetRestoredSlot. We don't need the handling of unrestored slots anymore
* Fix composite build with new tables
* Uniquify the mangled names
* Add more __
* Initial pass at type skip verifation checker
* Fix logging and some correctness issues
* Enable the more of type checking
- Notably, the recursive stuff now works
- Also fix a bug in constraint checking involving open types in the type system
* Fix build breaks involving new feature of GenericParameterDesc
* Add documentation for R2R format changes
Fix command line parameter to be more reasonable, and allow logging on command
Fix the rest of issues noted in crossgen2 testing
* Fix implementation of CompareMethodContraints. instead of using IsGeneric map, check to see if the method is generic in the first place. It turns out we have an efficient way to check in every place that matters
* Fix nits noticed by Aaron
* Add some const correctness to the world
* Fix issues noted by Michal, as well as remaining constrain checking issues
* Code review details
* Code review from trylek
* EnC non-functional changes
- Update inappropriate naming
- Update many logging statements
- Remove unused code
* EnC support for fields on generic types
* EnC support for methods on generic types
* Fix use after free introduced in EnC breakpoint.
Fix off by one for string logging.
* update new feature capabilities, JIT GUID
* Fix non-enc build
* Fix EnCFieldIndex check
* Remove IsFdPrivate assert
---------
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
Co-authored-by: Tom McDonald <tommcdon@microsoft.com>
* Remove fragile NGen logic for precomputed hashcodes
Hashing was confirmed to offer minor performance wins
but not with lazy hash code generation. Pre hashing was needed
to have a benefit on start-up but even then it was minor.
Mapping from an instruction pointer to a MethodDesc is a critical component of the runtime used in many places, notably diagnostics, slow path delegate creation, and stackwalking.
This change provides a dramatic improvement in the performance of that logic through several techniques.
1. The mapping from IP to range of interesting memory is done via a tree structure resembling that of a page table. The result of this is that in addition to reducing the locking logic, the cost of looking up in the presence of many different loaded assemblies will be reduced to a nearly constant time.
2. That tree structure is configured so that when accessing memory which will never be freed in the lifetime of the process, the memory can be accessed without taking any locks whatsoever.
3. The code map is enhanced to include not only the code generated by the JIT/R2R code, but also to include the fixup and stub precode stubs.
4. In addition, performance improvement was done to improve the performance of slow path delegate creation in particular, by reordering which checks are done, and by writing a simplified signature parse routine for computing the number of arguments to a function.
Performance of this was tested in both the EH stackwalking scenario as well as the delegate slow path creation scenario, but the delegate logic is what will be most visible when this is checked in. (See PR #79471 for details of the additional changes necessary to take advantage of this work when doing EH) (#8393 describes the potential product impact of just improving the delegate slow path creation code)
For the delegate creation scenario the perf impact was measured to be quite substantial. These numbers are in ms to create a constant number of delegates on each thread used. Smaller is better. The test was run on a 6 core machine.
| Threads | Without fix | With this PR
| ------------- | ------------- | ----- |
| 1 | 840 | 313|
| 2 | 1977 | 316 |
| 3 | 3290 | 325 |
| 4| 4259 | 344 |
| 5 | 5140 | 351 |
| 6 | 5872 | 374|
| 7 | 6463 | 442|
| 8 | 7046 | 499|
| 9 | 7648 | 547|
| 10 | 8241 | 627|
| 11 | 8851 | 749|
| 12 | 9595 | 773|
Fixes#8393
* Update CEEInfo::getAddressOfPInvokeTarget to handle already resolved P/Invokes
* Make sure to use NDirectMethodDesc
* Respond to PR feedback and remove dead GetNativeNDirectTarget logic
* Fix a manual offsetof for NDirectMethodDesc
* Use offsetof directly
* Remove some more dead code
* Fix the JIT/EE transition for getAddressOfPInvokeTarget
* Fix the getAddressOfPInvokeTarget contract
* Fix asserts fired during diag testing
* EnC flag is now applied to MethodDesc instead of
Instantiated MethodDesc.
* Renamed ambiguous method and updated some logging.
* Fix typos
* Cleanup trailing whitespaces in committed files
* Revert a macro for win32 compat
* Disambiguate test data method
* Revert XMLPath test which rely on external assets
* Revert whitespace change in Xml tests
* Revert ClrEtwAl and ILLink.Shared
* Revert crossgen2 props/targets and *.wxl
* Change SString::GetUTF8NoConvert to GetUTF8 that converts the SString
This enables SString to get out of the UTF16 state and helps move us away from "SString's natural encoding is UTF16"
* Remove some stack scratch buffers that are unneeded now (as we can now convert the SString itself and in some cases it was already in UTF8) and implement PR feedback.
* Add SetAndConvertToUTF8 method and remove the GetUTF8 method variants with a scratch buffer.
* Remove unneeded variables.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Add support for instrumenting delegate calls and vtable calls into method handle histograms. Use these histograms to do GDV for delegate calls and also support method-based GDV for vtable calls.
For instrumentation we now support class probes at interface call sites, method probes at delegate call sites and both class probes and method probes at vtable call sites. For vtable calls, when turned on, instrumentation produces both histograms as PGO data so that the JIT can later make the choice about what is the best form of guard to use at that site.
For guarding, there are some things to take into account. Delegate calls currently (practically) always point to precode, so this PR is just guarding on getFunctionFixedEntryPoint which returns the precode address, and this is generally quite cheap (same cost as class-based GDV). That's the case for delegates pointing to instance methods anyway, this PR does not support static methods yet -- those will be more expensive.
For vtable calls the runtime will backpatch the slots when tiering, so the JIT guards the address retrieved from the vtable against an indirection of the slot, which is slightly more expensive than a class-based guard.
Currently the instrumentation is enabled conditionally with COMPlus_JitDelegateProfiling=1 (for delegates) and COMPlus_JitVTableProfiling=1 (for vtable calls). Currently delegate profiling is turned on by default while vtable profiling is off by default.
FastInterlock* operations were #defined as aliases to regular Interlock* operations. Deleted the FastInterlock* aliases and replaced usage with Interlocked* operations.
* Change `CrossLoaderAllocatorHash` to not use the GC
`GCHeapHash`:
- Replaced `GCHeapHash` usage with `SHash`
- Added `s_supports_autoremove` to `SHash` to simulate `GCHeapHash`'s ability to remove elements while iterating them. When enabled, `SHash` calls `ShouldDelete()` on elements it walks during various operations and removes them if requested
- Added an optional on-remove cleanup action for elements in `SHash` to ease cleanup of heap-allocated elements
`CrossLoaderAllocatorHash`:
- Added formal native types for internal data structures and hash table elements. The layout of the internal data structures is mostly the same as before.
- Trackers are ref-counted since they may be inserted into multiple hash tables, and get deleted once their ref count reaches zero
- Translated the current implementation. Used holders where necessary to handle OOMs gracefully.
Miscellaneous:
- Removed cooperative GC mode usage in the relevant places in slot backpatching and inline tracking, and removed usage of the forbid-suspend-for-debugger region in those places
- When deleting call counters, reordered such that the runtime is suspended before the slot backpatching lock is acquired, to prevent the suspension code from suspending for the debugger while the lock is held and leading to FuncEval deadlocks
Testing:
- Memory usage is roughly the same as before, if anything it seems to be a bit lower
- Perf is similar to before, no significant change
- Ran a slot backpatching test including collectible assemblies in stress mode to look for issues