summaryrefslogtreecommitdiff
path: root/src/utilcode
AgeCommit message (Collapse)AuthorFilesLines
2019-01-14Large version bubble Support (#21727)Andon Andonov1-2/+22
* 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 runtests.py * 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-10Normalize a few more spin-wait loops (#21586)Koundinya Veluri3-38/+15
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-02Delete lstrlen from Unix PAL (#21745)Jan Kotas1-1/+1
strlen/wcslen works just fine.
2018-12-26desktop port (#21523)Maoni Stephens1-0/+11
+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-11-20Delete CORCOMPILE_IMPORT_TABLE_ENTRY (#21109)Jan Kotas1-50/+0
2018-11-15Fixed signatures of ref readonly methods in JIT ETW events (#20981)szehetner1-42/+81
* fixed ETW method signature of ref readonly methods * added type token * extract method for printing classes * fixed optional_modifier, use CorSigUncompressToken_EndPtr
2018-11-06Code review feedbackAndrew Au1-60/+59
2018-11-06Removing unnecessary hacksAndrew Au1-60/+60
2018-11-06Initial data breakpoint changesCagri (Charlie) Aslan1-1/+2
temporary changes towards multiple data breakpoints add multiple hardware bp support Remove Complus.log revert log.cpp changes
2018-10-31Clean up string literal implicit const casting and some two-phase lookup ↵Jeremy Koritzinsky2-2/+2
nits on Windows (#20730) * Remove implicit c-string const casting and clean up some C++ standards conformance bugs. * Fix const string conversion in FCSigCheck.
2018-10-08Remove mentions of Rotor from codebase (#20298)Austin Wise1-90/+0
* Moving parsing from TypeNameParser ctor to a separate method. It seems a bit odd to have the constructor parsing and then use a dummy method (MakeRotorHappy) to make it look more normal. * Remove CorMarkThreadInThreadPool. It is neither referenced nor exported. * Remove reference to rotor from securitywrapper.h * Remove reference to rotor from Strike/vm.cpp. This file is only built for Windows. * Remove reference to rotor from debugreturn.h This is the only file the defines these macros, so there is no need to undef them first. * Remove unused code refering to rotor from PAL. * Remove references to Rotor from PAL. * Remove references to deleted tests from DisabledTests.txt I can't find any evidence that this file is actually used. * Remove unneeded casts. * Remove dead and misleading code from profilinghelper.cpp. FEATURE_PROFAPI_EVENT_LOGGING is always defined when PROFILING_SUPPORTED is defined. And the entire contents of profilinghelper.cpp is surrounded with "ifdef PROFILING_SUPPORTED". So all sections in "ifndef FEATURE_PROFAPI_EVENT_LOGGING" are dead. Furthermore, in coreclr this does not use the eventlog, so the macro name is misleading. * Remove dead code in excep.cpp. This entire function is surrounded with "ifndef FEATURE_PAL". * Remove refererences to rotor from safemath.h This does not appear to cause any compile problems, so nobody was using safemath.h without _ASSERTE defined. Also S_SIZE_T_WP64BUG is not used anywhere. * Remove dead code from palclr.h. I don't know why these check to see if the macro is undefined immediately after defining them. Also the comment appears to reference some unions that are no longer in this file. * Expose ISymUnmanagedWriter2 from SymWriter as required by COM. The comment talks about the C# compiler using this, however I cannot see a way for the C# compiler to get an instance of this. It is only used internally by AssemblyBuilder and not exposed otherwise. * Restore check for _ASSERTE in safemath.h. On Windows sometimes that this file is included without _ASSERTE being defined. As the existing comment suggests, it appears that SOS explicitly does not want _ASSERTE to do anything.
2018-08-28Break into debugger on assertion failures (#19702)Jan Kotas1-9/+6
* Break into debugger on assertion failures Assertion failures terminated the process by default that made them hard to debug. Changed them to break into debugger or trigger fail fast when the debugger is not attached. This should make the day-to-day CoreCLR developer experience better and it is simular to what we had on .NET Framework in the past. * Fix Unix build break Add RaiseFailFastException to Unix PAL
2018-08-25Remove NumaNodeInfo, CPUGroupInfo, AppDomain, SystemDomain, and EEConfig ↵David Mason1-2/+2
stubs from local gc (#19500) * Switch NumaNodeInfo and CPUGroupInfo to the interface * Remove AppDomain/SystemDomain stubs * remove EEConfig methods * Port numa code to the coreclr side * add numa back to PAL and standalone builds * enable numa for PAL/Standalone builds, and fix BOOL warnings * remove unused defines, and fix linux build errors * building on windows * about to delete numa work from unix and want a backup * add stubs for unix numa/cpugroup * Code review feedback * Code review feedback
2018-08-23Enable unloading of AssemblyLoadContext (#18476)Jan Vorlicek1-2/+5
Enable assembly unloading * Allow PInvoke methods on collectible assemblies * Fix test unloadability Several hundreds of tests were using Helper class that created GCHandle, but never freed it. That prevented unloading of those tests. The change modifies the Helper class to keep the handle in a finalizable object. Several GCHandle related tests were not freeing the GCHandle they allocated, so this change adds freeing them to enable the unloading. * Add missing error messages to the resources * Fix shuffle thunk cache for unloadability * Add GetLoaderAllocator to ICLRPrivBinder
2018-08-02Remove unused/nop/questionable code (#19239)Aaron Robinson1-114/+1
* Remove unused holder code * Remove NOP `IsV2RuntimeLoaded()` usage. * Remove unused/nop/questionable code in util * Remove unused V2Profiler message from resource
2018-07-31Delete FEATURE_IPCMAN (#19212)Jan Kotas2-4/+0
2018-07-19Fix opinfo: InlineR should only read 8 bytes (#18801)sunnycase1-1/+0
2018-07-17 Add pooling for JIT scratch memory (#18924)Jan Kotas2-79/+1
Fixes #3408
2018-07-16Apply tiering's call counting delay more broadly (#18610)Koundinya Veluri1-6/+19
Apply tiering's call counting delay more broadly Issues - When some time passes between process startup and first significant use of the app, startup perf with tiering can be slower because the call counting delay is no longer in effect - This is especially true when the process is affinitized to one cpu Fixes - Initiate and prolong the call counting delay upon tier 0 activity (jitting or r2r code lookup for a new method) - Stop call counting for a called method when the delay is in effect - Stop (and don't start) tier 1 jitting when the delay is in effect - After the delay resume call counting and tier 1 jitting - If the process is affinitized to one cpu at process startup, multiply the delay by 10 No change in benchmarks.
2018-06-24Removed dead strings used in debug-only code (#18622)hsharber1-655/+0
Removed strings used in debug-only code in ex.cpp Fix #18420
2018-06-03Warnings cleanup (#18260)Robin Sue6-7/+2
* Cleanup all disabled warnings that do not trigger * Fix warning about line continuation in single line comment * Eliminiate all unreferenced local variables and reenable warning
2018-05-27Typo (#18141)John Doe2-2/+2
* Ajusted -> Adjusted * alot -> a lot * Ambigous -> Ambiguous * amoun -> amount * amoung -> among * Amperstand -> Ampersand * Anbody -> Anybody * anddoens't -> and doesn't * anme -> name * annoations -> annotations * annother -> another * anothr -> another * ansynchronous -> asynchronous * anticpation -> anticipation * anway -> anyway * aother -> another * Apparant -> Apparent * appartment -> apartment * appdmomain -> appdomain * Appdomian -> Appdomain * appdomin -> appdomain * approproiate -> appropriate * approprate -> appropriate * approp -> appropriate * appened -> appended * appropiately -> appropriately * appropraitely -> appropriately * Apperantly -> Apparently * approp. -> appropriate * Approriate -> Appropriate
2018-05-24Typo (#18122)John Doe4-4/+4
* acquringing -> acquiring * Activ -> Active * activley -> actively * acutal -> actual * bIncomingIPAdddefed -> bIncomingIPAddRefed * adddr -> addr * readding -> reading * Addfunction -> AddFunction * additionnal -> additional * Additonal -> Additional * Additonally -> Additionally * Addresss -> Address * addtion -> addition * aded -> added * aditional -> additional * adjustements -> adjustments * Adress -> Address * afer -> after * aformentioned -> aforementioned * afte -> after * agains -> against * agaisnt -> against * aggresively -> aggressively * aggreates -> aggregates * aggregious -> egregious * aginst -> against * agregates -> aggregates * Agressive -> Aggressive * ahve -> have * ajdust -> adjust * ajust -> adjust * alement -> element * algoritm -> algorithm * alighnment -> alignment * alignmant -> alignment * constraits -> constraints * Allcator -> Allocator * alllocate -> allocate * alloacted -> allocated * allocatate -> allocate * allocatoror -> allocator * alloctaed -> allocated * alloction -> allocation * alloted -> allotted * allt he -> all the * alltogether -> altogether * alocate -> allocate * alocated -> allocated * Alocates -> Allocates * alogrithm -> algorithm * aloocate -> allocate * alot -> a lot * alwasy -> always * alwyas -> always * alwys -> always
2018-04-05Rename conflicting definitions VER_MAJOR/MINORVERSION macros (#17364)Jan Kotas1-11/+8
* Rename conflicting definitions of VER_MAJOR/MINORVERSION These macros are defined by Windows SDK. They were overload to mean CLR version that was causing interesting redefinition issues. * Delete workaround for redefined Windows SDK macros * Delete ProjectN version * Delete dead code
2018-03-31Delete dead code to support OSes prior to Windows 7 (#17367)Jan Kotas1-111/+1
2018-03-24Delete some unused functions (#17193)mikedn1-92/+0
2018-03-24Delete unused files from src/inc (#17186)Jan Kotas3-171/+0
2018-03-19Delete unused downlevel globalization support (#17022)Jan Kotas5-4144/+3
Delete ENABLE_DOWNLEVEL_FOR_NLS and everything under it
2018-03-13Revert "Revert "Fix handling of incorrect assemblies on Unix (#16747)" ↵Jan Kotas1-1/+2
(#16790)" (#16917) This reverts commit 47bef69b68a35eafa069d08187727684a5f47901.
2018-03-06Revert "Fix handling of incorrect assemblies on Unix (#16747)" (#16790)Jan Kotas1-2/+1
This reverts commit 383736b96b643ba46ad290fc86601fc2d62a9436.
2018-03-05Fix handling of incorrect assemblies on Unix (#16747)Ruben Ayrapetyan1-1/+2
* Return DPTR from PEDecoder::FindFirstSection() Change type of the function's return value to PTR_IMAGE_SECTION_HEADER instead of (IMAGE_SECTION_HEADER *) * Fix handling of incorrect assemblies on Unix This fixes the regression that was introduced by #10772 and is caused by a missing check for validity of loaded assembly file. Related issue: #15544
2018-02-17delete unused mirror files (#16423)Sergey Andreenko5-5/+0
2018-01-23Delete dead code (#15990)Jan Kotas1-15/+0
2018-01-19Revert "Change just-in-time debugging registry keys. (#15722)" (#15921)Mike McLaughlin1-5/+5
This reverts commit 8b2cac974db3edde38e1a555455f53592d03b68e.
2018-01-12LoaderHeap: remove LHF_ZEROINIT option.Konstantin Baladurin1-15/+4
This option was used for UMEntryThunkCode::Poison. Now we use own free list to store freed thunks and don't return allocated memory to the LoaderHeap. So reused thunks are always uninitialized.
2018-01-05Change just-in-time debugging registry keys. (#15722)Mike McLaughlin1-5/+5
From "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug" to "SOFTWARE\Microsoft\.NETCore\JITDebugging".
2017-12-02Delete sortversioning.cpp/h (#15345)Jan Kotas3-897/+0
Fixes #8403
2017-11-30Jumpstub fixes (#15296)Jan Kotas1-2/+2
- Reserve space for jump stubs for precodes and other code fragments at the end of each code heap segment. This is trying to ensure that eventual allocation of jump stubs for precodes and other code fragments succeeds. Accounting is done conservatively - reserves more than strictly required. It wastes a bit of address space, but no actual memory. Also, this reserve is not used to allocate jump stubs for JITed code since the JITing can recover from failure to allocate the jump stub now. Fixes #14996. - Improve algorithm to reuse HostCodeHeap segments: Maintain estimated size of the largest free block in HostCodeHeap. This estimate is updated when allocation request fails, and also when memory is returned to the HostCodeHeap. Fixes #14995. - Retry JITing on failure to allocate jump stub. Failure to allocate jump during JITing is not fatal anymore. There is extra memory reserved for jump stubs on retry to ensure that the retry succeeds allocating the jump stubs that it needs with high probability. - Respect CodeHeapRequestInfo::getRequestSize for HostCodeHeap. CodeHeapRequestInfo::getRequestSize is used to throttle code heap segment size for large workloads. Not respecting it in HostCodeHeap lead to too many too small code heap segments in large workloads. - Switch HostCodeHeap nibble map to be allocated on regular heap as part. It simplied the math required to estimate the nibble map size, and allocating on regular heap is overall goodness since it does not need to be executable.
2017-11-27Improve Monitor scaling (#14216)Koundinya Veluri1-1/+2
Improve Monitor scaling and reduce spinning Part 1: Improve Monitor scaling Fixes https://github.com/dotnet/coreclr/issues/13978 - Refactored AwareLock::m_MonitorHeld into a class LockState with operations to mutate the state - Allowed the lock to be taken by a non-waiter when there is a waiter to prevent creating lock convoys - Added a bit to LockState to indicate that a waiter is signaled to wake, to avoid waking more than one waiter at a time. A waiter that wakes by observing the signal unsets this bit. See AwareLock::EnterEpilogHelper(). - Added a spinner count to LockState. Spinners now register and unregister themselves and lock releasers don't wake a waiter when there is a registered spinner (the spinner guarantees to take the lock if it's available when unregistering itself) - This was necessary mostly on Windows to reduce CPU usage to the expected level in contended cases with several threads. I believe it's the priority boost Windows gives to signaled threads, which seems to cause waiters to much more frequently succeed in acquiring the lock. This causes a CPU usage problem because once the woken waiter releases the lock, on the next lock attempt it will become a spinner. This keeps repeating, converting several waiters into spinners unnecessarily. Before registering spinners, I saw typically 4-6 spinners under contention (with delays inside and outside the lock) when I expected to have only 1-2 spinners at most. - It costs an interlocked operation before and after the spin loop, doesn't seem to be too significant since spinning is a relatively slow path anyway, and the reduction in CPU usage in turn reduces contention on the lock and lets more useful work get done - Updated waiters to spin a bit before going back to waiting, reasons are explained in AwareLock::EnterEpilogHelper() - Removed AwareLock::Contention() and any references (this removes the 10 repeats of the entire spin loop in that function). With the lock convoy issue gone, this appears to no longer be necessary. Perf - On Windows, throughput has increased significantly starting at slightly lower than proc count threads. On Linux, latency and throughput have increased more significantly at similar proc counts. - Most of the larger regressions are in the unlocked fast paths. The code there hasn't changed and is almost identical (minor layout differences), I'm just considering this noise until we figure out how to get consistently faster code generated. - The smaller regressions are within noise range Part 2: Reduce Monitor spinning Fixes https://github.com/dotnet/coreclr/issues/13980 - Added new config value Monitor_SpinCount and Monitor spins for that many iterations, default is 30 (0x1e). This seems to give a somewhat decent balance between latency, fairness, and throughput. Lower spin counts improve latency and fairness significantly and regress throughput slightly, and higher spin counts improve throughput slightly and regress latency and fairness significantly. - The other constants can still be used to disable spinning but otherwise they are no longer used by Monitor - Decreased the number of bits used for tracking spinner count to 3. This seems to be more than enough since only one thread can take a lock at a time, and prevents spikes of unnecessary CPU usage. Tried some things that didn't pan out: - Sleep(0) doesn't seem to add anything to the spin loop, so left it out. Instead of Sleep(0) it can just proceed to waiting. Waiting is more expensive than Sleep(0), but I didn't see that benefit in the tests. Omitting Sleep(0) also keeps the spin loop very short (a few microseconds max). - Increasing the average YieldProcessor() duration per spin iteration improved thorughput slightly but regressed latency and fairness very quickly. Given that fairness is generally worse with part 1 of this change above, it felt like a better compromise to take a small reduction in throughput for larger improvements in latency and fairness. - Tried adding a very small % of lock releases by random wake a waiter despite there being spinners to improve fairness. This improved fairness noticeably but not as much as decreasing the spin count slightly, and it was making latency and throughput worse more quickly. After reducing the % to a point where I was hardly seeing fairness improvements, there were still noticeable latency and throughput regressions. Miscellaneous - Moved YieldProcessorNormalized code into separate files so that they can be included earlier and where needed - Added a max for "optimal max normalized yields per spin iteration" since it has a potential to be very large on machines where YieldProcessor may be implemented as no-op, in which case it's probably not worth spinning for the full duration - Refactored duplicate code in portable versions of MonEnterWorker, MonEnter, and MonReliableEnter. MonTryEnter has a slightly different structure, did not refactor that. Perf - Throughput is a bit lower than before at lower thread counts and better at medium-high thread counts. It's a bit lower at lower thread counts because of two reasons: - Shorter spin loop means the lock will be polled more frequently because the exponential backoff does not get as high, making it more likely for a spinner to steal the lock from another thread, causing the other thread to sometimes wait early - The duration of YieldProcessor() calls per spin iteration has decreased and a spinner or spinning waiter are more likely to take the lock, the rest is similar to above - For the same reasons as above, latency is better than before. Fairness is better on Windows and worse on Linux compared to baseline due to the baseline having differences between these platforms. Latency also has differences between Windows/Linux in the baseline, I suspect those are due to differences in scheduling. - Performance now scales appropriately on processors with different pause delays Part 3: Add mitigation for waiter starvation Normally, threads are allowed to preempt waiters to acquire the lock. There are cases where waiters can be easily starved as a result. For example, a thread that holds a lock for a significant amount of time (much longer than the time it takes to do a context switch), then releases and reacquires the lock in quick succession, and repeats. Though a waiter would be woken upon lock release, usually it will not have enough time to context-switch-in and take the lock, and can be starved for an unreasonably long duration. In order to prevent such starvation and force a bit of fair forward progress, it is sometimes necessary to change the normal policy and disallow threads from preempting waiters. A new bit was added to LockState and ShouldNotPreemptWaiters() indicates the current state of the policy. - When the first waiter begins waiting, it records the current time as a "waiter starvation start time". That is a point in time after which no forward progress has occurred for waiters. When a waiter acquires the lock, the time is updated to the current time. - Before a spinner begins spinning, and when a waiter is signaled to wake, it checks whether the starvation duration has crossed a threshold (currently 100 ms) and if so, sets ShouldNotPreemptWaiters() When unreasonable starvation is occurring, the lock will be released occasionally and if caused by spinners, spinners will be starting to spin. - Before starting to spin, if ShouldNotPreemptWaiters() is set, the spinner will skip spinning and wait instead. Spinners that are already registered at the time ShouldNotPreemptWaiters() is set will stop spinning as necessary. Eventually, all spinners will drain and no new ones will be registered. - After spinners have drained, only a waiter will be able to acquire the lock. When a waiter acquires the lock, or when the last waiter unregisters itself, ShouldNotPreemptWaiters() is cleared to restore the normal policy.
2017-11-07Delete dead code (#14901)Jan Kotas1-57/+0
2017-10-27Delete dead code (#14703)Jan Kotas1-1508/+0
2017-10-16Delete dead code (#14521)Jan Kotas1-343/+1
2017-10-11Delete !FEATURE_IMPLICIT_TLS (#14398)Jan Kotas2-284/+0
Linux and Windows arm64 are using the regular C/C++ thread local statics. This change unifies the remaining Windows architectures to be on the same plan.
2017-09-14Fix crossgen memory mappings (#13972)Jan Vorlicek1-0/+4
This change removes executable memory mappings from crossgen. Now it can be run on systems with PAX set to prevent executable mappings without any marking using the paxctl.
2017-08-14Added SetThreadDescription to set the unmanaged thread name (#12593)Alois-xx1-0/+39
* Added SetThreadDescription to set the unmanaged thread name as well when a managed thread name was set. This will show up in future debuggers which know how to read that information or in ETW traces in the Thread Name column. * use printf instead of wprintf which exists on all platforms. * Removed printf Ensure that GetProceAddress is only called once to when the method is not present. Potential perf hit should be negligible since setting a thread name can only happen once per managed thread. * - Moved SetThreadName code to winfix.cpp as proposed - Finalizer and threadpool threads get their name - GCToEEInterface::CreateBackgroundThread is also named - but regular GC threads have no name because when I included utilcode.h things did break apart. * Fix for data race in g_pfnSetThreadDescription * Fix string literals on unix builds. * Fixed nits Settled thread name on ".NET Core ThreadPool"
2017-08-09Fixed issue #13282. (#13291)Mike McLaughlin1-1/+1
Changed the open process token from TOKEN_READ to TOKEN_QUERY.
2017-07-31 Fill freed loader heap chunk with non-zero value (#12731)Jonghyun Park1-9/+26
* Add FEATURE_LOADER_HEAP_GUARD feature * Invoke memset only for reclaimed regions * Enable FEATURE_LOADER_HEAP_GUARD by default * Insert trap inside UMEntryThunk::Terminate * Make all exectuable heaps not to zero-initialize itself Use fZeroInit (instead of fMakeRelazed) * Add comment * Revert unnecessary changes * Add and use 'Poison' method to insert a trap * Do NOT invoke FlushInstructionCache * Update comment * Add comment on ARM Poisoning instruction * Use X86_INSTR_INT3 instead of 0xCC
2017-07-26[Arm64] Enable CPUGroupInfo (#12766)Steve MacLean1-10/+10
2017-07-21Add CGroup CFS CPU limit support (#12797)Guillaume B1-17/+28
2017-07-17Fix alignment of reads in MD5Transform. (#12800)Ruben Ayrapetyan1-1/+13