Commit Graph
35 Commits
Author SHA1 Message Date
David Wrighton fcaba18061 Universal arm crossgen compiler (#58279)
Stop generating OS specific compilers for the arm and arm64 architectures for use in crossgen2
- As it turns out the OS differences here are relatively minor and fairly easy to handle with runtime switches.
- However, when an exact target is known we can generate better code by having the various if statements evaluate to a constant true/false. (This is done for all runtime jit builds)
- This has been validated to produce binary identical output for generating System.Private.CoreLib.dll on the various architectures.
- This work reduces the distribution size of crossgen2, and also reduces the amount of time it takes to build everything (Most notably, the Mac build times in PR's are reduced by 5-7 minutes, but improvements are visible across all of/architecture pairs)
2021-09-28 16:52:10 -07:00
Aaron Robinson b0159122f3 Add a no-cache backed CLRConfig lookup mechanism (#59513)
* Add a no cache backed CLRConfig lookup mechanism

Remove remaining locations that had a hardcoded COMPlus_ prefix.
The new no cache CLRConfig is usable from within the PAL.
2021-09-23 20:41:33 -07:00
Elinor Fung c8a4e180ab Remove some unnecessary allocations / copies on startup (#59270) 2021-09-20 10:27:47 -07:00
Elinor Fung b5be89c7d4 Remove PEDecoder::HasNativeHeader (always false) (#58303) 2021-08-30 10:17:20 -07:00
Jeremy Koritzinsky 65f795f8ac Delete unused md/hotdata code (#57987)
Hot/cold data from this folder was only used in NGEN/Crossgen1 scenarios, so it's dead now.
2021-08-24 01:34:27 +00:00
Jeremy Koritzinsky 25cd447418 Remove more ngen-related dead code and config vars (#57874) 2021-08-23 11:40:41 -07:00
Jeremy Koritzinsky 948770a23b Remove CROSSGEN_COMPILE define usage (#57697)
* Remove basic usages with unifdef.

* Manually remove the rest of the occurances that unifdef didn't catch due to complexity or if the file contains assembly.

* Undo deletion of some #if 0 blocks that unifdef removed.
2021-08-19 23:36:03 +00:00
Elinor Fung 4061822131 Delete code under FEATURE_PREJIT (#57693) 2021-08-19 10:10:43 -07:00
Elinor Fung 4ae06696b8 Delete code under FEATURE_NATIVE_IMAGE_GENERATION (#57669) 2021-08-18 12:21:28 -07:00
Noah Falk d90f6b6c86 Instrument MemTracker (#56648)
We are seeing some likely memory corruption in
https://github.com/dotnet/runtime/issues/54469
and these changes hopefully will help better
diagnose it
2021-08-01 23:47:20 -07:00
Jan Vorlicek a81fee275f Fix DAC issue with redefined standard new / delete operators (#55945)
I have found that since .NET 6 preview 5, SOS on macOS arm64 crashes
when running basic commands like clrstack due to the fact that
its std::string allocations are done using standard new operator,
but the freeing at some places is done using our overriden delete
operator due to inlining of STL code.

This change removes our redefinitions of those operators for DAC
compilation, so this clash cannot happen.
2021-07-22 14:39:42 -07:00
Koundinya Veluri 4ff3762a2e Update spin-wait pause/yield normalization (#55295)
Update spin-wait pause/yield normalization

- Modified the measurement to use much less time and to remeasure periodically to reduce CPU usage during startup
- Each measurement does a low-microsecond-level measurement of pause/yield times
- Some small amount of history of recent measurements is retained and used to for now take the lowest measurement for normalization
- Measurements are done lazily, and at most every few seconds another measurement is taken
- Added a profiling event that includes info about a measurement and the established value from recent measurements that is used for normalization
2021-07-13 08:59:20 -07:00
Jan Vorlicek 6a47ecf4a8 W^X support (#54954)
* W^X support

This change is the last part of enabling the W^X support. It adds the
actual executable allocator that handles all double mapped memory
allocations and creating the writeable mappings.

The platform specific functionality is placed in a new minipal that is
going to be a basis for future removal of Windows APIs usage from the
native runtime.

The last state of the change was tested on all the platforms that we
support using coreclr pri 1 tests with both the W^X enabled and disabled
using the COMPlus_EnableWriteXorExecute variable.

The debugger changes were tested using the managed debugger testing
suite on Windows x64, x86 and on Apple Silicon so far. Further testing
on other platforms is in progress.

* Replace LeafLock in UMEntryThunkFreeList by a new lock

* Also allocate LoaderHeapFreeBlock from regular heap.

* Set the W^X default to disabled
2021-07-11 16:46:53 +02:00
Manish Godse a2f58177b9 removing more crossgen code from being built. (#54458)
Should improve build times further.
2021-06-21 18:52:40 -07:00
Vladimir Sadov 97477e250c Enable loading composite r2r images from a singlefile bundle (#53739)
* Enable loading composite r2r images from a singlefile bundle
2021-06-18 13:48:22 -07:00
Jan Vorlicek d617e830ec Add writeable holders for executable memory (#53934)
* Add writeable holders for executable memory

This change adds holders for writeable mappings for executable memory.
It is the largest part of the W^X support. The ExecutableWriterHolder
implementation is dummy in this change, but it was fully tested with
coreclr / libraries tests on Windows arm, arm64, x64 and x86 with the
real double memory mapping.
There are few concepts / conventions used:
* When the writeable pointer isn't known at a place where it is needed
  and also not at the caller, the ExecutableWriterHolder instance is
  created.
* When a callee needs writeable pointer to executable memory and caller
  knows RW and RX, the argument is doubled with RX and RW suffixes. For
  constructors and member methods when "this" is the RW one, we pass just
  extra RX argument.
* Locals holding RW  pointer use RW suffix.
* Locals holding RX pointer usually have no suffix to minimize number of
  changes, but in some cases they have a RX suffix
  where I felt like it was better to make things clear.
2021-06-10 15:26:40 +02:00
Aaron Robinson cc8d9b3300 Parse DOTNET_PROCESSOR_COUNT with a 10 radix not 16 (#53208)
* Parse DOTNET_PROCESSOR_COUNT with a 10 radix not 16

* Update test for DOTNET_PROCESSOR_COUNT
2021-05-24 22:42:26 -07:00
Jan Vorlicek 636f89d78e Move metadata off the executable heaps (#52912)
* Move metadata off the executable heaps

This change moves metadata structures that manage blocks of heap memory
out of the heaps in preparation for the W^X changes that will make the
heap memory read-execute only and modifying the metadata would require
unnecessary mappings and unmappings of the memory as read-write.

The structures moved in this change are the following:
* LoaderHeapBlock
* FreeBlock
* HeapList

* Remove unnecessary m_pCurBlock from the UnlockedLoaderHeap
2021-05-20 11:02:22 +02:00
Jeremy Koritzinsky d49bcbe044 Add basic natvis visualizations for some VM types (#52853) 2021-05-19 16:43:37 -07:00
Juan Hoyos 6f5ab2b939 SingleFile diagnostic support - Add export table and DotNetRuntimeInfo to dumps (#52731)
* DACize PEDecoder::GetExport
* Ensure export table and runtimeinfo export are always present in a minidump
2021-05-17 13:40:01 -07:00
Anton Lapounov 65bdceb4d4 Respect Windows job object's CPU quota (#52690) 2021-05-13 20:23:33 -07:00
c1e7ca823f Low level API support for Objective-C interop. (#52146)
* Add Objective-C interop support.

* Include handling of HNDTYPE_REFCOUNTED when FEATURE_OBJCMARSHAL is defined (#47534)

* Allow overriding of Objective-C message send P/Invokes (#47721)

* Add new flag to MethodTable for types with ObjectiveCTrackedTypeAttribute.
Discover attribute during type load and set bit.
Update EagerFinalizer callout to query bit.

* Add testing for API

* Bridge API for propagating managed exception to native.

* Update GCEE interface to support GCServer scenario for Objective-C.
The new callbacks now fire when before the GC scans handles and is
non-concurrent.

* Comment added for ExceptionTracker non-NULL condition.

Co-authored-by: Jeremy Koritzinsky <[email protected]>
Co-authored-by: Elinor Fung <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
2021-05-13 12:04:46 -07:00
Peter Sollich 1b09a384f2 Stresslog fixes (#52601)
- Make regular (non-memory-mapped file based) stresslog work for clrgc.dll
- Fix interaction issue between GC and thread filters in StressLogAnalyzer
- Interpret small numbers for COMPlus_StressLogSize and COMPlus_TotalStressLogSize as GB rather than bytes
- Increment SOS_BREAKING_CHANGE_VERSION
2021-05-13 10:43:11 +02:00
Anton Lapounov 28ec201940 Allow overriding processor count via configuration setting (#52492) 2021-05-11 15:32:46 -07:00
Vladimir SadovandVitek Karas 711424876b Singlefile: enabling compression for managed assemblies. (#50817)
* enable compression of assemblies

* fix Unix build

* map should use converted layout for compressed

* enable execution for R2R

* fixes for OSX

* PR feedback (comments)

* more PR feedback

* shorter include path to pal_zlib.h

* Apply suggestions from code review

Co-authored-by: Vitek Karas <[email protected]>

Co-authored-by: Vitek Karas <[email protected]>
2021-04-14 19:00:31 -07:00
Elinor Fung f6b344b64a Remove IAssemblyName (and various fusion remnants) (#50755) 2021-04-06 21:11:04 -07:00
Aaron Robinson fbdcec9060 Support DOTNET_ prefix (#50507)
* Support and prefer DOTNET_ prefix.

Add support for EnableDOTNETPrefix to disable respecting the DOTNET_ prefix.

Enable environment variable caching on non-Windows platforms.
2021-04-01 10:20:22 -07:00
Aaron Robinson 99d6215ef2 Merge REGUTIL logic for environment variables into CLRConfig (#50393)
* Merge REGUTIL logic for environment variables into CLRConfig

Remove REGUTIL
Remove unused CLR configuration options
2021-03-30 20:51:24 -07:00
Aaron Robinson d2613848ef Clean up REGUTIL/CLRConfig system (#50314)
* Convert all configuration options from REGUTIL to CLRConfig.

* Remove uses of REGUTIL outside of CLRConfig impl.
2021-03-29 13:58:50 -07:00
fe8bc173df [mono][debugger] Implementing mscordbi to support iCorDebug on mono runtime (#47639)
* Implementing mscordbi on mono to support icordebug

* Fix eval, fix step and cancel step, remove suspend status on mscordbi

* Using log from coreclr as mscordbi does

* Missing files

* Removing eglib from implementation

* Compiling on Mac

* Compiling and Working on windows.
Changing what @lambdageek suggested about mono_atomic_inc_i32

* Generating libmscordbi on mac

* Fix socket on mac

* Counting references, deleting objects, removing unecessary properties,
formating with cland-format, renaming properties to follow the used
pattern.

* Checking error when get reply from debugger

* Fix format, reuse regmeta from coreclr and try to fix compilation on
windows

* Dont build when target is android or ios or wasm

* Fix error unused variable

* Fixing error: 'CFUserNotificationDisplayAlert' is unavailable: not
available on macCatalyst

* Fix compilation error on Linux

* Fix function not found in maccatalyst
Fix warning as error of macro redefinition

* Dont compile mscordbi on maccatalyst

* Fix compilation on linux

* Fix compilation on android, ios and browser

* Fix compilation on linux

* Fix cross compiling

* Fix compilation x86 windows

* Fix x86 compilation

* Fix compilation on windows

* Fix cmake error

* Fix cmake

* Fix arm64 mac

* Fix windows compilation

* Fix memory leak

* Returning E_NOTIMPL where it was possible and it's not implemented as
suggested by @cshung

* Fix what @cshung

* Use only one ref count

* Adding ex_try everywhere that we could have an allocation failure.

* Implementing get class

* Apply suggestions from code review

Co-authored-by: Noah Falk <[email protected]>

* Fix what @noahfalk suggested in his review.

* Fixing what was suggested by @viniciusjarina

* Fix what was suggested by @viniciusjarina

* Changing what @noahfalk suggested

* Accept more than 1 stepper per thread

* Changing what was suggested by @noahfalk

* Using CORDB_ADDRESS to return addresses from debugged process

* Fix eval

* Update src/mono/mono/mini/debugger-agent.c

Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>

* Using 1:1 with runtime for cordbtype and cordbclass

* Rnaming methods as suggested by @lambdageek

* Update src/mono/dbi/cordb-process.h

Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>

* Update CMakeLists.txt

* Fix arm64 compilation

* Fix arm64 compilation

* Fix error cmake

* fix arm64 compilation

* Fix arm64 compilation

* Fix arm64 compilation

* Fix arm64 compilation

* Revert "Fix arm64 compilation"

This reverts commit 25f24bc7ac66966fe59805e54e4009c909608b2c.

* Revert "Fix arm64 compilation"

This reverts commit a8f0318881d7b3e6b5a69b1b56c17478a71fdb4f.

* Revert "fix arm64 compilation"

This reverts commit b5de06dcf00bf296f2c8f4b47aa2492afbd73acd.

* Revert "Fix error cmake"

This reverts commit 2aae4636499d073ca5aa6fb9319d84875be6e08e.

* Revert "Fix arm64 compilation"

This reverts commit ae5f701589c3bd8ca04b9d9369af2b285a5d9bd0.

* Revert "Fix arm64 compilation"

This reverts commit 94d957c7416a900c9e90dec53900a104572ea6a1.

* Removing arm64 compilation

* Remove arm64 compilation

Co-authored-by: Noah Falk <[email protected]>
Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
2021-03-12 14:00:59 -03:00
Peter Sollich 1f866d2c3b Dprintf optimization (#47046)
This is support for putting the stress log into a memory mapped file and piping the dprintf calls in the GC codebase to the stress log.

It's much faster than the dprintf implementation we used before and doesn't take a lock for each dprintf call - only when it needs to get a new buffer. It also works for clrgc.dll, which accounts for some complications, because now calls can come from either coreclr.dll or clrgc.dll.

There is logic inside src/coreclr/util/StressLog.cpp to switch to the memory mapped file when the new environment variable COMPLUS_StressLogFilename is set. Here's a set of environment variables I've used:

COMPLUS_StressLogFilename=GCPerfSimStresslog.log
COMPLUS_gcServer=1
COMPLUS_LogLevel=9
COMPlus_StressLog=1
COMPlus_StressLogSize=10000000
COMPlus_TotalStressLogSize=1000000000

So this creates a max of 64 GB of stress log.

There is an analyzer tool to go with this under src/coreclr/tools/StressLogAnalyzer that is also part of this checkin. The tool is expected to become more sophisticated over time. The tool is itself multithreaded and uses a plugin dll for the actual analysis which makes it possible to change the plugin, rebuild and re-run the analysis on the in-memory log datastructure without reloading the log file.

The stresslog mechanism had a limit of 7 arguments so far, which seemed too small, so I've increased that to 12 currently. It can easily be increased up to 63, which is the limit in the format. The higher number of arguments is only supported when putting the stress log into a file, it is not yet supported when building the stress log in memory the traditional way. 

Supporting it would call for changes in SOS that I haven't done yet. However, stress logs containing no calls of more than 7 arguments would be dumped correctly by the current SOS - SOS would crash though with stress logs containing calls with more arguments. To catch this early, the logic in StressLog.cpp does a debug break when a call with more than 7 arguments is attempted without the memory-mapped file.

Note that for the purposes of GC logging, the logging level specified in the dprintf call is also persisted in the stress log. This makes it possible to selectively dump messages from specific subsystems.
2021-02-25 14:37:24 +01:00
David Wrighton 4f3545e2d1 Adjust logic in cor.h, corhdr.h, corinfo.h, corjit.h and such so that they may be included without the PAL (#46055)
This was done via simple substitution of the standard sized integer types, and dealing with the fallout. It is tested by using the ICorJitInfo interface directly within the crossgen2 jitinterface thunk library.

Effort was made to use a minimum number of casts, as casts in such a large change are likely to be wrong somewhere.
- Exceptions are the use of casting to handle some calls to the existing internal metadata api and around use of char16_t.

In addition, a small amount of logic from the PAL headers were pulled into the proper header to allow compilation in the presence of some SAL annotation, and other small details.
2021-02-17 19:03:19 -08:00
Jan Kotas 00832c828c Delete fallback to load mscorrc.dll from current directory (#47464) 2021-01-26 14:41:39 -08:00
Koundinya Veluri e42de0e2de Update Environment.ProcessorCount on Windows to take into account the processor affinity mask (#45943)
- Similarly to cases on Unixes where sched_getaffinity is available
- If `GCCpuGroup` and `Thread_UseAllCpuGroups` are both enabled, I'm not sure if the `CPUGroupInfo` count of active processors takes affinity into account as the docs are not clear, for now I'm not modifying that path until I can verify it
- Otherwise, a process that is started with a specific processor affinity mask still shows full CPU count
- This is one of the differences in the portable managed thread pool implementation, which relies on Environment.ProcessorCount, as opposed to the native thread pool, which uses the affinity mask
- After this change, in affinitized cases on Windows the behavior is consistent perf-wise with Linux in similar situations:
  - The portable thread pool uses the same worker thread count as the native thread pool
  - `Environment.ProcessorCount` returns the number of processors the the process is affinitized to, which may be less than it would have returned before
2021-01-25 12:21:48 -08:00
Tomáš Rylek 69e114c1ab December infra rollout - remove duplicated 'src' from coreclr subrepo (src/coreclr/src becomes src/coreclr) (#44973)
* Move src/coreclr/src/Directory.Build.targets to src/coreclr
Merge src/coreclr/src/CMakeLists.txt into src/coreclr/CMakeLists.txt

* Mechanical move of src/coreclr/src to src/coreclr

* Scripts adjustments to reflect the changed paths
2020-12-08 03:19:44 +01:00