54 Commits
Author SHA1 Message Date
Elinor Fung c37e13fc1a Remove GetDomain functions on assorted method/type/assembly classes which are always in the single app domain (#98135)
- 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.
2024-02-08 13:58:15 -08:00
Bruce Forstall 0926e136e1 Expose DOTNET_JitDebuggable as a public option (#96457)
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
2024-01-05 10:19:22 -08:00
Koundinya Veluri 8c02b08141 Ensure that a native code version only ever gets one entry point that doesn't change (#94542)
- 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
2023-11-09 10:29:14 -08:00
Egor Bogatov 81bb11d0fa Clean up AggressiveOpt tier in vm (#90504) 2023-08-24 14:02:08 +02:00
mikelle-rogers eacb32e400 Put HasNativeCodeReJITAware into GetFunctionAddress (#90049)
* Remove calls to GetFunctionAddress with Null address and clarify method names
2023-08-14 13:37:22 -07:00
JasperandJan Kotas 43e47b8e1d Remove _NoLogging methods from VM (#89641)
* Remove getIX_NoLogging

* Remove GetModule_NoLogging

* Remove IsRestored_NoLogging

* Remove GetOffset_NoLogging

* Remove GetMethodTable_NoLogging

* Remove HasClass[OrMethod]Instantiation_NoLogging

* Remove GetNumVirtuals_NoLogging

* Remove GetWriteableData[ForWrite]_NoLogging

* Remove GetMemberDef_NoLogging

* Remove GetApproxEnclosingMethodTable_NoLogging

* Remove GetTypeDefRid_NoLogging

* Remove GetCl_NoLogging

* Rename GetClass_NoLogging and remove old GetClassWithPossibleAV

* Update src/coreclr/vm/methodtable.h

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2023-07-28 14:42:28 -07:00
b4118a6a81 Feature to be able to selectively deoptimize methods (#88797)
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>
2023-07-13 19:42:52 -07:00
David Wrighton 8042facb42 Improve the performance of the type loader through various tweaks (#85743)
* 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
2023-06-13 15:25:50 -07:00
afa9a930b8 EnC Support for Generics (#85269)
* 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>
2023-04-25 10:32:19 -07:00
Aaron Robinson 5a45085c15 Remove fragile NGen logic for precomputed hashcodes (#82563)
* 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.
2023-03-08 21:48:42 -05:00
David Wrighton 766d8c1846 Fix the multicore performance of mapping from an instruction pointer to a MethodDesc (#79021)
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
2023-03-03 20:50:07 -08:00
Tanner Gooding 05f8388ba3 Update CEEInfo::getAddressOfPInvokeTarget to handle already resolved P/Invokes (#82150)
* 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
2023-02-15 10:05:14 -08:00
Aaron Robinson b69fa27556 Prep for new diagnostic work and tests (#81571)
* Fix asserts fired during diag testing

* EnC flag is now applied to MethodDesc instead of
Instantiated MethodDesc.

* Renamed ambiguous method and updated some logging.
2023-02-03 22:42:31 -08:00
Aaron Robinson 3ea12efc12 Remove the GenericComPlusCall mechanism (#76415)
Remove unused asm constants.
Remove comments about context-bound objects and remoting.
Use common constants for VtblGap concept.
2022-09-29 22:00:13 -07:00
Aaron Robinson 8ec62773f5 Remove all non-functional/non-informational uses of mscorlib. (#74529)
* Remove all non-functional/non-informational uses of mscorlib.
2022-08-24 21:02:22 -07:00
Hyungju Lee 8a64275f78 Throw if MethodDesc::GetName() returns null (#73760) 2022-08-21 08:52:55 +02:00
Adeel Mujahid 9d6396deb0 Fix typos (#72709) 2022-07-23 20:24:28 -07:00
Adeel Mujahid 3ea30ed321 Fix typos (#72314)
* 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
2022-07-16 22:11:11 -07:00
d17741d0c4 Change SString::GetUTF8NoConvert to GetUTF8 that converts the SString (#71101)
* 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>
2022-06-22 18:01:38 -07:00
Jakob Botsch Nielsen cae8546c5d Add support for delegate GDV and method-based vtable GDV (#68703)
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.
2022-06-18 01:58:01 +02:00
Jan Kotas 2ce8130f4b Find&replace FastInterlock* with Interlocked* (#70784)
FastInterlock* operations were #defined as aliases to regular Interlock* operations. Deleted the FastInterlock* aliases and replaced usage with Interlocked* operations.
2022-06-15 16:22:25 -07:00
David Wrighton 6e5065d5e0 Remove CORCOMPILE_IMPORT_SECTION (#69881)
- Replace with direct use of ready to run data structures in runtime
- Remove pointer tagging that is not relevant in a R2R based world
2022-05-27 15:23:54 -07:00
Aaron Robinson 4f010449b1 Removal of IBC infrastructure (#68717)
* Removal of IBC infrastructure

* Crossgen2 - remove tuning flag.
2022-05-16 13:18:53 -07:00
Aaron Robinson 6a9245f9a1 Reenable 4244 (#68615)
* Remove disable of 4244 in root compiler settings.
2022-05-04 13:53:32 -07:00
Koundinya Veluri 3e5e118c53 Change CrossLoaderAllocatorHash to not use the GC (#67160)
* 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
2022-04-08 07:20:18 -07:00