summaryrefslogtreecommitdiff
path: root/src/vm/appdomain.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-04-13Delete COMPlus_FinalizeOnShutdown (#23595)Jan Kotas1-4/+0
This compat quirk is increasingly more broken since the framework is generally not compatible with, and we have not heard anybody actually using it. Changed Environment.HasShutdownStarted to unconditionally return false. It does not make sense for it to ever return true with shutdown finalization disabled.
2019-04-04Runtime support for upcoming .NET Core WinRT Host (#23402)Jeremy Koritzinsky1-0/+3
* First pass at adding winrt host entry-point. * There's no way to specify HResult-swapping on a function called via hosted-interop so just return the HResult instead. * Use the WindowsRuntimeMarshal class to create the activation factory and initialize it. * Implement loading the dependent assemblies of a WinRT assembly into an isolated load context. * PR Feedback. * Fail to get the activation factory if the found type is not a managed type exported from a winmd. * Rearrange parameters based on PR feedback. * Remove unneeded include. * Make ActivationFactoryLoader internal. * Fix null-ref in WinRT-dependent-assembly loading * Remove extraneous "System."
2019-04-03Remove ADID and ADIndex from CoreCLR (#23588)David Wrighton1-844/+46
- Remove concept of AppDomain from object api in VM - Various infrastructure around entering/leaving appdomains is removed - Add small implementation of GetAppDomain for use by DAC (to match existing behavior) - Simplify finalizer thread operations - Eliminate AppDomain::Terminate - Remove use of ADID from stresslog - Remove thread enter/leave tracking from AppDomain - Remove unused asm constants across all architectures - Re-order header inclusion order to put gcenv.h before handletable - Remove retail only sync block code involving appdomain index
2019-03-20Runtime changes for IJW Activation (#22636)Jeremy Koritzinsky1-1/+1
* Implement loading an assembly from an HMODULE on Windows. * Use the native runtime to execute the main method so I don't have to replicate all of the startup behavior. * If ijwhost is loaded, then call back into ijwhost to resolve tokens for vtable entries. * Refactor our various component loaders (COM and IJW) and have IJW load components into separate ALCs when loaded from native. * Move VTableFixups after DeliverSyncEvents in our incremental load. We need the module to be loaded to at least FILE_LOAD_DELIVER_EVENTS when resolving dependencies loaded via VTableFixups, otherwise they try to load into the default ALC. * Only try to get ijwhost module handle on Windows. * Use defined() instead of ifndef * Fix off-Windows build break and fix unvalid comment. * ComponentLoadContext->IsolatedComponentLoadContext * Only build InMemoryAssemblyLoader when targeting windows. * Add doc comments for IsolatedComponentLoadContext. * Rename qcall. * Add comment for boolean parameter. * Add null check for managed ExecuteMainMethod entrypoint. * Add comments in ceeload.cpp for the ijwhost method resolution. * Add test verifying runtime callback to IJW host. * Add test for InMemoryAssemblyLoader.LoadInMemoryAssembly. * Fix x86 behavior rel. loading symbols by name and stdcall mangling. * Remove exe entrypoints. The executable case for mixed-mode will go through the normal .NET Core app model (no special hosting support needed). * Clean up whitespace * Add test verifying M->N->M ALC switch behavior with IJW. * Resolve the ijwhost module by probing the PE for the IJW assembly instead of hardcoding the name. * Remove static caching in GetTokenGetterFromHostModule. * Disable new IJW tests on Win7. * PR Feedback. * Cleanup extra copy of function. * Use old-style environment checking in LoadIjwFromModuleHandle since we reference S.P.CL directly. * Fix break in rebase * Clean up fake mscoree code. * Only validate that a CLR header exists. The OS verifies everything else. * Make ijw host resolution code static to ceeload.cpp * Use bracketed include for xplatform.h * Update comment on _CorDllMain * PR feedback. * Remove .def file. * PR feedback. * Verify we export correctly on x86 and x64. * Fix path to ijwhostmock for CopyConstructorMarshaler * Disable IJW tests on arm32 nightly. Can't repro the dependency load failures. Fixes #23358
2019-03-18Add Utf8String skeleton (#23209)Levi Broderick1-0/+5
Utf8String is an experimental type that is string-like (heap-allocated, immutable, variable-length, null-terminated) but whose inner representation is UTF-8, not UTF-16. This is a skeleton implementation of the basic API shape. The ecosystem of APIs has not yet been built around it. All Utf8String-related code is currently surrounded by ifdefs to allow easy identification and removal from release branches.
2019-03-15Use HKLM for CLSID lookup (#23258)Elinor Fung1-0/+1
* Use HKLM for CLSID lookup * Delete unused functions
2019-03-05Remove dead AppDomain unload code (#23026)Steve MacLean1-290/+0
2019-03-04Remove loose dependency in runtime on System.ComponentModel. (#23010)Aaron Robinson1-42/+0
Remove loose dependency in runtime on System.ComponentModel. Disable test to sync with CoreFX
2019-02-26Fix Assembly::Load context for collectible assemblies (#22494)Jan Vorlicek1-21/+0
* Fix Assembly::Load context for collectible assemblies This change fixes a problem when Assembly::Load is called from an assembly in a collectible AssemblyLoadContext. In that case, we ended up loading it into the default context instead of the context of the calling assembly.
2019-02-21Remove unused perfcounter code (#22742)Sung Yoon Whang1-2/+0
* removing references to COUNTER_ONLY, ENABLE_PERF_COUNTERS in src/vm directory * removing perfcounters* files * Fix build * Remove PerfCounterSupportedBuild * Some more cleanup on the GC side
2019-02-20Abstract deprecated and selectany for GCC and remove LLVM'ism where possible ↵Sinan Kaya1-26/+0
(#22662) * Abstract selectany * Fix initializer element is not constant src/corefx/System.Globalization.Native/pal_icushim.c:58:34: error: initializer element is not constant static const int MaxICUVersion = MinICUVersion + 20; * Enable ms extensions * Apply LLVM patterns to GCC * Remove deprecated function * Fix const conversion error src/corefx/System.Globalization.Native/pal_calendarData.c:390:16: warning: passing argument 1 of ‘ures_close_ptr’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] ures_close(erasResBundle); src/corefx/System.Globalization.Native/pal_calendarData.c:419:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] char* name = GetCalendarName(calendarId); * Remove old compiler option
2019-02-14Replace multi-loaderallocator hash implementation in MethodDescBackpatchInfo ↵David Wrighton1-7/+4
(#22285) * GCHeapHash - Hashtable implementation for runtime use - Implementation written in C++ - Data storage in managed heap memory - Based on SHash design, but using managed memory CrossLoaderAllocatorHash - Hash for c++ Pointer to C++ pointer where the lifetimes are controlled by different loader allocators - Support for add/remove/visit all entries of 1 key/visit all entries/ remove all entries of 1 key - Supports holding data which is unmanaged, but data items themselves can be of any size (key/value are templated types) * Swap MethodDescBackpatchInfo to use the CrossLoaderAllocatorHash * The MethodDescBackpatchCrst needs to be around an allocation - Adjust the Crst so that it can safely be used around code which allocates - Required moving its use out from within the EESuspend logic used in rejit
2019-01-24Remove obsolete thread abortion flags. (#22185)Filip Navara1-1/+1
2019-01-23Remove all traces of FEATURE_STACK_PROBE. (#22149)Filip Navara1-16/+1
2019-01-14Custom Marshalers in custom-ALC-loaded assemblies results in types loaded ↵Jeremy Koritzinsky1-50/+0
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-11Patch vtable slots and similar when tiering is enabled (#21292)Koundinya Veluri1-0/+6
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-11Add cleanup of the TypeIDMap at unload time (#21943)Jan Vorlicek1-0/+14
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-03Remove unnecessary propagation of stack crawl marks. (#21781)Filip Navara1-2/+1
2018-12-21Remove dead ICLRPrivBinder methods (#21637)Steve MacLean1-28/+2
* Remove dead FindAssemblyBySpec All paths returned E_FAIL * Remove dead BinderFlags * Remove dead VerifyBind
2018-12-10Refactor internal System.AppDomain out of CoreLib (#21460)Jan Kotas1-267/+80
Fixes #21028
2018-12-10Delete vm/context.* (#21459)Jan Kotas1-14/+0
* Delete vm/context.* Leftover from remoting
2018-12-05Remove FromGAC & OnTPAList (#21371)Steve MacLean1-18/+0
* Remove FromGAC & OnTPAList * PR feedback
2018-12-03Refactor all FCalls out of AppDomain.cs (#21337)Jan Kotas1-103/+56
This saves the unmanaged->managed->unmanaged trip to initialize the assembly binder. Includes small bits of unrelated cleanup.
2018-12-03Remove IsNeutralDomain() (#21318)Steve MacLean1-4/+3
* Remove IsNeutralDomain() * PR feedback
2018-12-01Enable COM interop for collectible classes (#20919)Jan Vorlicek1-45/+0
* Enable COM interop for collectible classes * Modify DispatchInfo to use LoaderAllocator handles The DispatchMemberInfo was using global handles to refer to the managed MemberInfo instances. That doesn't work with unloadability. This change modifies it to use handles allocated from LoaderAllocator. * Disable COM interop for WinRT types * Remove collectible check from IsTypeVisibleFromCom. That fixes three new COM interop tests * Add collectible check to GetComClassFactory when we check for unsupported interop with WinRT * Add COM unloadability tests Add two tests to test COM unloadability: * One for using native COM server from managed COM client * One for using managed COM objects from native client * Add unloading test for IUnknownTest * Disable NETClientPrimitivesInALC on Win ARM The NETClientPrimitives is disabled there too.
2018-11-30Address PR feedbackSteve MacLean1-2/+1
2018-11-29Enable type equivalence (#21265)Aaron Robinson1-3/+2
* Enable TypeEquivalence feature for Windows platform * Basic test - verified test exercises TypeEquivalence code paths
2018-11-28Delete code related to LoaderOptimization and SharedDomain (#21031)Jan Kotas1-523/+10
2018-11-27Fix ILStubCache allocation for collectible assemblies (#21188)Jan Vorlicek1-3/+0
The ILStubCache was being allocated per domain unless the domain was a compilation AppDomain. This is wrong for collectible assemblies, since after an assembly is collected, the cache keeps stale entries referring to already deleted MethodTables. The fix is to make ILStubChange per LoaderAllocator instead (and keep the per module instances for compilation AppDomain).
2018-11-26Disable domain neutral loading (#21156)Jan Kotas1-29/+1
2018-11-22Delete System.AppDomainSetup (#21157)Jan Kotas1-292/+0
* Delete System.AppDomainSetup Contributes to #21028 * Add test hook for null entry assembly * Validate that the binder paths are absolute
2018-11-21Delete dead/unused code (#21138)Jan Kotas1-29/+1
2018-11-16Fix unloadability races (#21024)Jan Vorlicek1-55/+0
* Fix LoaderAllocator::AllocateHandle When another thread wins the race in growing the handle table, the code was not refreshing the slotsUsed local to the new up to date value. This was leading to overwriting / reusing a live handle. This change fixes it. * Embed ThreadLocalBlock in Thread Instead of allocating ThreadLocalBlock dynamically, embed it in the Thread. That solves race issue between thread destruction and LoaderAllocator destruction. The ThreadLocalBlock could have been deleted during Thread shutdown while the LoaderAllocator's destruction would be working with it.
2018-11-13Change GetAppDomain to return AppDomain from the global static (#20910)Jan Vorlicek1-12/+15
* Change GetAppDomain to return it from the global static The current implementation of the GetAppDomain takes it from the TLS for the current thread. But we only have one AppDomain in the system, so we can change it to return just that one. I have still left the ThreadLocalInfo.m_pAppDomain and its setter present, because SOS uses that to access the AppDomain and the SOS needs to be runtime versino agnostic. This makes it to perform better for Unix where accessing TLS is not trivial. * Move the AppDomain instance pointer to own static To enable access to the one and only AppDomain without unnecessary indirections, I have moved the pointer out of the SystemDomain class.
2018-11-09Delete dead/unreachable code related to remoting (#20880)Jan Kotas1-63/+0
2018-11-09Fix typos in comments (#20908)Li Shengqiu1-1/+1
2018-10-31Clean up string literal implicit const casting and some two-phase lookup ↵Jeremy Koritzinsky1-1/+1
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-17Fix collectible NativeCallable UMThunkEntry lifetime (#20438)Jan Vorlicek1-33/+0
* Fix collectible NativeCallable UMThunkEntry lifetime The UMEntryThunk cache entries created for NativeCallable target methods for collectible classes were not properly cleaned up at the unload time. This change fixes that by adding UMEntryThunkCache on LoaderAllocator and using it for entries belonging to NativeCallable targets on collectible classes. The cache is created lazily. * Reflect PR feedback Remove the UMEntryThunk cache from the AppDomain and leave it just on the LoaderAllocator.
2018-10-05Remove context statics stuff (#20256)Jan Vorlicek1-24/+0
* Remove context statics stuff part 1 This change removes all context statics stuff from the runtime since context statics are not supported and this code was obsolete. * Remove context statics stuff from the debugger code
2018-10-04Remove AppDomain unload (#20250)Jan Vorlicek1-1778/+16
* Remove AppDomain unload This change removes all code in AppDomain that's related to AppDomain unloading which is obsolete in CoreCLR. It also removes all calls to the removed methods. In few places, I have made the change simpler by taking into account the fact that there is always just one AppDomain.
2018-09-14convert HandleStore::_underlyingBucket to a pointer (#19935)David Mason1-1/+1
* convert HandleStore::_underlyingBucket to a pointer * undo _underlyingBucket pointer change and delete Ref_CreateHandleTableBucket * update comment
2018-08-24Very small cleanup of various comments and code formatting (#19665)Vitek Karas1-3/+1
* Very small cleanpu of various comments and code formatting Fixed couple of comments to match the code and the wording. Fixed indentation in several places. Removed unused local variable in AppDomain::BindAssemblySpec * Remove unused enum in the binder
2018-08-23Enable unloading of AssemblyLoadContext (#18476)Jan Vorlicek1-28/+116
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-12Fix a couple of apartment state issues (#19384)Koundinya Veluri1-1/+2
* Fix a couple of apartment state issues Fix for https://github.com/dotnet/coreclr/issues/17822 - The apartment state now defaults to MTA for the main thread along with a CoInitialize - Calling `Thread.SetApartmentState` with STA now fails as expected (different behavior from previous netcore, same behavior as netfx) Fix for https://github.com/dotnet/coreclr/issues/17787 - `WaitHandle.WaitAll` for multiple handles is not supported on an STA thread due to issues described in https://github.com/dotnet/coreclr/issues/17787#issuecomment-385117537 - It now throws `NotSupportedException` as expected (different behavior from previous netcore, same behavior as netfx) Fix for https://github.com/dotnet/coreclr/issues/19225 * Temporarily exclude invalid CoreFX test
2018-08-11Make RuntimeType sealed and deleted support for introspection only loads ↵Jan Kotas1-36/+15
(#19427) - Sealed Runtime makes `is RuntimeType` and similar checks faster. These checks are fairly common in reflection. - Delete support for introspection only loads from the runtime. We do not plan to use in .NET Core. The support for introspection loads inherited from RuntimeType and thus it is incompatible with sealed RuntimeType.
2018-06-15Delete bitrotten appdomain agility checks (#18489)Jan Kotas1-2/+0
Fixes #18484
2018-06-09Avoid NativeOverlapped pinning by allocating unmanaged memory for it (#18360)Jan Kotas1-66/+0
It makes PinnableBufferCache unnecessary
2018-05-27Typo (#18141)John Doe1-1/+1
* 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-04Fix System.String over-allocation (#17876)Jan Kotas1-2/+0
BaseSize for System.String was not set correctly. It caused unnecessary extra 8 bytes to be allocated at the end of strings that had `Length % 4 < 2` on 64-bit platforms. This change makes affected strings proportionally cheaper. For example, `new string('a', 1)` in a long-running loop is 7% faster.
2018-03-19Switch over to managed Marvin implementation for string hashing (#17029)Jan Kotas1-6/+0