summaryrefslogtreecommitdiff
path: root/src/vm/methodtable.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-04-15Use NewArrayHolder for array types (#24017)Omair Majid1-3/+3
This touches all the code outside of src/debug/. Using a NewHolder with array types means that when the holder is ready to release the memory, it ends up invoking `delete` (instead of `delete[]`) on that array. This is an undefined behaviour. Use NewArrayHolder instead to fix this.
2019-04-08Allow reabstraction of default interface methods (#23313)Michal Strehovský1-6/+56
Allow the runtime to load types with incomplete interface implementations. With this change, we allow (in pseudo-C#): ```csharp interface IFoo { void Frob() { } } interface IBar : IFoo { abstract void IFoo.Frob() } class Fooer : IBar { } ``` Calling IFoo.Frob on an instance of `Fooer` will result in new exception being thrown because the default implementation of `IFoo.Frob` was re-abstracted by `IBar`.
2019-04-05Fix issue 23713: handle TypeDesc field handles (#23767)Fadi Hanna1-1/+2
2019-04-04Fix SystemV AMD64 Explicit structure classification (#22041)Jeremy Koritzinsky1-136/+210
* Don't bail out on enregistering explicit structs if there are no overlapping fields. * Don't enregister if any unaligned fields. * Enable passing explicit structs by-value by enregistering on systemv. Some edge cases are likely still broken, but just removing our blanket opt-out makes the current tests pass. * Enable MarshalstructAsLayoutExp off-Windows. * Start adding additional tests for explicit layout to try to catch edge cases in SystemV classification. * Added a test that spans across multiple eightbytes and has an overlap in the second eightbyte. * Change repro to use an array of floats and an int field in managed and use a float array for padding in native to force an SSE classification on the first byte. * New algorithm to calculate eightbyte classification by going throw the structure byte-by-byte instead of field-by-field. * Fix updating eightbyte classifications in the loop to actually used the iterated-upon variable. * Consider each element of a fixed array as a separate field (to match native implementations). * Implement correct SystemV classification for fixed buffers in non-blittable structures. Fixed buffers in blittable structures have the managed layout assign classifications, which still is buggy. * Add tests. * Correctly classify blittable fixed buffers. Move "is this field a fixed buffer" tracking into one of the unused bits in FieldDesc as code that isn't in marshalers needs to know about it. * Handle the case where we have a struct that has no fields in an eightbyte that contains (i.e. no fields in the first eight bytes of the structure). * PR feedback. * Only look up FixedBufferAttribute when the type is a value class and the type of the field is a value type. * Use heuristic to determine if a type is a fixed buffer for SystemV classification. * Revert tracking if a field is a fixed buffer in the FieldDesc. * Update comments. * Classify aligned, nonoverlapping, float/double only structures as HFAs even if explicitly laid out * Enable overlapping fields in HFAs. Update NativeType HFA to check for alignment. I checked Godbolt to verify that HFAs for overlapping fields are allowed. * Add HFA tests. * Fix compile errors from HFA alignment check. * Non-valuetypes will never have their managed layout used to classify SystemV eightbytes. * Don't classify a struct with no zero-offset field as an HFA. * Remove duplicate semicolon. * PR feedback. * Add test with 2-field double HFA. * Clean up and add static asserts for struct size. * Add define for static_assert_no_msg to the native test headers * Fix build breaks. * Remove unneeded "size = X bytes" comments. They were holdovers from the .NET Framework test tree. * Use GetNumInstanceFieldBytes instead of GetLayoutInfo()->GetManagedSize() * Fix build break. * Centralize FieldMarshaler offsettting in ClassifyEightBytesWithNativeLayout. * Fix signed/unsigned mismatch * Fix condition to also detect arm64. * Change ifdef to if defined. * Remove duplicate declaration (broken in rebase) * Add some logging in one of the unreproable OSX test failures. * Mark System.Numerics.Vector as intrinsic and don't use the eightbyte classifier to enregister it. * Also explicitly opt-out of HFAs for System.Numerics.Vector`1 for consistency. * Update R2R required version to 3.0. * Remove debugging prints.
2019-04-03Remove ADID and ADIndex from CoreCLR (#23588)David Wrighton1-7/+7
- 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-04-01Enable R2R compilation/inlining of PInvoke stubs where no marshalling is ↵Fadi Hanna1-0/+48
required (#22560) * These changes enable the inlining of some PInvokes that do not require any marshalling. With inlined pinvokes, R2R performance should become slightly better, since we'll avoid jitting some of the pinvoke IL stubs that we jit today for S.P.CoreLib. Performance gains not yet measured. * Added JIT_PInvokeBegin/End helpers for all architectures. Linux stubs not yet implemented * Add INLINE_GETTHREAD for arm/arm64 * Set CORJIT_FLAG_USE_PINVOKE_HELPERS jit flag for ReadyToRun compilations * Updating R2RDump tool to handle pinvokes
2019-02-18Fix constrained call corner cases (#22464)Michal Strehovský1-1/+1
Fixes #22423. I'm still unclear on how JitStress manages to get itself into that situation, but I was able to write a repro that triggers the `!pMDAfterConstraintResolution->IsInterface()` assert using regular IL, so we need to handle that either way. The repro for that is constrained3.il. While figuring out the repro, I wrote a bunch of other test code and found another bug (constrained2), where we would box in a situations that doesn't require boxing (canonically ambiguous situation where there's a suitable default interface implementation and a valuetype implementation of the constrained method that does not requires boxing once we no longer deal with __Canon).
2019-02-15Fix bug in FindDispatchSlot usageAaron Robinson1-10/+4
2019-02-03Throw the right exception when interface dispatch is ambiguous (#22295)Michal Strehovský1-1/+1
Throw the approved exception per dotnet/corefx#34124.
2019-01-23Remove all traces of FEATURE_STACK_PROBE. (#22149)Filip Navara1-46/+1
2019-01-11Patch vtable slots and similar when tiering is enabled (#21292)Koundinya Veluri1-2/+1
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-09Remove extraneous eightbytes check for native structures and add tests. (#21590)Jeremy Koritzinsky1-10/+27
* 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.
2018-12-21Improve removal of dead calls to allocator helpers.Eugene Rozenfeld1-0/+26
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.
2018-12-14Implement two pass algorithm for variant interface dispatch (#21355)Michal Strehovský1-5/+34
Fixes #20452.
2018-12-03Remove IsNeutralDomain() (#21318)Steve MacLean1-14/+1
* Remove IsNeutralDomain() * PR feedback
2018-12-01Enable COM interop for collectible classes (#20919)Jan Vorlicek1-2/+4
* 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-29Enable type equivalence (#21265)Aaron Robinson1-37/+37
* 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-2/+1
2018-11-26Disable domain neutral loading (#21156)Jan Kotas1-17/+0
2018-11-21Delete dead/unused code (#21138)Jan Kotas1-1/+1
2018-11-15Allow supressing exceptions in diamond inheritance cases (#20458)Michal Strehovský1-26/+42
2018-11-13Handle generics in methodimpls for default interface methods (#20404)Michal Strehovský1-29/+51
The existing logic looking at MethodImpls to find the default interface implementation was not correct in the presence of generics. The MethodImpl records we build during type load only contain inexact MethodDescs for the declMethod that are not suitable for comparisons. The fix is to pipe through the token and resolve the declaring method from it at the time of dispatch.
2018-11-09Delete dead/unreachable code related to remoting (#20880)Jan Kotas1-56/+9
2018-10-11Enable BSTR Field Marshaller for x-plat (#20264)Luqun Lou1-1/+1
2018-10-04Enable thread statics for collectible classes (#19944)Jan Vorlicek1-2/+2
* Enable thread statics for collectible classes This change removes checks that were preventing usage of thread statics in collectible classes and also implements all the necessary changes. The handles that hold arrays with thread statics are allocated from LoaderAllocator for collectible classes instead of using the global strong handle like in the case of non-collectible classes. The change very much mimics what is done for regular statics. This change also adds ability to reuse freed handles to the LoaderAllocator handle table. Freed handle indexes are stored into a stack and when a new handle allocation is requested, the indices from this stack are used first. Due to the code path from which the FreeTLM that in turn frees the handles is called, I had to modify the critical section flags and also refactor the handle allocation so that the actual managed array representing the handle table is allocated out of the critical section. When I was touching the code, I have also moved the code that was dealing with handles that are not stored in the LoaderAllocator handle tables out of the critical section, since there is no point in having it inside of it.
2018-10-04Remove AppDomain unload (#20250)Jan Vorlicek1-1/+1
* 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-08-11Make RuntimeType sealed and deleted support for introspection only loads ↵Jan Kotas1-40/+3
(#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-29Remove relocations for vtable chunks (#17147)Gleb Balykov1-6/+21
* Separate sections READONLY_VCHUNKS and READONLY_DICTIONARY * Remove relocations for second-level indirection of Vtable in case FEATURE_NGEN_RELOCS_OPTIMIZATIONS is enabled. Introduce FEATURE_NGEN_RELOCS_OPTIMIZATIONS, under which NGEN specific relocations optimizations are enabled * Replace push/pop of R11 in stubs with - str/ldr of R4 in space reserved in epilog for non-tail calls - usage of R4 with hybrid-tail calls (same as for EmitShuffleThunk) * Replace push/pop of R11 for function epilog with usage of LR as helper register right before its restore from stack
2018-06-04Work in VM towards cross-bitness crossgen (#18245)Egor Chesakov1-1/+1
* Replace sizeof expressions with target-specific constants: * sizeof(ObjHeader) -> OBJHEADER_SIZE * sizeof(Object) -> OBJECT_SIZE * ObjSizeOf(Object) -> OBJECT_BASESIZE * sizeof(ArrayBase) -> ARRAYBASE_SIZE * ObjSizeOf(ArrayBase) -> ARRAYBASE_BASESIZE * Remove ObjSizeOf macro * Use OBJECT_SIZE in ArrayBase::GetBoundsOffset * Cast ppObj to CORCOMPILE_GCREFMAP_TOKENS* before dereferencing in FakePromote * LOG2_PTRSIZE should depend on _TARGET_64BIT_
2018-04-17Unix/x64 ABI cleanupCarol Eidt1-2/+2
Eliminate `FEATURE_UNIX_AMD64_STRUCT_PASSING` and replace it with `UNIX_AMD64_ABI` when used alone. Both are currently defined; it is highly unlikely the latter will work alone; and it significantly clutters up the code, especially the JIT. Also, fix the altjit support (now `UNIX_AMD64_ABI_ITF`) to *not* call `ClassifyEightBytes` if the struct is too large. Otherwise it asserts.
2018-03-27Enable reflection load ComImport assembly and Type.IsComObjectType (#16943)Luqun Lou1-4/+0
* Enable reflection load ComImport assembly and Type.IsComObjectType * Update Enable reflection load ComImport assembly
2018-02-22Remove relocations for MethodTable::m_pParentMethodTable for Linux ARM (#15915)gbalykov1-11/+24
2018-02-13Fix ambiguous interface method error message (#16341)Michal Strehovský1-1/+1
Fixes #15864.
2018-01-19Updating the VM to no longer treat the SIMD HWIntrinsic types as HFA or ↵Tanner Gooding1-0/+37
MultiReg structs.
2018-01-13Revert "Remove relocations for MethodTable::m_pParentMethodTable for Linux ARM"Jan Kotas1-18/+13
This reverts commit cf1fb9e17fc8b6ee849edab5a696d0ec5c6eadd2.
2017-12-13Fix formatting and put more things under #ifMichal Strehovský1-64/+67
2017-09-14Use an unsigned variable to avoid comparison problems (#14001)David Wrighton1-3/+3
2017-09-13Merge branch 'master' into update_from_masterDavid Wrighton1-80/+146
2017-08-17Fix linux build break (#13441)Yi Zhang (CLR)1-4/+0
2017-08-15Finalize override lookup algorithm (#12753)Yi Zhang (CLR)1-30/+147
* first cut of multiple candidates * new positive case for diamond shape * Add proper missing implementation detection and positive diamond shape scenario support. Untested * fix bug and get test to pass * Add more diamond shape pos/neg tests * Fix bad I8 * Add GVM tests to diamond shape * GVM working * Change test case to better match diamondshape scenario * Fix MethodImpl::Iterator::GetMethodDesc and optimize no-method impl scenario * Update methodimpl test to include multiple slots and fix a bug * Temporarily disable incremental build in this branch * Update methodimpl to include multiple methodipml overriding scenario. This is triggering some bugs and need to investigate * Fix a buffer overrrun bug with interface methodimpl * Update after self-review * Add proper methodImpl validation for methods * Address feedback. Refactoring pending
2017-08-08Merge pull request #12168 from gbalykov/remove-relocations-readonlyBruce Forstall1-67/+139
Partially remove relocations from SECTION_Readonly
2017-08-07Cleanup code access security from the unmanaged runtime (#13241)Jan Kotas1-8/+6
2017-07-24Add the runtime code versioning featurenoahfalk1-5/+1
This makes tiered compilation work properly with profiler ReJIT, and positions the runtime to integrate other versioning related features together in the future. See the newly added code-versioning design-doc in this commit for more information. Breaking changes for profilers: See code-versioning-profiler-breaking-changes.md for more details.
2017-07-19Fix build break after rebaseYi Zhang (CLR)1-5/+6
2017-07-19More update in /dev/defaultintf (#11693)Yi Zhang (CLR)1-2/+5
* Support non-virtual calls on interface private members correctly * Support protected methods * Properly handle precode * Throw (tentative) exception when seeing conflict overrides and add a test case (This updates CoreCLR dev/defaultintf the same with the build we are showing at //build)
2017-07-19More update for default interface methods (#10818)Yi Zhang (CLR)1-6/+14
* Support protected methods * add a test for diamond shape scenario and tentatively throw exception when that happens
2017-07-19Default Interface Method Prototype (#10505)Yi Zhang (CLR)1-93/+264
* allow non-zero RVA on abstract interface method in ilasm * Revert "allow non-zero RVA on abstract interface method in ilasm" This reverts commit eecb8024e58f14a20e5e49359f38019f5768ac41. * add a test case and allow virtual non-abstract method in ilasm * allow non-abstract methods in the loader * fixup dispatch map * support for simple default interface method scenario * fix a bug with incorrect usage of MethodIterator skpping the first method. add a test case for overriding but it may not be what we want * add another simple test case for base class * allow private/internal methods in ilasm and add a explict impl test * update reference to mscorlib in il test * add shared generics and variance case * allow interface dispatch to return instantiating stubs with the right PARAM_TYPE calling conv * simple factoring and add a valuetype test case * add a test case for generic virtual methods * a bit more refactoring by moving the CALLCONV_PARAMTYPE logic inside getMethodSigInternal * support explicit methodimpl and remove implicit methodimpl test case * update test cases to give more clear output * Fix a bug where GetMethodDescForSlot chokes on interface MethodDesc without precode. This is accdentally discovered by methodimpl test case when iterating methods on a default interface method that has already been JITted * cleanup code after review and add a bit more comments * update comments * only use custom ILAsm for default interface methods tests - some tests are choking on CoreCLR ilasm for security related stuff * address comments and allow instance methods, and add a constraint value type call test scenario * disable the failing protected method scenario
2017-07-10Remove relocations for MethodTable's vtable-1st-level-indirectionGleb Balykov1-4/+11
2017-07-10Remove relocations for MethodTable::m_pParentMethodTable for Linux ARMGleb Balykov1-13/+18
2017-07-10Remove relocations for MethodTable::m_pPerInstInfo for Linux ARMGleb Balykov1-9/+38