Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-07-14Open types can exist as entries in interface map (#55372)David Wrighton
* Open types can exist as entries in interface map - While invalid via the ECMA spec, the runtime currently represents a type explicitly instantiated over its own generic type parameters via the open type MethodTable - This is not strictly correct, as per the spec, these should be represented via an instantiated type, but changing that detail at this time is considered highly risky - This conflicts with the perf optimization around partialy interface loading which uses the open type of an interface to represent a type instantiated in the curiously recurring fashion. - The fix is to detect types instantiated over generic variables, and make them ineligible for the optimization, and to detect those cases where the optimization is ineligible, and revert back to the non-optimized behavior Fixes #55323
2021-07-13Update spin-wait pause/yield normalization (#55295)Koundinya Veluri
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-13Fix UMThunkMarshInfo delete (#55559)Jan Vorlicek
There was a forgotten call to c++ delete that should have been converted to LoaderHeap::BackoutMem in a code path invoked only if two threads raced for allocating the UMThunkMarshInfo and the one that lost the race needed to delete it.
2021-07-13Fix more alloc-dealloc mismatches and use-after-scopes (#55420)Jeremy Koritzinsky
* Fix another dynamically-sized allocation to use new/delete instead of the mismatched new[]/delete. * Fix use-after-scope * Fix another alloc-dealloc mismatch * Update src/coreclr/vm/threadstatics.cpp Co-authored-by: Jan Kotas <jkotas@microsoft.com> * Use standard size_t instead of custom SIZE_T typedef. * Fix formatting. Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2021-07-13Look up the ICustomMarshaler implementation methods based on runtime type ↵Jeremy Koritzinsky
(#55439)
2021-07-12Prevent AV in processinfo2 while suspended (#55379)John Salem
2021-07-11W^X support (#54954)Jan Vorlicek
* 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-11Support filtering ObjectAllocated callback for pinned object heap allocation ↵Yauk
only (#55448) * Prototype allocation profiler * Add callback for pinned objects * Fix the build issue caused by corprof.idl change * Improve the test * Misc changes for the tests Co-authored-by: Andrew Au <andrewau@microsoft.com> Co-authored-by: Yauk Jia <yaujia@microsoft.com>
2021-07-10[Mono] Add Mono Profiler events into EventPipe. (#55264)Johan Lorensson
* Add Mono Profiler events into EventPipe. * Drop callstack on exception_clause profile event. Needed since instrumentation uses mono_profiler_raise_exception_clause used without wrapper and that in turn will cause incomplete stacks due to transitioning into native code without informing unwinder. * Fix build error. * Add support to configure MonoVM diagnostics using env variable. Adding new MONO_DIAGNOSTICS env variable that can include diagnostic specific configs as well as --diagnostic-ports, meaning that its possible to use that instead of DOTNET_DiagnosticPorts variable. It also add variable to set some mono profiler settings needed very early during startup to get GC alloc as well as exception clause checks. In order to set needed options early in process, EventPipe component calls a specific component_init method setting up needed config. * Fix enable/disable callback registrations based on enable/disable bit mask. * Add ability to specify callspec for method instrumentation. Add --diagnostic-mono-profiler-callspec= to accept Mono callspec string. Split keywords to enable method tracing and instrumentation, enables ability to start instrumenting (but not emitting events) in one session and then enable emitting events in later session. If a callspec is used, instrumentation will be enabled on component init. * Only init component once when using static component builds.
2021-07-09Fix helloworld on x86 Linux (#55095)t-mustafin
Make managed->managed call use of ecx, edx to pass first two arguments. Make stack alignment returning after call.
2021-07-09Fix GCMemoryInfo.TotalAvailableMemoryBytes under Wow (#55387)Jan Kotas
Fixes #55126
2021-07-08Fix race condition caused by updating interface map with exact target (#55308)David Wrighton
- Change interface map reading to reliably perform a volatile load (without barrier) - When performing scan for exact interface match/match trhough SpecialMarkerTypeForGenericCasting, be careful to only read the map once and use that value for all comparisons - All other uses of InterfaceMapIterator have been audited, and look to be safe
2021-07-06Add missing startup flags in runtime/start event (#55151)Sung Yoon Whang
2021-07-03Expose and implement generic math interfaces on core types (#54650)Tanner Gooding
* Pin MicrosoftNetCompilersToolsetVersion to a version that supports Static Abstracts in Interfaces * Fixed issues related to enabling generic math in a general sense (#4) - Disable constraint checking during EEInit - Disable il linker running on CoreLib - Fixup generic math tests to actually build * Adding interfaces to support generic math * Implement generic math interfaces on core types * Updating the System.Runtime ref assembly to support generic math * Add a basic xunit test for generic-math * Removing unnecessary nullable annotations * Ensure all preview interface members are explicitly implemented * Don't use var for various methods in Double/Half/Single * Ensure FeatureGenericMath is defined for Mono * Skip generic math tests on Mono WASM due to https://github.com/dotnet/runtime/issues/54910 * Apply suggestions from code review Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com> Co-authored-by: David Wrighton <davidwr@microsoft.com> Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
2021-07-02Add support to DAC for reading tagged memory on tracked types (#54994)Aaron Robinson
* Add support to DAC for reading tagged memory on tracked types * Build error on macOS. * DACize the relevant SyncBlock APIs. Create helper function for tagged memory API querying.
2021-07-01Remove unnecessary Prev field in portable tailcall helpers (#54894)Jakob Botsch Nielsen
GC only ever needs to look at the top dispatcher frame as other dispatchers cannot have live arg buffers, so it is not necessary to keep these linked together. We can save a bit of stack this way. Also update design document that was a bit outdated.
2021-06-30Optionally capture a dump during generational aware analysis (#54517)Andrew Au
2021-06-29Handle marker types with more than 1 generic argument correctly when they ↵David Wrighton
must be materialized into full types (#54875)
2021-06-28Faster type load for scenarios made more common by generic math (#54588)David Wrighton
Change interface map layout in two interesting ways 1. For interface maps defined in System.Private.CoreLib, rely on the C# compiler to prevent any ambiguous duplicates, and to find the full interface expansion, instead of expanding it within the type loader See code marked with #SpecialCorelibInterfaceExpansionAlgorithm - Note that this optimization is only applied for ValueTypes as the presence of inheritance makes the optimization much more complex in many cases, and isn't needed. - This optimization reduces the amount of parsing of the interface implementation table must be done for valuetypes in CoreLib. In particular, with the new interfaces that are added as part of #54650 there is a very deep interface hierarchy that requires a great deal of scanning. As those interfaces are added to all the primitive types, the impact on startup performance is significant and measurable. 2. For interface map expansion that follows the curiously recurring generic pattern, place the open instantiation of the type in the interface map instead of the the exact instantiation, and update all places in the runtime which consider the interface map to deal with that change (Mostly by adding special purpose logic to work with the special marker type in the interface map, but there is also logic to simply force the exact interface type to be loaded, when working with the partially loaded type is not quite good enough, or excessively complex) - This optimization reduces the set of interface types that need to be loaded if they are unused. Of particular benefit are the numerous interfaces associated with the primitive types that are added as part of #54650. Performance of launching an extremely simple .NET process (process with empty main method). Results acquired using local testing on my developer machine, using a simple script that launches the process 500 times in a row. | Before #54650 | After #54650 | After #54650 and #54588 (this pr) | | :-: | :-: | :-: | | 14.1ms | 16.5ms |14.3ms |
2021-06-28Make sure we consider buffer length when marshalling back Unicode ByValTStr ↵Jeremy Koritzinsky
fields (#54695) * Use string constructor that takes length instead of the one that searches for a null terminator. Fixes #54662 * Marshal back buffer size or string to first null terminator, whichever is shorter * Add tests. * Add unicode test. * Use the same implementation style for the wstr case case as the cstr case * Fix accidental deletion from test.
2021-06-28Fix load exception on generic covariant return type (#54790)Wei Zheng
2021-06-28Fix alloc-dealloc mismatches (#54701)Jeremy Koritzinsky
2021-06-27Make DependentHandle public (#54246)Sergio Pedri
* Move DependentHandle to System.Runtime * Update DependentHandle APIs to follow review * Make DependentHandle type public * Update DependentHandle on Mono runtime * Add allocation checks to DependentHandle APIs This avoids throwing ExecutionEngineException-s if one of the public APIs is called on a non-allocated DependentHandle instance * Add more unit tests for new public DependentHandle APIs * Add faster, unsafe internal APIs versions to DependentHandle * Naming improvements to Ephemeron type The ephemeron type is checked in the Mono runtime in "object.c" as follows: m_class_get_image (klass) == mono_defaults.corlib && !strcmp ("Ephemeron", m_class_get_name (klass)) As such, the namespace it belongs to in the managed runtime doesn't matter: the VM will just check that the type name matches, and that the type is in fact defined in corelib. This means we can just move it to System.Runtime without worrying about it being properly managed in the VM. Additionally, the type is defined in "sgen-mono.c" as follows: typedef struct { GCObject* key; GCObject* value; } Ephemeron; So as long as the layout matches the one of the type defined in C# (which it does), we're also free to rename the fields to better follow the naming guidelines, and the VM will have no issues with it. * Code style tweaks, improved nullability annotations * Remove incorrect DependentHandle comment on Mono * Add default Dispose test for DependentHandle Co-authored-by: Stephen Toub <stoub@microsoft.com> * Fix race condition in DependentHandle on Mono * Optimize DependentHandle.nGetPrimary on CoreCLR Removed internal call, same optimization as GCHandle * Small IL codegen improvement in DependentHandle.nGetPrimary * Simplify comments, add #ifdef for using directive * Minor code style tweaks * Change nGetPrimaryAndSecondary to nGetSecondary * Minor code refactoring to DependentHandle on Mono * Rename DependentHandle FCalls * Remove DependentHandle.UnsafeGetTargetAndDependent * Remove DependentHandle.GetTargetAndDependent * Fix FCall path for internal DependentHandle APIs * Add more DependentHandle unit tests * Reintroduce DependentHandle.GetTargetAndDependent() This fixes a bug due to a race condition in ConditionalWeakTable<K, V>, which relies on this method which atomically retrieves both target and dependent with respect to target being set to null concurrently by other threads. This also exposes the same API publically to allow consumers to potentially implement custom conditional weak tables in the same manner. * Minor IL tweaks to produce smaller IR in the JIT * Add DependentHandle.StopTracking() API This also fixes two potential GC holes when setting DependentHandle.Target (see conversation from https://github.com/dotnet/runtime/pull/54246#issuecomment-863285327 onwards) * Rename InternalSetTarget to StopTracking, remove redundant param * Remove FCUnique from InternalStopTracking This was added in https://github.com/dotnet/runtime/pull/39810 to avoid a collision with MarshalNative::GCHandleInternalSet, as the two FCalls had identical implementations and their entry points were not unique. This should no longer be needed after 099fc478551f46cc54e7a18a32d9a9ac73727c73, as that changed both the signature and the implementation of this FCall. * Update API surface to match approved specs from API review * Update DependentHandle XML docs Co-authored-by: Stephen Toub <stoub@microsoft.com>
2021-06-26Fix gc hole in IO thread pool (#54769)David Wrighton
2021-06-26Fix handling of static virtual method implementation checking (#54710)David Wrighton
- It turns out that GetMethodDescFromMemberDefOrRefOrSpec and FindOrCreateAssociatedMethodDesc are not safe to use on a MemberRef whent the associated MethodTable is not fully loaded. - Instead only use that feature when working with a MethodDef or a fully loaded type, and when working with a not fully loaded type, use MemberLoader::FindMethod instead. - When running the resolution algorithm for doing constraint validation, it also is not necessary to fully resolve to the exact correct MethodDesc, which as that process uses FindOrCreateAssociatedMethodDesc needs to be avoided. - The above was not evident as in many cases, the validation algorithm did not run as it was misplaced and located directly before the call to SetIsFullyLoaded. That code path is only followed if the type is able to fully load without circular dependencies. (Test case CuriouslyRecurringGenericWithUnimplementedMethod added to cover that scenario) - In addition, while investigating these issues, I realized we were lacking checks that the constraints on the impl and decl method were not checked at during type load, but that work was instead deferred to dispatch time. Along with the constraint check there was also a set of accessibility checks that had been missed that are common to all MethodImpl handling. Fix by adding tweaking the logic to share most of that code.
2021-06-25Tweak classcompat loader to skip MethodImpls associated with static methods ↵David Wrighton
(#54658)
2021-06-25Fix BackoutJitData (#54711)Jan Vorlicek
* Fix BackoutJitData The RemoveJitData that the BackoutJitData calls requires the code header to be copied to the final location. This change fixes it. I've also found that in one of my previous changes, I've accidentally enabled jitting into a scratch buffer by default by adding the FEATURE_WXORX define unconditionally. So I am removing it in this change for non Apple Silicon, it will be replaced by a dynamic check whether W^X is enabled in the final W^X change.
2021-06-25Move the metadata update related APIs to the MetadataUpdater class (#54590)Mike McLaughlin
Move the metadata update related APIs to the MetadataUpdater class The old APIs AssemblyExtensions.ApplyUpdate() and AssemblyExtensions.GetApplyUpdateCapabilities() will be removed after all the references to them have been changed to the new APIs. Add the new IsSupported API described in issue https://github.com/dotnet/runtime/issues/51159. Change the tests to use the MetadataUpdater APIs. Fix the ApplyUpdate qcalls and icalls Add the ILLink substitutions for MetadataUpdater.IsSupported property Change the old APIs to call the new ones Update mono's MetadataUpdater.IsSupported property Update feature switch doc Fixed the argument checking in coreclr's MetadataUpdater.ApplyUpdate().
2021-06-24Move setting fHasVirtualStaticMethods out of sanity check section (#54574)Tomáš Rylek
2021-06-22Fail COM CoClass creation during construction instead of during jitting (#54508)Jeremy Koritzinsky
2021-06-22Convert some COM object checking functions to managed code (#54471)Aaron Robinson
* Convert COM object checking to managed code * Convert IsComWrapperClass to a managed "can cast to" implementation. * Add testing for updates.
2021-06-22removing more crossgen code from being built. (#54458)Manish Godse
Should improve build times further.
2021-06-18Enable loading composite r2r images from a singlefile bundle (#53739)Vladimir Sadov
* Enable loading composite r2r images from a singlefile bundle
2021-06-18Fix Linux x86 build (#50836)Gleb Balykov
2021-06-17Follow the same failure behavior for [ComImport] classes on Windows with ↵Jeremy Koritzinsky
built-in COM disabled as non-Windows. (#54298)
2021-06-16Remove the `sealed` blittable layoutclass correctness fix because of ↵Jeremy Koritzinsky
backcompat. (#54235)
2021-06-15Add the concept of "notification profilers" to the runtime (#53122)David Mason
2021-06-12Unify macOS ARM64 write protection holders with W^X ones (#54067)Jan Vorlicek
* Unify macOS ARM64 write protection holders with W^X ones This change removes the original holders that were added for changing memory protection for executable code and moves the actual switching to the recently added W^X holders. The unixexports files don't support target specific symbols. So I needed to export a dummy version of the PAL_JitWriteProtect for macOS x64.
2021-06-11Enable devirtualization in more scenarios on crossgen2 (#53567)David Wrighton
Address deficiencies in current devirtualization infrastructure - Remove the responsibility of creating a CORINFO_RESOLVED_TOKEN structure from the JIT and make it a responsibility of the VM side of the jit interface. - This enables the component (crossgen2) which has deeper understanding of the requirements here to correctly handle scenarios that would otherwise require expressing crossgen2 specific details across the jit interface. - Add a new set of fixups (`READYTORUN_FIXUP_Check_VirtualFunctionOverride` and `READYTORUN_FIXUP_Verify_VirtualFunctionOverride`) these are used to validate that the behavior of the runtime and crossgen2 compiler is equivalent for a virtual resolution event - `READYTORUN_FIXUP_Check_VirtualFunctionOverride` will ensure that the virtual resolution decision is the same at crossgen2 time and runtime, and if the decision differs, any generated code affected by the decision will not be used. - `READYTORUN_FIXUP_Verify_VirtualFunctionOverride` will perform the same checks as `READYTORUN_FIXUP_Check_VirtualFunctionOverride`, but if it fails the check, the process will be terminated with a fail-fast. It is intended for use under the `--verify-type-and-field-layout` stress mode. - Currently only the `READYTORUN_FIXUP_Verify_VirtualFunctionOverride` is actually generated, and it is only generated when using the `--verify-type-and-field-layout` switch to crossgen2. Future work will identify if there are scenarios where we need to generate the `READYTORUN_FIXUP_Check_VirtualFunctionOverride` flag. One area of possible concern is around covariant returns, another is around handling of type equivalence. - In order to express the fixup signature for the VirtualFunctionOverride fixups, a new flag has been added to `ReadyToRunMethodSigFlags`. `READYTORUN_METHOD_SIG_UpdateContext` will allow the method signature to internally specify the assembly which is associated with the method token, instead of relying on the ambient context. - R2RDump and the ReadyToRun format documentation have been updated with the details of the new fixups/flags. - Update the rules for handling unboxing stubs - See #51918 for details. This adds a new test, as well as proper handling for unboxing stubs to match the JIT behavior - Also revert #52605, which avoided the problem by simply disabling devirtualization in the presence of structs - Adjust the rules for when it is legal to devirtualize and maintain version resiliency - The VersionsWithCode and VersionsWithType rules are unnecessarily restrictive. - Instead Validate that the metadata is safely checkable, and rely on the canInline logic to ensure that no IL that can't be handled is inlined. - This also involved adding a check that the chain of types from the implementation type to the declaration method table type is within the version bubble. - And changing the `VersionsWithType` check on the implementation type, to a new `VersionsWithTypeReference` check which can be used to validate that the type can be referred to, in combination with using `VersionsWithType` on the type definition. - By adjusting the way that the declMethod is referred to, it becomes possible to use the declMethod without checking the full method is `VersionsWithCode`, and it just needs a relationship to version matching code. - In `resolveVirtualMethod` generate the `CORINFO_RESOLVED_TOKEN` structures for the jit - In particular we are now able to resolve to methods where the decl method is the resolution result but is not within the version bubble itself. This can happen if we can prove that the decl method is the only method which can possibly implement a virtual. - Add support for devirtualization reasons to crossgen2 - Port all devirtualization abort conditions to crossgen2 from runtime that were not already present - Fix devirtualization from a canonical virtual method when the actual implementation is more exact - Fix variant interface override scenario where there is an interface that requires implementation of the variant interface as well as the variant interface itself.
2021-06-10Add writeable holders for executable memory (#53934)Jan Vorlicek
* 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-10Fix2 for Trim HW (#53928)Lakshan Fernando
* Fix for Trim HW * FB
2021-06-09ProcessInfo2 Diagnostics IPC Command (#52258)John Salem
* Stash the entrypoint assembly path * Add ep funcs for accessing entrypoint and version * TODO: get Mono's entrypoint asm * Add ProcessInfo2 command * command includes everything the first one did + product ver and entrypoint asm path * Add a test too * Mono build fixes * fix Mono build * PR feedback * fetch mono info from main assembly * remove ref naming * remove lazy method * handle bundled host * need to test still * Use assembly name * simplify access patterns * change API to utf8 * updated test * update comment * PR feedback * save before I commit this time... * fix merge conflict * Update ds-process-protocol.c add missing break statement from merge conflict fix * Update src/native/eventpipe/ds-process-protocol.h * Update ds-process-protocol.c add missing frees * PR feedback
2021-06-09Fixes Trim HelloWorld (#53912)Lakshan Fernando
2021-06-09Build support for s390x: clr.iltools and clr.paltests (#53289)Ulrich Weigand
* Add dummy support for s390x in vm, jit, debug, and unwinder * This suffices to make clr.iltools and clr.paltests buildable
2021-06-08Fix Apple Silicon shuffle thunks (#53250)Steve MacLean
* Fix Apple Silicon shuffle thunks Fixes 47294 * Set and use m_hfaFieldSize for stack arguments m_hfaFieldSize is needed to calculate correct shuffle size.
2021-06-08Check if the marshalling of a field is possible across all platforms. (#53194)Aaron Robinson
* Check if the marshalling of a field is possible across all platforms. * Add test for the generic field generation for IClassX.
2021-06-08add support for unwinding function fragments in the dac (#53765)David Mason
2021-06-08Implement descr_generations_to_profiler for regions (#53706)Andrew Au
2021-06-07Added some logic to include rcwrefcache references required by ↵alesomas
feature_comwrappers (#53503) * Set rcwrefcache related references only for feature_comwrappers Co-authored-by: Ubuntu <creditsuisse@BuildVM.hqykqmymov3ebcqudt35mscinc.ax.internal.cloudapp.net>
2021-06-05Add background type preloading based on multicorejit (#52595)Gleb Balykov
* Add background type preloading based on multicorejit This is a second part of #48326 change, which enables handling of methods loaded from r2r images. Background thread of multicorejit now not only jits methods but also loads methods from R2R images. This allows to load types in background thread. This is required as part of https://github.com/dotnet/runtime/issues/45748 change (specifically, https://github.com/dotnet/runtime/issues/45748#issuecomment-750889697), goal of which is to enable background type preloading using multicorejit.