summaryrefslogtreecommitdiff
path: root/src/vm/arm/stubs.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-06-18Implement instantiating and unboxing through portable stublinker code… (#106)JUNG DONG-HEON1-884/+41
* Implement instantiating and unboxing through portable stublinker code - Handle only the cases with register to register moves - Shares abi processing logic with delegate shuffle thunk creation - Architecture specific logic is relatively simple - Do not permit use of HELPERREG in computed instantiating stubs - Fix GetArgLoc such that it works on all architectures and OS combinations Add a JIT stress test case for testing all of the various combinations - Use the same calling convention test architecture that was used as part of tail call work Rename secure delegates to wrapper delegates - Secure delegates are no longer a feature of the runtime - But the wrapper delegate lives on as a workaround for a weird detail of the ARM32 abi
2020-03-25[Tizen] Implement ASan wrapper for Linux ARM32Vyacheslav Cherkashin1-0/+8
This commit implements wrappers that allow interception transitions from managed to external unmanaged code (CIL -> native) and back (native -> CIL). This allows enable/disable ASan during transitions. Due to this, we sanitize only external code, which allows us to achieve acceptable performance. Change-Id: I53ecdc14d28f7210cd9e7f5bd4db0c8ef5ed81fc Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
2019-07-11Fix GS cookie check on ARM in functions with stackalloc (#25628)Jan Vorlicek1-3/+7
* Fix GS cookie check on ARM in functions with stackalloc The GC cookie check was failing during GC stack walking on ARM for frames of functions using stackalloc and pinvoke. The InlinedCallFrame stores only the SP after the stackalloc adjustment and unwinder needs R9 that contains SP before the stackalloc to be able to unwind the frame to get caller SP. The caller SP is used as a base for getting the GS cookie address. We were incorrectly setting the R9 in the CONTEXT to the same value as SP and so the unwinding was getting an incorrect caller SP. The fix is to store R9 in the InlinedCallFrame for ARM.
2019-07-04Fix instantiation stub maker for case where no register is used by function ↵Fadi Hanna1-20/+29
parameters (#25558) * Fix instantiation stub maker for case where no register is used by function parameters
2019-01-19Cleanup: Remove MethodDesc::GetLoaderAllocatorForCode (#22067)Jan Vorlicek1-1/+1
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-11Patch vtable slots and similar when tiering is enabled (#21292)Koundinya Veluri1-14/+0
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.
2018-11-13Optimize vtable calls (#20696)Fadi Hanna1-10/+10
* Implementation of R2R vtable call thunks. These thunks will fetch the target code pointer from the vtable of the input thisPtr, and jump to that address. This is especially helpful with generics, since we can avoid a generic dictionary lookup cost for a simple vtable call. Overall, these thunks cause the CPU to have less branch mispredictions, and give a small performance boost to vtable calls. These stubs are under VirtualCallStubManager so that the managed debugger can handle stepping through them.
2018-11-09Delete dead/unreachable code related to remoting (#20880)Jan Kotas1-61/+0
2018-09-03Deal with cross-bitness compilation warnings Pt.2 (#19781)Egor Chesakov1-3/+4
* Disable ASMCONSTANTS_C_ASSERT in cross-bitness scenario in src/vm/ceeload.cpp * Adjust MAXFIELDMARSHALERSIZE for cross-bitness scenario in src/vm/arm/cgencpu.h * Make ALLOC_ALIGN_CONSTANT host specific in src/inc/stdmacros.h * Make PRECODE_ALIGNMENT host specific in src/vm/arm/cgencpu.h * Disable unreachable code in src/vm/arm/stubs.cpp * Adjust CorDBIPC_BUFFER_SIZE for cross-bitness scenario in src/debug/inc/dbgipcevents.h * Disable warning C4359 in src/vm/arm/cgencpu.h * Deal with warning C4267: 'initializing': conversion from 'size_t' to 'int' in src/vm/stublink.cpp * Deal with warning C4267: 'initializing': conversion from 'size_t' to 'int' in src/vm/callingconvention.h * Disable unreachable REGDISPLAY constructor in src/inc/regdisp.h
2018-08-23Deal with compilation warnings in VM in cross-bitness scenario (#18707)Egor Chesakov1-1/+1
2018-08-23Enable unloading of AssemblyLoadContext (#18476)Jan Vorlicek1-2/+3
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-06-29Remove relocations for vtable chunks (#17147)Gleb Balykov1-3/+85
* 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-03-24Delete unused files from src/inc (#17186)Jan Kotas1-1/+0
2018-01-29Perform PhysicalMemoryLimit check for workstation GC, refactor ↵Tom Deseyn1-7/+0
GetLargestOnDieCacheSize into GetCacheSizePerLogicalCpu (#15975) * refactor: combine GetLargestOnDieCacheSize and GetLogicalCpuCount in GetCacheSizePerLogicalCpu * Perform PhysicalMemoryLimit check also for workstation GC
2018-01-21Remove AppDomainLeaks configuration option (#15956)antofik1-5/+0
Removed all usages of AppDomainLeaks configuration option and CHECK_APP_DOMAIN_LEAKS feature Fix #12094
2018-01-12Improve UMEntryThunkCode::Poison method.Konstantin Baladurin1-2/+12
Improve UMEntryThunkCode::Poison to produce diagnostic message when collected delegate was called.
2017-10-17[RyuJIT/ARM32] Add the optimization case on CreateDictionaryLookupHelper ↵Sujin Kim1-6/+111
(#13933) * Implement optimization case for CreateDictionaryLookupHelper Signed-off-by: Hyung-Kyu Choi <hk0110.choi@samsung.com> * Reenable mainv1/mainv2 tests
2017-10-11Delete !FEATURE_IMPLICIT_TLS (#14398)Jan Kotas1-239/+53
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-29StompWriteBarrier initialization path refactoring (#14105)Sergey1-12/+16
* refactored arm, arm64, amd64 and x86 to signal about icache flush and ee restarts * refactored gc init stage to stomp write barrier (hence flush icache) only once * review fixes, care taken of icache invalidation during StompResize * fixed heap boundaries initialization bug introduced after refactoring gc.cpp * stylistic review fixe * global variable rename * global variable rename once more
2017-09-12[RyuJIT/ARM32] Implement CreateDictionaryLookupHelper only via helper (#13733)Sujin Kim1-5/+28
* [RyuJIT/ARM32] Implement CreateDictionaryLookupHelper only via run-time helper Implement CreateDictionaryLookupHelper only via run-time helper * Add assertion for checking CORINFO_USEHELPER
2017-08-07Cleanup code access security from the unmanaged runtime (#13241)Jan Kotas1-1/+0
2017-08-02Use 'udf 0xff' instead of 'bkpt 0xbe' as a poison (#13152)Jonghyun Park1-2/+2
2017-07-31 Fill freed loader heap chunk with non-zero value (#12731)Jonghyun Park1-0/+6
* 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-06-26Replace array type handle with method table in arguments of array allocation ↵Ruben Ayrapetyan1-2/+2
helpers (#12369) * Remove direct usage of type handle in JIT_NewArr1, with except of retrieving template method table. * Assert that array type descriptor is loaded when array object's method table is set. * Pass template method tables instead of array type descriptors to array allocation helpers.
2017-05-17Finish deleting dead CAS code from CoreLib (#11436)Jan Kotas1-1/+0
Fixes #9321 and deletes CleanupToDoList.cs Delete unmanaged security implementation
2017-05-05Add compact entry points for ARM (#11109)gbalykov1-0/+7
2017-03-16[Local GC] Break EE dependency on GC's generation table and alloc lock in ↵Sean Gillespie1-1/+1
single-proc scenarios (#10065) * Remove usage of the generation table from the EE by introducing an EE-owned GC alloc context used for allocations on single-proc machines. * Move the GC alloc lock to the EE side of the interface * Repair the Windows ARM build * Move the decision to use per-thread alloc contexts to the EE * Rename the lock used by StartNoGCRegion and EndNoGCRegion to be more indicative of what it is protecting * Address code review feedback 2 (enumerate the global alloc context as a part of GCToEEInterface) * Code review feedback (3) * Address code review feedback (move some GC-internal globals to gcimpl.h and gc.cpp) * g_global_alloc_lock is a dword, not a qword - fixes a deadlock * Move GlobalAllocLock to gchelpers.cpp and switch to preemptive mode when spinning * Repair the Windows x86 build
2017-02-26Clean up PInvokeStubForHost and PInvokeStubForHostInner (#9815)Jonghyun Park1-6/+0
2017-02-14Remove never defined FEATURE_REMOTINGdanmosemsft1-174/+0
2017-02-10Remove always defined FEATURE_CORECLRdanmosemsft1-2/+0
2016-09-08Introduce an interface separating the GC and the VM,Sean Gillespie1-1/+1
modifying the VM to utilize this interface. Introduce an interface separating the GC and the rest of the VM Remove static members of both IGCHeap and IGCHeapInternal and move the management of the singular GC heap to the VM. Rename uses of IGCHeap in the VM to GCHeapHolder, as well as other misc. renames throughout the VM and GC. Split each interface function into categories, document them, use consistent formatting across the interface Undo some accidental find/replace collateral damage Remove all ifdefs from the GC interface Deduplicate function declarations between IGCHeap and IGCHeapInternal, expose AllocAlign8 through the interface and the reference to alloc_context to repair the ARM build Paper cut: false -> nullptr Repair the ARM and x86 builds Rename GCHeapHolder -> GCHeapUtilities and address documentation feedback Rebase against master Rename gcholder.h/cpp -> gcheaputilities.h/cpp Fix an uninitialized field on alloc_context causing test failures on clang Rename the include guard for gcheaputilities.h Un-breaks SOS by making the following changes: 1) Instructs the DAC to look for IGCHeap::gcHeapType by name, instead of assuming that it exists near g_pGCHeap, 2) Eliminate all virtual calls on IGCHeap in the DAC, since we cannot dispatch on an object in another process, 3) Because of 2, expose the number of generations past the GC interface using a static variable on IGCHeap that the DAC can read directly. repair the Windows build
2016-08-07Check PAL_VirtualUnwind failure during GC (#6598)Jonghyun Park1-1/+6
As discussed in #6525, PAL_VirtualUnwind sometimes fails during GC. This GC failure leads to very unpredicatble behavior (which is very hard to analyze). This commit tries to stop the execution at the point where error happens.
2016-06-23Enable out-of-proc unwinding on ARM (#5946)kvochko1-1/+8
Fix #5855
2016-06-21Fixing build break on x86 and arm.Fadi Hanna1-1/+1
[tfs-changeset: 1614031]
2016-05-15Fix arm and x86 build breaksJan Kotas1-0/+7
[tfs-changeset: 1604843]
2016-04-12Implement software write watch and make concurrent GC functional outside WindowsKoundinya Veluri1-5/+6
- Implemented software write watch using write barriers - A new set of write barriers is introduced, each corresponding to an existing one, but which also updates the write watch table. The GC switches to a write watch barrier during concurrent GC, and switches back to a non write watch barrier after the final query for dirty pages. - The write watch table is alloacted along with the card table - Since the card table is used differently, different synchonization is used for the write watch table. The runtime is suspended during resize since that is the most infrequently occuring operation, of that, ResetWriteWatch, and GetWriteWatch. - ResetWriteWatch() doesn't need a suspend, but since the software WW version is much faster than the Windows version, moved it into the suspended region to avoid some synchronization that would otherwise be required - The background calls to GetWriteWatch() don't need or do a suspend. They only need to synchronize with the resize path, not for the purpose of correct functionality, but to not miss dirty pages such that concurrent GC is effective. Miscellaneous: - Fixed runtests.sh to copy mscorlib.dll and delete the Windows version of mscorlib.ni.dll
2016-01-27Update license headersdotnet-bot1-4/+3
2015-11-18Revert change in 4e06e42 that broke ARM cross buildBen Pye1-1/+1
2015-11-17Enable CLANG sanitizers for native debug buildsSteve Harter1-1/+1
2015-11-03Fix sos clrstack unwinding for the special HelperMethodFrame.Mike McLaughlin1-0/+1
Add and implement new ICorDebugDataTarget4 unwind interface using lldb stack unwinder ABIs. The implementation does a linear search of the native frames for the stack pointer provided. It doesn't happen often so the performance is fine. Stub out the DBI's ICorDebugDataTarget4 (in ShimDataTarget::VirtualUnwind) for now. Since PAL_VirtualUnwindOutOfProc is disabled it makes sense to just return E_NOTIMPL. Fix bpmd command so it doesn't stop in lldb when it isn't a CLRN exception (continues).
2015-10-20Implementation of System V ABI struct passing.Lubomir Litchev1-1/+1
This PR adds support for System V x86_64 ABI classification and calling convention to the VM and the Jit, including, but not limited to Ubuntu Linux and Mac OS X. The general rules outlined in the System V x86_64 ABI (described at http://www.x86-64.org/documentation/abi.pdf) are followed with a few little exceptions, described below: 1. The hidden argument for by-value passed structs is always after the ÎéÎíthisÎéÎí parameter (if there is one.). This is a difference with the Sysetem V ABI and affects only the internal jit calling conventions. For PInvoke calls the hidden argument is always the first parameter since there is no ÎéÎíthisÎéÎí parameter in this case. 2. Managed structs that have no fields are always passed by-value on the stack. 3. The jit proactively generates frame register frames (with RBP as a frame register) in order to aid the native OS tooling for stack unwinding and the like.
2015-07-31Modify unwinder to provide RtlVirtualUnwind.Ben Pye1-0/+5
Use PAL_VirtualUnwind on Linux ARM Add assembler annotation for unwinding
2015-07-24Add ARM target for CoreCLR on Linux.Ben Pye1-10/+35
c_runtime/vprintf/test1 is disabled as casting NULL to va_list is against the C specification. Fix SetFilePointer tests on 32 bit platforms. Define _FILE_OFFSET_BITS=64 so that we have long file support on 32 bit platforms. Implement context capture/restore for ARM. Link libgcc_s before libunwind on ARM so C++ exceptions work. Translate armasm to gas syntax. Specify Thumb, VFPv3, ARMv7 for the ARM target. Add ARM configuration to mscorlib build Implement GetLogicalProcessorCacheSizeFromOS in PAL. Set UNWIND_CONTEXT_IS_UCONTEXT_T from configure check.
2015-02-20Delete dead codeJan Kotas1-5/+0
2015-02-11Fix ARM Ready To Run: A dynamic helper generator was not allocating enough ↵John Chen1-1/+1
memory. [tfs-changeset: 1414126]
2015-01-30Initial commit to populate CoreCLR repo dotnet-bot1-0/+3903
[tfs-changeset: 1407945]