path: root/src/vm
AgeCommit message (Collapse)AuthorFilesLines
2019-07-18Add ASan wrapper for jit callbacks from external code (AMD64)sandbox/ches01/asan_amd64Vyacheslav Cherkashin3-49/+289
Signed-off-by: Vyacheslav Cherkashin <>
2019-07-17Add ASan wrapper for extern external calls (AMD64)Vyacheslav Cherkashin3-0/+214
Signed-off-by: Vyacheslav Cherkashin <>
2019-02-14prestub: fix ExternalMethodFixupWorkersubmit/tizen/20190419.143735submit/tizen/20190419.042330submit/tizen/20190416.152950submit/tizen/20190410.105333submit/tizen/20190405.141848submit/tizen/20190327.110559submit/tizen/20190312.130143submit/tizen/20190312.123654submit/tizen/20190312.102237accepted/tizen/unified/20190422.045933Konstantin Baladurin1-1/+5
Use DispatchToken::CreateDispatchToken to get token to resolve virtual method in case of non interface MT.
2019-02-14Fix EECodeManager::GetAmbientSP on x86/LinuxIgor Kulaychuk1-1/+2
2019-01-22Restrict HW intrinsic name check to intrinsic types (#22116)Michal Strehovský1-18/+18
Avoids having to compare names of all types in CoreLib to see if they're HW intrinsics.
2019-01-22Do not throw from TraceResolver (#22126)Michal Strehovský1-3/+5
Fixes #22059.
2019-01-22Move MemoryFailPoint to shared CoreLib partition (#22104)Filip Navara7-79/+22
* Move MemoryFailPoint to shared CoreLib partition. * Split MemoryFailPoint into Unix and Windows versions. * Replace MemoryFailPoint.GetMemorySettings FCall with GC.GetSegmentSize to make sharing with CoreRT easier.
2019-01-20Cleanup array related FCalls (#22097)Jan Kotas10-235/+44
* Cleanup Array FCalls * Disable outdated CoreFX tests
2019-01-19Cleanup: Remove MethodDesc::GetLoaderAllocatorForCode (#22067)Jan Vorlicek12-30/+16
This function was recently changed to just return the MethodDesc::GetLoaderAllocator. This is a cleanup that removes the function completely and replaces all of its usages.
2019-01-19Removed unused 'Stack Walking' code (#22039)Matt Warren1-43/+0
As fair as I can tell `ECWGCFCrawlCallBack(..)` is not wired-up anywhere (I've successfully compiled CoreCLR locally with this change under `x86` and `x64`)
2019-01-18Add Per-assembly Load Native Library callbacks (#21555)Swaroop Sridhar7-68/+162
Add Per-assembly Load Native Library callbacks This Change implements the Native Library resolution Call-backs proposed in
2019-01-18Handle complex constrained calls with default interface methods (#21978)Michal Strehovský1-0/+31
This adds handling for the interface dispatch corner case where: * We have a constrained callsite to a method on a generic interface in shared code * The callsite cannot be statically resolved because the result of dispatch depends on the generic context * At runtime, the dispatch resolves to a default interface method This would require us to have infrastructure to build "boxing thunks" - thunks that would box their first argument before dispatching to the default interface method implementation. Since this is a corner case and the fix is actually quite involved, we're making the runtime just throw in this situation. The test is written so that it should pass both if the runtime chooses to throw, or if the runtime makes the boxing thunk (we're not hardcoding the implementation limitation).
2019-01-18Use correct resolution scope when checking default implementations (#22036)Michal Strehovský1-3/+5
We need to use the module of the interface. Fixes #22021.
2019-01-18Add comments on headers that gets parsed by Mono linker for whoever touches ↵Sung Yoon Whang3-0/+18
this next (#22054) * Add comments on headers that gets parsed by Mono linker for whoever touches this next * add more comments to the targets file
2019-01-15On SIGTERM default to a non-zero exit code (#21300)Tom Deseyn1-3/+17
* On SIGTERM default to a non-zero exit code * Fix Windows builds * Improve SIG_DFL/SIG_IGN handling * Remove PAL_GetTerminationExitCode * Use sa_handler/sa_sigaction based on SA_SIGINFO; remove HAVE_SIGINFO_T. * configure.cmake: remove siginfo_t check * Move restore_signal_and_resend so OSX can use it; add function documentation * Fix OSX build: include pal/process.h for gPID * Check SIG_IGN and SIG_DFL against sa_handler * Don't use sa_handler when SA_SIGINFO is set * Fix equality check * Swap order of checking SA_SIGINFO and SIG_IGN/SIG_DFL
2019-01-15Large version bubble Support (#21727)Andon Andonov9-19/+58
* Preliminary Changes * Module Index Resolution * Change infoModule encoding * Change referencing module in R2R * Pre-condition Check * Virtual Method Module Resolution * Remove Workarounds and add conditional import loading * Add signature kind module override * Add ELEMENT_TYPE_MODULE_ZAPSIG * Add switch to enable large version bubble * Cleanup * Change Native header check * Add large version bubble test * Add Large Version Bubble Checks * Cleanup * Revert unnecessary check * Change EncodeMethod Version Bubble Condition * Add Large Version Bubble asserts * Cleanup * Add default argument to * Change test PreCommands * Revert whitespace changes * Change breaking conditional check * Streamline Version Bubble test * Address PR Feedback * Address PR Feedback #2 * Remove dead code * Add crossgen-time ifdef
2019-01-15Finding Standalone GC and CoreDisTools in non-standard host testing (#21983)Aaron Robinson2-57/+24
* Use GetInternalSystemDirectory() as the directory for standalone GC * Use GetInternalSystemDirectory() as the directory for coredistools
2019-01-15Removing noisy R2R compilation outputs, and putting them under the /verbose ↵Fadi Hanna1-1/+2
switch (#21987)
2019-01-14Custom Marshalers in custom-ALC-loaded assemblies results in types loaded ↵Jeremy Koritzinsky15-142/+157
from crossing ALCs (#21606) * Create repro for dotnet/coreclr#19654 * Update ICustomMarshaler.csproj * Update ICustomMarshaler.csproj * Clean up repro per feedback. * Add test case for different assemblies with the same CustomMarshaler name. * Move EEMarshalingData cache from AppDomain to LoaderAllocator. This fixes the custom-marshaler conflict when using unloadable assembly contexts. * Internalize the LoaderHeap* parameter. * Add the pointer to the requesting assembly to the hashtable key. * Fix linux-musl build break. * Move Crst out of FEATURE_COMINTEROP block. * Make sure to copy over the assembly pointer to the key that's actually stored in the hash table. * Add comment for m_invokingAssembly. * Move all usages of EEMarshallingData to hang off the correct loader allocator instead of always the global one. * Change to m_InteropDataCrst since this EEMarshallingData can be used in preemptive GC mode. * Always init m_InteropDataCrst (since it's used by EEMarshallingData as well as COM). * PR Feedback. * Remove extraneous inlines.
2019-01-13Add NativeLibrary Resolve Event (#21929)Swaroop Sridhar4-27/+104
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: The ResolveEventTests triggered a pre-existing bug in the exception handling code (#21964). Disabling the test on ARM64 Windows until the issue is fixed.
2019-01-12Patch vtable slots and similar when tiering is enabled (#21292)Koundinya Veluri37-299/+1757
Patch vtable slots and similar when tiering is enabled For a method eligible for code versioning and vtable slot backpatch: - It does not have a precode (`HasPrecode()` returns false) - It does not have a stable entry point (`HasStableEntryPoint()` returns false) - A call to the method may be: - An indirect call through the `MethodTable`'s backpatchable vtable slot - A direct call to a backpatchable `FuncPtrStub`, perhaps through a `JumpStub` - For interface methods, an indirect call through the virtual stub dispatch (VSD) indirection cell to a backpatchable `DispatchStub` or a `ResolveStub` that refers to a backpatchable `ResolveCacheEntry` - The purpose is that typical calls to the method have no additional overhead when code versioning is enabled Recording and backpatching slots: - In order for all vtable slots for the method to be backpatchable: - A vtable slot initially points to the `MethodDesc`'s temporary entry point, even when the method is inherited by a derived type (the slot's value is not copied from the parent) - The temporary entry point always points to the prestub and is never backpatched, in order to be able to discover new vtable slots through which the method may be called - The prestub, as part of `DoBackpatch()`, records any slots that are transitioned from the temporary entry point to the method's at-the-time current, non-prestub entry point - Any further changes to the method's entry point cause recorded slots to be backpatched in `BackpatchEntryPointSlots()` - In order for the `FuncPtrStub` to be backpatchable: - After the `FuncPtrStub` is created and exposed, it is patched to point to the method's at-the-time current entry point if necessary - Any further changes to the method's entry point cause the `FuncPtrStub` to be backpatched in `BackpatchEntryPointSlots()` - In order for VSD entities to be backpatchable: - A `DispatchStub`'s entry point target is aligned and recorded for backpatching in `BackpatchEntryPointSlots()` - The `DispatchStub` was modified on x86 and x64 such that the entry point target is aligned to a pointer to make it backpatchable - A `ResolveCacheEntry`'s entry point target is recorded for backpatching in `BackpatchEntryPointSlots()` Slot lifetime and management of recorded slots: - A slot is recorded in the `LoaderAllocator` in which the slot is allocated, see `RecordAndBackpatchEntryPointSlot()` - An inherited slot that has a shorter lifetime than the `MethodDesc`, when recorded, needs to be accessible by the `MethodDesc` for backpatching, so the dependent `LoaderAllocator` with the slot to backpatch is also recorded in the `MethodDesc`'s `LoaderAllocator`, see `MethodDescBackpatchInfo::AddDependentLoaderAllocator_Locked()` - At the end of a `LoaderAllocator`'s lifetime, the `LoaderAllocator` is unregistered from dependency `LoaderAllocators`, see `MethodDescBackpatchInfoTracker::ClearDependencyMethodDescEntryPointSlots()` - When a `MethodDesc`'s entry point changes, backpatching also includes iterating over recorded dependent `LoaderAllocators` to backpatch the relevant slots recorded there, see `BackpatchEntryPointSlots()` Synchronization between entry point changes and backpatching slots - A global lock is used to ensure that all recorded backpatchable slots corresponding to a `MethodDesc` point to the same entry point, see `DoBackpatch()` and `BackpatchEntryPointSlots()` for examples Due to startup time perf issues: - `IsEligibleForTieredCompilation()` is called more frequently with this change and in hotter paths. I chose to use a `MethodDesc` flag to store that information for fast retreival. The flag is initialized by `DetermineAndSetIsEligibleForTieredCompilation()`. - Initially, I experimented with allowing a method versionable with vtable slot backpatch to have a precode, and allocated a new precode that would also be the stable entry point when a direct call is necessary. That also allows recording a new slot to be optional - in the event of an OOM, the slot may just point to the stable entry point. There are a large number of such methods and the allocations were slowing down startup perf. So, I had to eliminate precodes for methods versionable with vtable slot backpatch and that in turn means that recording slots is necessary for versionability.
2019-01-11Enable returning more complex structures via PInvoke returns. (#21470)Jeremy Koritzinsky3-45/+30
* Add test verifying behavior in dotnet/coreclr#19676. * Clean up test code. * Test what happens if we enable returning structures by value. * Use braced initializer. * Update Decimal tests to expect that returning a decimal by LPStruct or Currency works. * Change handle-in-struct marshalling to expect a NotSupportedException thrown at marshal time instead of expecting a MarshalDirectiveException at signature time. * Update Decimal Reverse-PInvoke tests. * Disable some previously disabled return marshalling types and add a nice comment block explaining why they're disabled. * Enable marshalling DateTime return values and add a test. * Rename IsUnuspportedValueTypeReturn * Add return test for ArrayWithOffset * Remove extraneous P/Invoke. * Fix spelling. * Add test for successfully returning a struct that has one field of a type that is return-type blocked. * Add explicit struct return test. * Clean up tests. * Fix grammer. * Add test for struct whose managed layout doesn't require a stdcall return buffer but whose native layout does. * Add test verifying HandleRef behavior. * Clean up IsUnsupportedTypedefReturn per PR feedback.
2019-01-11Flowing the nativeCodeVersion to DebuggerJitInfo (#21925)Andrew Au9-19/+31
2019-01-11Add cleanup of the TypeIDMap at unload time (#21943)Jan Vorlicek5-0/+60
The TypeIDMap is stored in the AppDomain and contains two hash maps - id to MethodTable and MethodTable to id. We were missing removing entries for MethodTables that belong to a LoaderAllocator that's being destroyed. Thus we were leaking some memory, but also causing potential issue. When at some point after the LoaderAllocator destruction a MethodTable gets the same address as one of the MethodTables that was destroyed in the past and was also recorded in the TypeIDMap, we would incorrectly reuse the id. That is problematic in case the old MethodTable didn't require fat id and the new does or vice versa. I've hit assert due to that while running System.Numerics.Vectors.Tests inside an unloadable AssemblyLoadContext. The implementation of the fix is very primitive. It is expected that we will be able to get rid of the TypeIDMap in a near future and so it is not worth optimizing.
2019-01-11Normalize a few more spin-wait loops (#21586)Koundinya Veluri13-149/+24
Normalize a few more spin-wait loops - Fixed a few more spin-waits to normalize the spin-wait duration between processors - These spin-waits have so far not needed to be retuned to avoid unreasonably long spin-wait durations. They can be retuned as necessary in the future. - Added a version of YieldProcessorNormalized() that normalizes based on spin-wait counts tuned for pre-Skylake processors for spin-wait loops that have not been retuned. - Moved some files around to make YieldProcessorNormalized() and the like available in more places. Initialization is still only done in the VM. Uses outside the VM will use the defaults, where there would be no significant change from before. - Made YieldProcessor() private outside of the GC and added System_YieldProcessor() for when the system-defined implementation is intended to be used
2019-01-09Fix DynamicMethodDesc memory leak (#21891)Jan Vorlicek4-63/+47
The DynamicMethodTable::AddMethodsToList was incorrectly allocating the MethodDescChunk from the domain's LoaderAllocator instead of the context specific one. Thus the allocated memory was leaking after a collectible AssemblyLoadContext was collected. There was also a problem with the DynamicMethodDesc::Destroy being called twice for collectible classes - once by RuntimeMethodHandle::Destroy() and once when the DomainFile destructor was called. Due to the primary issue, this problem was not visible, since the domain's LoaderAllocator is never unmapped. But it started to cause AV after the primary issue was fixed.
2019-01-09Remove extraneous eightbytes check for native structures and add tests. (#21590)Jeremy Koritzinsky2-12/+33
* Remove extraneous eightbytes check and add tests. * Interger -> Integer * Missed Helper.cs * Handle field sizes larger than 8 bytes in AssignClassifiedEightByteTypes * Move CoreFX test case into CoreCLR. Fix the SystemV eightbyte classifier to correctly classify the second eightbyte when a single field crosses the eightbyte boundary (such as an in-place array of three 4-byte enums). * Enable passing user defined structs in in-place arrays in a structure if SystemV ABI expects it. * Correctly handle a field spanning two full eightbytes. * Just directly assign 0 to accumulatedSizeForEightByte * Change multi-eightbyte field handling to be a loop as per PR feedback. * Remove extraneous whitespace.
2019-01-09Merge pull request #21867 from adityamandaleeka/fix_writebarrier_bounds_checkAditya Mandaleeka1-3/+15
Fix write barrier bounds checks for ARM64 Unix.
2019-01-08Extract cleanup changes from #21793. (#21852)Jeremy Koritzinsky6-45/+85
* Cleanup changes from #21793. * Emit the data pointer offset directly into the IL stream (and calculate it as needed instead of passing it through) * Fix broken assumption that OverrideProcArgs::na::m_pMT is the array type instead of the element type (which it was).
2019-01-08Fix write barrier bounds checks for ARM64 UnixAditya Mandaleeka1-3/+15
2019-01-08Update ceemain.cpp (#21869)Will Cohen1-1/+1
2019-01-07Remove CAS era security checks around resource loads (#21825)Filip Navara8-49/+10
2019-01-06Move Native Library APIs to NativeLibrary class (#21821)Swaroop Sridhar7-79/+111
Move APIs that manipulate native libraries from System.Runtime.InteropServices.Marshal class to the new System.Runtime.InteropServices.NativeLibrary class. In API review: #32015, The LoadLibrary APIs were originally Approved to live in System.Runtime.InteropServices.Marshal class. However, recently the decision was changed such that the APIs are in a new NativeLibrary class.
2019-01-04Delete unused fFullReset argument (#21814)Jan Kotas7-43/+10
2019-01-04Avoid passing stack crawl mark unnecessarily deep in the call stack. (#21783)Filip Navara4-32/+21
* Avoid passing stack crawl mark unnecessarily deep in the call stack. * Move stack crawl from TypeName::GetTypeManaged to RuntimeTypeHandle::GetTypeByName.
2019-01-04Add test for StringBuilder null terminator implementation detail (#21800)Jeremy Koritzinsky1-11/+3
* Remove some commented out code. * Add test verifying that we put a null terminator 2-past the end of the native buffer allocated for a StringBuilder.
2019-01-04Adds portable version of EncodingTable (#21735)Marek Safar3-16/+0
* Adds portable version of EncodingTable Most of the implementation is extracted from CoreRT * Use string comparer directly * Remove no longer used COMNlsInfo * Adds localization support * Removes FeatureCoreFxGlobalization configuration * Remove redudant encodings look up from GetEncoding * Keep Hashtable for nameToCodePage as it does not lock on read * Replace locked dictionary lookup with short switch * Include comment with msbuild task link used to generate the data file
2019-01-03Cleanup current culture handling in the unmanaged runtime (#21706)Jan Kotas11-651/+87
Large portion of the current culture handling in the unmanaged runtime inherited from desktop has been no-op. The nativeInitCultureAccessors QCall that it used to depend on desktop got (almost) never called in CoreCLR. - Delete resetting of current culture on threadpool threads. It was needed in desktop because of a very tricky flow of current culture between appdomains. It is superseded by the flowing the current culture via AsyncLocal in CoreCLR. - Comment out fetch of managed current culture for unmanaged resource lookup. It has number of problems that are not easy to fix. We are not localizing the unmanaged runtime currently anyway, so it is ok to just comment it out. - Fix the rest to call CultureInfo directly without going through Thread.CurrentThread
2019-01-03Remove unnecessary propagation of stack crawl marks. (#21781)Filip Navara8-20/+10
2019-01-02Delete lstrlen from Unix PAL (#21745)Jan Kotas3-26/+26
strlen/wcslen works just fine.
2019-01-02Simplify and improve integer overflow checks in Interop (#21732)Jan Kotas1-6/+5
- Delete unnecessary CheckStringLength calls for result of string.Length. Managed strings are guaranteed to be under 2GB bytes, so these checks were unnecessary. - Add `checked(...)` around buffer size computations that may hit potential integer overflow. It does not look like any of these would cause a bug that would lead to buffer overrun, but it is better to catch these early.
2019-01-02strlen to managed code and vectorize (#21729)Ben Adams6-22/+8
2019-01-01Cleanup ArgumentNull_Obj references in unmanaged runtime (#21738)Jan Kotas3-12/+12
2018-12-31Improve MdUtf8String (#21720)Ben Adams3-22/+0
* Move MdUtf8String::EqualsCaseSensitive to managed code * Move MdUtf8String.ToString to safe code * Use Encoding.UTF8.GetString
2018-12-31Add license, keep more of the CriticalHandle logic in the shared fileJan Kotas1-1/+1
2018-12-29Move CultureInfo to shared CoreLib (#21672)Filip Navara3-16/+14
* Move thread CurrentCulture and CurrentUICulture variables to CultureInfo. * Move CultureInfo to shared CoreLib * Code style fixes for consistency. * Fold down APPX code into CultureInfo.CurrentCulture/CurrentUICulture. * Remove unnecessary parentheses around return statements. * Remove GetCurrentUICultureNoAppX.
2018-12-29Fix warning causing error in warning as error (Windows) (#21697)Ben Adams1-1/+1
2018-12-26desktop port (#21523)Maoni Stephens12-15/+112
+alloc lock split into SOH and LOH +provisional mode to fix too many gen2 GCs triggered in low mem situation when the heap has heavy pinning fragmentation +better free list usage +premature OOM fixes +3 new configs: GCHeapAffinitizeMask, GCHighMemPercent, GCLOHThreshold (will be documented) YieldProcessor scaling factor is different on core due to the different implementation on core.
2018-12-24Fix warning causing error in warning as error (Windows) (#21656)Ben Adams1-3/+3
2018-12-22Improve removal of dead calls to allocator helpers.Eugene Rozenfeld4-7/+58
This change improves detection of allocators with side effects. Allocators can cause side effects if the allocated object may have a finalizer. This change adds a pHasSideEffects parameter to getNewHelper JitEE interface method. It's used by the jit to check for allocator side effects instead of guessing from helper ids. Fixes #21530.