1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00
Commit graph

100 commits

Author SHA1 Message Date
Jakob Botsch Nielsen
0c67acb240
JIT: Sign/zero-extend small primitive arguments for pinvokes on arm32 and Apple arm64 (#106314)
Fix #101046
2024-08-15 01:54:52 +02:00
David Wrighton
dacf9dbdd4
Change temporary entrypoints to be lazily allocated (#101580)
* WorkingOnIt

* It basically works for a single example.

Baseline
Loader Heap:
----------------------------------------
System Domain:        7ffab916ec00
LoaderAllocator:      7ffab916ec00
LowFrequencyHeap:     Size: 0xf0000 (983040) bytes total.
HighFrequencyHeap:    Size: 0x16a000 (1482752) bytes total, 0x3000 (12288) bytes wasted.
StubHeap:             Size: 0x1000 (4096) bytes total.
FixupPrecodeHeap:     Size: 0x168000 (1474560) bytes total.
NewStubPrecodeHeap:   Size: 0x18000 (98304) bytes total.
IndirectionCellHeap:  Size: 0x1000 (4096) bytes total.
CacheEntryHeap:       Size: 0x1000 (4096) bytes total.
Total size:           Size: 0x3dd000 (4050944) bytes total, 0x3000 (12288) bytes wasted.

Compare
Loader Heap:
----------------------------------------
System Domain:        7ff9eb49dc00
LoaderAllocator:      7ff9eb49dc00
LowFrequencyHeap:     Size: 0xef000 (978944) bytes total.
HighFrequencyHeap:    Size: 0x1b2000 (1777664) bytes total, 0x3000 (12288) bytes wasted.
StubHeap:             Size: 0x1000 (4096) bytes total.
FixupPrecodeHeap:     Size: 0x70000 (458752) bytes total.
NewStubPrecodeHeap:   Size: 0x10000 (65536) bytes total.
IndirectionCellHeap:  Size: 0x1000 (4096) bytes total.
CacheEntryHeap:       Size: 0x1000 (4096) bytes total.
Total size:           Size: 0x324000 (3293184) bytes total, 0x3000 (12288) bytes wasted.

LowFrequencyHeap is 4KB bigger
HighFrequencyHeap is 288KB bigger
FixupPrecodeHeap is 992KB smaller
NewstubPrecodeHeap is 32KB smaller

* If there isn't a parent methodtable and the slot matches... then it by definition the method is defining the slot

* Fix a couple more issues found when running a subset of the coreclr tests

* Get X86 building again

* Attempt to use a consistent api to force slots to be set

* Put cache around RequiresStableEntryPoint

* Fix typo

* Fix interop identified issue where we sometime set a non Precode into an interface

* Move ARM and X86 to disable compact entry points

* Attempt to fix build breaks

* fix typo

* Fix another Musl validation issue

* More tweaks around NULL handling

* Hopefully the last NULL issue

* Fix more NULL issues

* Fixup obvious issues

* Fix allocation behavior so we don't free the data too early or too late

* Fix musl validation issue

* Fix tiered compilation

* Remove Compact Entrypoint logic

* Add new ISOSDacInterface15 api

* Fix some naming of NoAlloc to a more clear IfExists suffix

* Remove way in which GetTemporaryEntryPoint behaves differently for DAC builds, and then remove GetTemporaryEntrypoint usage from DAC entirely in favor of GetTemporaryEntryPointIfExists

* Attempt to reduce most of the use of EnsureSlotFilled. Untested, but its late.

* Fix the build before sending to github

* Fix unix build break, and invalid assert

* Improve assertion checks to validate that we don't allocate temporary entrypoints that will be orphaned if the type doesn't actually end up published.

* Remove unused parameters and add contracts

* Update method-descriptor.md

* Fix musl validation issue

* Adjust SOS api to be an enumerator

* Fix assertion issues noted
Fix ISOSDacInterface15 to actually work

* Remove GetRestoredSlotIfExists
- Its the same as GetSlot ....  just replace it with that function.

* Update src/coreclr/debug/daccess/daccess.cpp

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Update docs/design/coreclr/botr/method-descriptor.md

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Update src/coreclr/vm/methodtable.inl

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Update src/coreclr/vm/methodtable.h

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Fix GetMethodDescForSlot_NoThrow
Try removing EnsureSlotFilled
Implement IsEligibleForTieredCompilation in terms of IsEligibleForTieredCompilation_NoCheckMethodDescChunk

* Fix missing change intended in last commit

* Fix some more IsPublished memory use issues

* Call the right GetSlot method

* Move another scenario to NoThrow, I think this should clear up our tests...

* Add additional IsPublished check

* Fix MUSL validation build error and Windows x86 build error

* Address code review feedback

* Fix classcompat build

* Update src/coreclr/vm/method.cpp

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Remove assert that is invalid because TryGetMulticCallableAddrOfCode can return NULL ... and then another thread could produce a stable entrypoint and the assert could lose the race

* Final (hopefully) code review tweaks.

* Its possible for GetOrCreatePrecode to be called for cases where it isn't REQUIRED. we need to handle that case.

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
2024-07-14 12:20:21 -07:00
Jan Kotas
0746dd3d07
Fix mistake in BotR Threading section (#104183)
Fixes #79248
2024-06-28 18:56:12 -07:00
David Wrighton
eb8f54d92b
Make normal statics simpler (#99183)
This change makes access to statics much simpler to document and also removes some performance penalties that we've had for a long time due to the old model. Most statics access should be equivalent or faster.

This change converts static variables from a model where statics are associated with the module that defined the metadata of the static to a model where each individual type allocates its statics independently. In addition, it moves the flags that indicate whether or not a type is initialized, and whether or not its statics have been allocated to the `MethodTable` structures instead of storing them in a `DomainLocalModule` as was done before.

# Particularly notable changes
- All statics are now considered "dynamic" statics.
- Statics for collectible assemblies now have an identical path for lookup of the static variable addresses as compared to statics for non-collectible assemblies. It is now reasonable for the process of reading static variables to be inlined into shared generic code, although this PR does not attempt to do so.
- Lifetime management for collectible non-thread local statics is managed via a combination of a `LOADERHANDLE` to keep the static alive, and a new handle type called a `HNDTYPE_WEAK_INTERIOR_POINTER` which will keep the pointers to managed objects in the `MethodTable` structures up to date with the latest addresses of the static variables.
- Each individual type in thread statics has a unique object holding the statics for the type. This means that each type has a separate object[](for gc statics), and/or double[](for non-gc statics) per thread for TLS statics. This isn't necessarily ideal for non-collectible types, but its not terrible either.
- Thread statics for collectible types are reported directly to the GC instead of being handled via a GCHandle. While needed to avoid complex lifetime rules for collectible types, this may not be ideal for non-collectable types.
- Since the `DomainLocalModule` no longer exists, the `ISOSDacInterface` has been augmented with a new api called `ISOSDacInterface14` which adds the ability to query for the static base/initialization status of an individual type directly.
- Significant changes for generated code include
  - All the helpers are renamed
  - The statics of generics which have not yet been initialized can now be referenced using a single constant pointer + a helper call instead of needing a pair of pointers. In practice, this was a rare condition in perf-critical code due to the presence of tiered compilation, so this is not a significant change to optimized code.
  - The pre-initialization of statics can now occur for types which have non-primitive valuetype statics as long as the type does not have a class constructor.
  - Thread static non-gc statics are now returned as byrefs. (It turns out that for collectible assemblies, there is currently a small GC hole if a function returns the address of a non-gc threadstatic. CoreCLR at this time does not attempt to keep the collectible assembly alive if that is the only live pointer to the collectible static in the system)

With this change, the pointers to normal static data are located at a fixed offset from the start of the `MethodTableAuxiliaryData`, and indices for Thread Static variables are stored also stored in such a fixed offset. Concepts such as the `DomainLocalModule` , `ThreadLocalModule`, `ModuleId` and `ModuleIndex` no longer exist.

# Lifetime management for collectible statics
- For normal collectible statics, each type will allocate a separate object[] for the GC statics and a double[] for the non-GC statics. A pointer to the data of these arrays will be stored in the `DynamicStaticsInfo` structure, and when relocation occurs, if the collectible types managed `LoaderAllocator` is still alive, the static field address will be relocated if the object moves. This is done by means of the new Weak Interior Pointer GC handle type. 
- For collectible thread-local statics, the lifetime management is substantially more complicated due the issue that it is possible for either a thread or a collectible type to be collected first. Thus the collection algorithm is as follows.
  - The system shall maintain a global mapping of TLS indices to MethodTable structures
  - When a native `LoaderAllocator` is being cleaned up, before the WeakTrackResurrection GCHandle that points at the the managed `LoaderAllocator` object is destroyed, the mapping from TLS indices to collectible `LoaderAllocator` structures shall be cleared of all relevant entries (and the current GC index shall be stored in the TLS to MethodTable mapping)
  - When a GC promotion or collection scan occurs, for every TLS index which was freed to point at a GC index the relevant entry in the TLS table shall be set to NULL in preparation for that entry in the table being reused in the future. In addition, if the TLS index refers to a `MethodTable` which is in a collectible assembly, and the associated `LoaderAllocator` has been freed, then set the relevant entry to NULL.
  - When allocating new entries from the TLS mapping table for new collectible thread local structures, do not re-use an entry in the table until at least 2 GCs have occurred. This is to allow every thread to have NULL'd out the relevant entry in its thread local table.
  - When allocating new TLS entries for collectible TLS statics on a per-thread basis allocate a `LOADERHANDLE` for each object allocated, and associate it with the TLS index on that thread.
  - When cleaning up a thread, for each collectible thread static which is still allocated, we will have a `LOADERHANDLE`. If the collectible type still has a live managed `LoaderAllocator` free the `LOADERHANDLE`.

# Expected cost model for extra GC interactions associated with this change
This change adds 3 possible ways in which the GC may have to perform additional work beyond what it used to do.
1. For normal statics on collectible types, it uses the a weak interior pointer GC handle for each of these that is allocated. This is purely pay for play and trades off performance of accessing collectible statics at runtime to the cost of maintaining a GCHandle in the GC. As the number of statics increases, this could in theory become a performance problem, but given the typical usages of collectible assemblies, we do not expect this to be significant.
2. For non-collectible thread statics, there is 1 GC pointer that is unconditionally reported for each thread. Usage of this removes a single indirection from every non-collectible thread local access. Given that this pointer is reported unconditionally, and is only a single pointer, this is not expected to be a significant cost.
3. For collectible thread statics, there is a complex protocol to keep thread statics alive for just long enough, and to clean them up as needed. This is expected to be completely pay for play with regard to usage of thread local variables in collectible assemblies, and while slightly more expensive to run than the current logic, will reduce the cost of creation/destruction of threads by a much more significant factor. In addition, if there are no collectible thread statics used on the thread, the cost of this is only a few branches per lookup.

# Perf impact of this change
I've run the .NET Microbenchmark suite as well as a variety of ASP.NET Benchmarks. (Unfortunately the publicly visible infrastructure for running tests is incompatible with this change, so results are not public). The results are generally quite hard to interpret. ASP.NET Benchmarks are generally (very) slightly better, and the microbenchmarks are generally equivalent in performance, although there is variability in some tests that had not previously shown variability, and the differences in performance are contained within the margin of error in our perf testing for tests with any significant amount of code. When performance differences have been examined in detail, they tend to be in code which has not changed in any way due to this change, and when run in isolation the performance deltas have disappeared in all cases that I have examined. Thus, I assume they are caching side effect changes. Performance testing has led me to add a change such that all NonGC, NonCollectible statics are allocated in a separate LoaderHeap which appears to have reduced the variability in some of the tests by a small fraction, although results are not consistent enough for me to be extremely confident in that statement.
2024-06-12 20:54:31 -07:00
Ken Dale
59f2833b98
Update docs.microsoft.com usages to learn.microsoft.com (#102881)
* Update https://docs.microsoft.com to https://learn.microsoft.com

* Update http://docs.microsoft.com/ to https://learn.microsoft.com (removes trailing slash)

* Update docs.microsoft.com to https://learn.microsoft.com

* Update docs.microsoft.com to learn.microsoft.com

* Replace learn.microsoft.com/en-us/ with learn.microsoft.com/ to remove locale from urls
2024-05-31 11:27:45 -07:00
Tanner Gooding
3bd417108a
Change the ReciprocalEstimate and ReciprocalSqrtEstimate APIs to be mustExpand on RyuJIT (#102098)
* Change the ReciprocalEstimate and ReciprocalSqrtEstimate APIs to be mustExpand on RyuJIT

* Apply formatting patch

* Fix the RV64 and LA64 builds

* Mark the ReciprocalEstimate and ReciprocalSqrtEstimate methods as AggressiveOptimization to bypass R2R

* Mark other usages of ReciprocalEstimate and ReciprocalSqrtEstimate in Corelib with AggressiveOptimization

* Mark several non-deterministic APIs as BypassReadyToRun and skip intrinsic expansion in R2R

* Cleanup based on PR recommendations to rely on the runtime rather than attributation of non-deterministic intrinsics

* Adding a regression test ensuring direct and indirect invocation of non-deterministic intrinsic APIs returns the same result

* Add a note about non-deterministic intrinsic expansion to the botr

* Apply formatting patch

* Ensure vector tests are correctly validating against the scalar implementation

* Fix the JIT/SIMD/VectorConvert test and workaround a 32-bit test issue

* Skip a test on Mono due to a known/tracked issue

* Ensure that lowering on Arm64 doesn't make an assumption about cast shapes

* Ensure the tier0opts local is used

* Ensure impEstimateIntrinsic bails out for APIs that need to be implemented as user calls
2024-05-13 14:01:21 -07:00
Filip Navara
41b1091890
Replace FEATURE_EH_FUNCLETS in JIT with runtime switch (#99191)
* Replace FEATURE_EH_FUNCLETS/FEATURE_EH_CALLFINALLY_THUNKS in JIT with runtime switch

* Cache Native AOT ABI check to see if TP improves

---------

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
2024-04-05 11:46:18 -07:00
Egor Bogatov
fab69efde7
Move memset/memcpy/memzero jit helpers to SpanHelpers (#98623)
---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2024-02-25 17:37:10 +01:00
Egor Bogatov
bed5f469e8
GT_STORE_BLK - do not call memset for blocks containg gc pointers on heap (#95530)
Co-authored-by: Qiao Pengcheng <qiaopengcheng@loongson.cn>
2024-01-04 23:21:44 +01:00
Bruce Forstall
be4a76b22b
Adjust clr-abi for new arm32 call-finally behavior (#95596)
Due to change in #95117
2023-12-04 11:36:40 -08:00
Jan Kotas
11a6f9bd1a
Add ABI note about small return types (#94987)
* Add ABI note about small return types

* Update docs/design/coreclr/botr/clr-abi.md

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>

* Fix fcall.h to match
2023-11-20 07:02:27 -08:00
Thomas Johnson
85f54f3ef6
Fixed broken ECMA links (#92547) 2023-09-24 11:37:59 -07:00
Mark Plesko
88c4b87221
Clarifications in botr gc section (#89888) 2023-08-02 17:16:34 -07:00
Jan Vorlicek
4fbd7c5827
Set the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE (#88072)
* Set the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE

This change makes setting the `CORINFO_EH_CLAUSE_SAMETRY` on
`CORINFO_EH_CLAUSE` to happen for coreclr to. It is a prerequisity for the
port of exception handling from nativeaot to coreclr and it is a noop on
coreclr with the old exception handling.

* Fix comments

* Add clr-abi note and r2rdump support for the flag

* Fix markdown LINT error

* Update docs/design/coreclr/botr/clr-abi.md

* Update docs/design/coreclr/botr/clr-abi.md

* Update the ABI doc

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2023-07-26 18:48:32 +02:00
Aaron Robinson
5649739953
UnsafeAccessorAttribute non-generic support (#86932)
* CoreCLR and NativeAOT

* Add UnsafeAccessorAttribute API

* Implement IL generation for all accessor paths

* Implement static/instance field lookup - non-generic

* Implement static/instance method lookup - non-generic

* Defined ambiguity logic with respect to
custom modifiers.
- First pass ignore custom modifiers
- If ambiguity detected, rerun algorithm but
  require precise matching of custom modifiers.
- If there is no clear match throw AmbiguousImplementationException.

* Cleanup memory management confusion
with ILStubResolver.

* Fix non-standard C++

* Remove CORINFO_MODULE_ALLACCESS scope

* Remove enum METHOD_TYPE.

* Update BOTR on TypeDesc
2023-06-15 06:59:49 -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
Alexander Soldatov
224927519c
[RISC-V] Fix Stubs for Generics (#87316)
Fix register saving before passing generic instantiation parameter.
2023-06-09 17:43:48 -07:00
t-mustafin
d88f9a0ed3
Fix typo in dac-notes.md (#87295) 2023-06-08 17:04:21 -07:00
Andrew Au
f20292493e
Documentation for the HotColdMap section (#87023) 2023-06-05 13:45:51 -07:00
Tanner Gooding
d7a30ba1f1
Ensure Vector2/3/4, Quaternion, and Plane don't have a false dependency on Vector<T> (#86481)
* Ensure Vector2/3/4, Quaternion, and Plane don't have a false dependency on Vector<T>

* Apply JIT formatting patch

* Fixing a build issue

* Handle an SPMI assert
2023-05-19 18:59:50 -07:00
Tanner Gooding
0f8afd209a
Add an undocumented switch to allow controlling the preferred vector width emitted implicitly by the JIT (#86457)
* Add an undocumented switch to allow controlling the preferred vector width emitted implicitly by the JIT

* Resolving issues and responding to PR feedback

* Simplifying the xarch cpu info check
2023-05-18 14:25:00 -07:00
David Wrighton
8a2aec1be7
Intrinsics analyzer and fixes (#85481)
* Implement analyzer for platform intrinsics use in System.Private.CoreLib

This analyzer detects the use of all platform intrinsics and checks to
ensure that they are all used either protected by an if statement OR
ternary operator which checks an appropriate IsSupported flag, or that
the intrinsic is used within a method where the behavior of platform
support for the intrinsic is not allowed to vary between compile time
and runtime. The analyzer attempts to be conservative about allowed patterns. 

All existing code in System.Private.CoreLib has been annotated to avoid producing
errors.

See the markdown document for details.

Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
2023-05-15 19:20:01 -07:00
Tanner Gooding
7bd4666671
Ensure getMaxSIMDStructBytes doesn't report compVerifyInstructionSetUnusable (#85370) 2023-05-06 09:09:26 -07:00
Egor Bogatov
0be256e710
Allocate Array.Empty<> on a frozen segment (NonGC heap) (#85559)
Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
2023-05-03 11:41:34 +02:00
mikelle-rogers
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
Tanner Gooding
db93e03226
Updating some places to cover xmm16-xmm31 (#84088)
* Updating some places to cover xmm16-xmm31

* Remove XMM0-XMM31 and K0-K7 from mapRegNumToDwarfReg
2023-03-29 16:19:44 -07:00
Huo Yaoyuan
b007d12c6d
Update BOTR description of function pointer (#83914) 2023-03-24 20:30:09 -07:00
David Wrighton
e88d8944bf
Load levels explanation (#83840)
Add some descriptions of how load levels work in the runtime
2023-03-23 13:35:25 -07:00
Tanner Gooding
46993586e4
Some minor cleanup post the addition of TYP_SIMD64 and ZMM support - P1 (#83044)
* Ensure EA_16BYTE is FEATURE_SIMD only and EA_32/64BYTE are TARGET_XARCH only

* Remove getSIMDSupportLevel as its now unnecessary

* Ensure canUseVexEncoding and canUseEvexEncoding are xarch only

* Don't make EA_16BYTE+ require FEATURE_SIMD

* Resolving formatting and build failures

* Adding back a check that shouldn't have been removed
2023-03-07 11:56:26 -08:00
Adeel Mujahid
3b63eb1346
Replace remaining instances of COMPlus with DOTNET (#82985)
* Replace remaining instances of COMPlus with DOTNET

* Fix heading in RyuJIT tutorial
2023-03-05 08:40:20 -08:00
Jan Kotas
3adbcf5ff9
Doc improvements (#76863)
- Use proper macOS capitalization
- Delete superfluous details

Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
2022-10-11 13:35:53 -07:00
Mike McLaughlin
543bcc5ee7
Misc createdump fixes (#73426)
Add --crashreportonly command line option that doesn't generated a dump.

Add matching DOTNET_EnableCrashReportOnly env var.

Add LoadModule error logging for MacOS.

Make DAC validate EEClass and MethodDesc functions more robust on Linux/MacOS so SOS's eestack and dumpstack commands don't segfault.

Update createdump doc.
2022-08-05 13:01:14 -07:00
Egor Bogatov
4cd3e780c4
Add EH filters for generic catch(T) blocks (#72721)
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2022-07-29 23:29:50 +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
David Wrighton
a78c46d1dd
Version resilient cross module code compilation and inlining (#71271)
- 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
- Support input of PGO data to control the set of methods
- Enable new `READYTORUN_FLAG_UNRELATED_R2R_CODE` flag on R2R images which is used to indicate which modules may have generic code not directly related to the metadata of the image
- Lookup R2R methods in an `alternate` location as well as the metadata defining module. This allows for many generics to be embedded without needing to use the new `READYTORUN_FLAG_UNRELATED_R2R_CODE` flag, which has global effects on performance.

- Add command line switches to enable/disable the new behavior

- Enhance the version resilience test to cover this new behavior
2022-07-01 15:54:24 -07:00
David Wrighton
89dc073529
Revert "Add support for cross module inlining and cross module generic compilation to Crossgen2 (#68919)" (#71076)
This reverts commit 18ec279e4b.
2022-06-21 14:04:39 -07:00
David Wrighton
18ec279e4b
Add support for cross module inlining and cross module generic compilation to Crossgen2 (#68919)
* Add support for cross module inlining and cross module generic compilation 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
  - By default the new behavior is not enabled
2022-06-20 10:51:41 -07:00
Jan Krivanek
e4ac6fa2e4
Fix typo (clr.dll -> mscordacwks.dll) (#70550) 2022-06-10 06:53:10 -07:00
Jakob Botsch Nielsen
8ca9916b0d
Add arm64 support for EnC (#69679)
This adds support for EnC on arm64. A couple of notes on the
implementation compared to x64:
- On x64 we get the fixed stack size from unwind info. However, for the
  frames we set up on arm64 for EnC it is not possible to extract the
  frame size from there because their prologs generally look like

  stp fp, lr, [sp,#-16]!
  mov fp, sp
  sub sp, sp, #144

  with unwind codes like the following:

  set_fp; mov fp, sp

  save_fplr_x #1 (0x01); tp fp, lr, [sp, #-16]!

  As can be seen, it is not possible to get the fixed stack size from
  unwind info in this case. Instead we pass it through the GC info that
  already has a section for EnC data.

- On arm64 the JIT is required to place the PSPSym at the same offset
  from caller-SP for both the main function and for funclets. Due to
  this we try to allocate the PSPSym as early as possible in the main
  function and we must take some care in funclets.  However, this
  conflicts with the EnC frame header that the JIT uses to place values
  that must be preserved on EnC transitions. This is currently
  callee-saved registers and the MonitorAcquired boolean.

  Before this change we were allocating PSPSym above (before) the
  monitor acquired boolean, but we now have to allocate MonitorAcquired
  first, particularly because the size of the preserved header cannot
  change on EnC transitions, while the PSPSym can disappear or appear.
  This changes frame allocation slightly for synchronized functions.
2022-05-24 00:14:18 +02:00
Adeel Mujahid
55e2378d86
Fix typos (#69537)
* Fix typos

* Fix typo: seperate -> separate

* Rename ApplicationNameSetFromArgument

* Update src/coreclr/vm/methodtablebuilder.cpp

* Update docs/coding-guidelines/clr-code-guide.md

Co-authored-by: Dan Moseley <danmose@microsoft.com>

* Update src/mono/mono/tests/verifier/make_tests.sh

Co-authored-by: Dan Moseley <danmose@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2022-05-23 10:14:58 -07:00
Jeremy Koritzinsky
04e65d2b87
Generate the DAC table on Windows with MSVC linker directives instead of resource injection (#68065) 2022-05-12 14:53:12 -07:00
Adeel Mujahid
4141913109
Fix typos (#69011) 2022-05-07 11:55:53 -07:00
Jan Kotas
b59c6491dd
Rename CoreRT to NativeAOT (1/N) (#68888)
Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
2022-05-05 18:14:28 -07:00
Qiao Pengcheng
90b7be39c4
[LoongArch64] JIT/EE interface for getting ABI-info (#62893)
* [LoongArch64] add ToolBox directory about jitinterace for getting ABI-info. (#59561)

Co-authored-by: Loongson's .NET-teams

* [LoongArch64] add new interace for getting ABI-info. (#59561)

* [LoongArch64] add the linking page for LoongArch64 ABI-info. (#59561)

* [LoongArch64] moved ThunkInput.txt to #62885.

* [LoongArch64] moved vm/jitinterface.cpp to #62885.

* remove the JIT/EE interface back from #62885..

* [LoongArch64] Fix the compiling error after merge.

* [LoongArch64] add comments for the returned value of `getFieldTypeByHnd`.

* [LoongArch64] rename getFieldTypeByHnd to getFieldSizeClassificationByHnd.
Also add macro define for returned value of `getFieldSizeClassificationByHnd`.

* [LoongArch64] Delete the interface `getArgType2`.
And refactor the returned values of `getFieldSizeClassificationByHnd`.

* [LoongArch64] delete `GetArgType` within `ToolBox/superpmi`.

* [LoongArch64] rename `getFieldSizeClassificationByHnd` to
`getLoongArch64PassStructInRegisterFlags`.

* [LoongArch64] amend the floating-ABI for native-struct.

* [LoongArch64] update all related `GetFieldSizeClassificationByHnd`
by `GetLoongArch64PassStructInRegisterFlags` and amend some comments.

* [LoongArch64] replace `LookupApproxFieldTypeHandle()`
by `GetFieldTypeHandleThrowing()`.

* [LoongArch64] implements the crossgen2 for LoongArch64.

* Revert "[LoongArch64] implements the crossgen2 for LoongArch64."

This reverts commit b05a2b90e8d8a2f6d1cf7f101ddfc9d4ed8d984e.

The crossgen2 for LoongArch64 will be submitted by a new PR.

* [LoongArch64] update the `GUID JITEEVersionIdentifier`.
Also delete some unused comments.

Co-authored-by: qiaopengcheng <qiaopengcheng-hf@loongson.cn>
2022-02-18 00:07:48 -08:00
Jakob Botsch Nielsen
3fc8b09944
Add JIT support for control-flow guard on x64 and arm64 (#63763)
Add support for generating control-flow guard checks. The support is enabled by a JIT flag or by setting COMPlus_JitForceControlFlowGuard=1.

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
2022-02-08 18:20:12 +01:00
Austin Wise
db1bbf4068
Fix link in readytorun-format.md (#64878)
The link was not rendering correctly, as the link text and target were on separate lines.
2022-02-06 10:39:55 -08:00
Michal Strehovský
07ed923f57
Switch to objwriter from the dotnet/llvm-project repo (#63177) 2021-12-31 13:34:33 +09:00
Jeremy Koritzinsky
562d1e7f8c
Remove the varargs-based mdarray helper. (#62855) 2021-12-16 15:11:50 -08:00
Michal Strehovský
f44b0ba183
Add docs around NativeAOT workflows (#62837) 2021-12-16 10:35:54 +09:00