* Update FixupPrecode and StubPrecode types for ARM
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
* Update ThisPtrRetBufPrecode and NDirectImportPrecode types for arm
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
* Addressing PR feedback - remove unnecessary #ifdef's
---------
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
The precode code was incorrectly using the HOST_ARM64, HOST_ARM, etc. defines instead
of the TARGET_ ones. This means the cross-DAC was using the wrong architectures
*Precode::Type codes.
* [RISC-V] coreclr-vm and other directories in coreclr
- Successfully cross-build for RISC-V.
- Run A simple application "helloworld"
- Fail a test in clr.paltest
* Remove commented codes
* Fix mistakes
* Update by reviews
* [VM] Fix test
* [VM] Update
Updated by review in #82380
* [VM] Update assert and todo comments
* [VM] Updated
* [VM] Fix a bug
* [VM] Add getRISCV64PassStructInRegisterFlags
* Revert "[VM] Add getRISCV64PassStructInRegisterFlags"
This reverts commit cd1ea45de36458a5e3ec66a325bf3e0c4812680d.
* [VM] Restore getLoongArch64PassStructInRegisterFlags
In coreclr-jit patch, it makes getRISCV64PassStructInRegisterFlags for
RISCV64. So restore getLoongArch64PassStructInRegisterFlags
* [VM] FIX TEST ERRORS
* [VM] Update Stubs
* Fix exceptionhandling, stack smashing detected
* [VM] Fix vm/riscv64
---------
Co-authored-by: Timur Mustafin <t.mustafin@partner.samsung.com>
* Add multi-element caching scheme to ExecutableAllocator
* CodePageGenerator generated code for LoaderHeaps should not cache the RW mapping created, as it is never accessed again, and caching it is evicting useful data from the cache
* Fix build breaks introduced by executable mapping cache changes
* Fix build breaks caused by changes to introduce the concept of executable pages that aren't cached ever
* Move VSD executable heaps from being LoaderHeaps to being CodeFragmentHeaps
- Should reduce the amount of contention on the ExecutableAllocator cache
- Will improve the performance of identifying what type of stub is in use by avoiding the RangeList structure
- Note, this will only apply to stubs which are used in somewhat larger applications
* Add statistics gathering features to ExecutableAllocator
* In progress
* Fix Dac api failing when called early in process startup
* Implement interleaved stubs as 16KB pages instead of 4KB pages
* Remove api incorrectly added
* Adjust cache size down to 3, and leave a breadcrumb for enabling more cache size exploration
* Fix x86 build
* Tweaks to make it all build and fix some bugs
- Notably, arm32 is now only using 4K pages as before, as it can't generate the proper immediate as needed.
* Add statistics for linked list walk lengths
* Reorder linked list on access
* Fix some more asserts and build breaks
* Fix Arm build for real this time, and fix unix arm64 miscalculation of which stubs to use
* Update based on code review comments
* More code review feedback
* Fix oops
* Attempt to fix Unix Arm64 build
* Try tweaking the number of cached mappings to see if the illegal instruction signal will go away in our testing
* Revert "Try tweaking the number of cached mappings to see if the illegal instruction signal will go away in our testing"
This reverts commit 983846083fea60eab9df53cf07a2fb5230c6c818.
* Fix last code review comment
* Part6-2: -add the coreclr-vm directory for LoongArch64. (#59561)
Co-authored-by: Loongson's .NET-teams
* [LoongArch64] revert the syncblk.cpp.
* [LoongArch64] delete some unused codes.
* [LoongArch64] add vm/CMakeLists.txt from #62889.
* [LoongArch64] add related files from #62886 and #62893.
* [LoongArch64] moved vm/jitinterface.cpp from #62893.
moved inc/corinfo.h from #6288.
* [LoongArch64] run the file `src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh`
and merge the patch from #62893.
* [LoongArch64] revert vm/ceeload.h.
amend the `ToolBox/superpmi/superpmi-shared/agnostic.h`
* [LoongArch64] add empty interfaces within `CorInfoImpl.cs`.
* [LoongArch64] Fix the compiling error on Windows.
* [LoongArch64] Fix the compiling error for memory unaligned m_currentByteStackIndex.
* [LoongArch64] Delete the !TARGET_LOONGARCH64 for m_currentByteStackIndex.
* [LoongArch64] move ToolBox from #62886.
* [LoongArch64] amend the args when needs unsigned extending within CallTargetWorker.
* [LoongArch64] add bool type for args' unsigned extention.
* [LoongArch64] adding char type for args' unsigned extention.
Also rename `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI` within ABI.
* [LoongArch64] amend renaming `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI` within ABI.
* [LoongArch64] remove the JIT/EE interface to #62893.
* [LoongArch64] revert the rename `TARGET_LOONGARCH64` to `UNIX_LOONGARCH64_ABI`.
Also add unsigned extend for CHAR type.
* [LoongArch64] refactor the `ArgDestination and ArgLocDesc`.
* [LoongArch64] rename the `m_flag` and `getFieldTypeByHnd`.
* [LoongArch64] add `NATIVE_SYMBOL_READER_DLL` for compiling error.
* [LoongArch64] update the version of the `LICENSE description`.
* [LoongArch64] keep same with the comment in `jit/targetloongarch64.h`
* [LoongArch64] amend the code for reviewing.
* [LoongArch64] refactor LoongArch64-ABI within `vm`,
and also amend some code for review.
* [LoongArch64] delete unused codes.
* [LoongArch64] merge main for #65869.
* [LoongArch64] amend the format for reviewing.
* [LoongArch64] delete some unused code for reviewing.
* [LoongArch64] amend code for CR feedback @jkotas @janvorli
* [LoongArch64] add class type for LoongArch64-ABI.
* [LoongArch64] Amend the LoongArch64's ABI
after merged `MethodTable::GetLoongArch64PassStructInRegisterFlags()`
and `CEEInfo::getLoongArch64PassStructInRegisterFlags()`
* [LoongArch64] Fix the assert error
when running hello-world within debug-mode after refacting.
Co-authored-by: qiaopengcheng <qiaopengcheng-hf@loongson.cn>
* Reimplement stubs to improve performance
This change implements `FixupPrecodeStub`, `PrecodeStub`
and `CallCountingStub` using a new mechanism with fixed code and separate RW
data. The `LoaderHeap` was updated to support a new kind of allocation
using interleaved code and data pages to support this new mechanism.
The JIT now generates code that uses indirection slot to jump to the
methods using `FixupPrecode`, improving performance of the ASPNet
plaintext benchmark by 3-4% depending on the target platform (measured
on x64 Windows / Linux and arm64 Linux).
I have also removed the Holders, as the stubs are naturally properly
aligned due to the way they are allocated.
There is now only a single variant of each stub, there are no long /
short ones anymore as they are not needed - the indirect jumps we use
now are not range limited.
Most of the stubs stuff is now target agnostic and the originally split
implementation is now in single place for all targets. Only a few
constants are defined as target specific in these.
The code for the stubs is no longer generated as bytes by C++ code, but
rather written in asm and compiled. These precompiled templates are then
used as a source to copy the code from. The x86 is a bit more complex
than that due to the fact that it doesn't support PC relative indirect
addressing, so we need to relocate all access to the data slots when
generating the code pages.
As a further improvement, we could generate just a single page of the
code and then just map it many times. This is left for future work.
ARM64 Unix differs from the other targets / platforms - there are
various page sizes being used. So the asm templates are generated for
4k..64k page sizes and the variant is then picked at runtime based on
the page size extracted from the OS.
This also removes a lot of writeable mappings created for modifications
of the stub code when W^X is enabled, in the plaintext benchmark they
were reduced by 75%. That results in a significant reducing of the .NET
application startup time with W^X enabled.
I think the `LoaderHeap` would benefit from some refactoring, but I'd
prefer leaving it for a follow up. It seems that for the sake of the
review, it is better to keep it as is.
The change also implements logging of number of mappings and their exact
locations. This helped me to drive the work and I am planning to use it
for further changes. It can be removed in the future once we reach a
final state.
There are still opportunities for improvement, but these stubs allowed
me to scrape off the most significant portion of the mappings.
* Remove last vestiges of nidump now that NGEN is dead
* Add back the DAC'd version of gcdump into a separate file from nidump.cpp
* Include common header.
* Update src/coreclr/vm/method.hpp
* Remove basic usages with unifdef.
* Manually remove the rest of the occurances that unifdef didn't catch due to complexity or if the file contains assembly.
* Undo deletion of some #if 0 blocks that unifdef removed.
* Add writeable holders for executable memory
This change adds holders for writeable mappings for executable memory.
It is the largest part of the W^X support. The ExecutableWriterHolder
implementation is dummy in this change, but it was fully tested with
coreclr / libraries tests on Windows arm, arm64, x64 and x86 with the
real double memory mapping.
There are few concepts / conventions used:
* When the writeable pointer isn't known at a place where it is needed
and also not at the caller, the ExecutableWriterHolder instance is
created.
* When a callee needs writeable pointer to executable memory and caller
knows RW and RX, the argument is doubled with RX and RW suffixes. For
constructors and member methods when "this" is the RW one, we pass just
extra RX argument.
* Locals holding RW pointer use RW suffix.
* Locals holding RX pointer usually have no suffix to minimize number of
changes, but in some cases they have a RX suffix
where I felt like it was better to make things clear.
* Move src/coreclr/src/Directory.Build.targets to src/coreclr
Merge src/coreclr/src/CMakeLists.txt into src/coreclr/CMakeLists.txt
* Mechanical move of src/coreclr/src to src/coreclr
* Scripts adjustments to reflect the changed paths