14 Commits
Author SHA1 Message Date
Tom McDonald 0bd362370b FIx riscv64 build break due to NDirectImportPrecode::Type conflict with ThisPtrRetBufPrecode::Type (#92087) 2023-09-14 19:50:12 -04:00
Tom McDonaldandJan Vorlicek f7a7b2b8b1 Update FixupPrecode and StubPrecode types for ARM (#92030)
* 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>
2023-09-14 14:12:18 -04:00
Mike McLaughlin 0241bc154b Fix arm64/arm32 cross-DAC (#91425)
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.
2023-08-31 16:52:29 -07:00
Dong-Heon JungandTimur Mustafin f66c469be1 [RISC-V] coreclr-vm and other directories in coreclr (#82381)
* [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>
2023-04-14 16:32:25 +02:00
David Wrighton 11a0671c0b More efficient executable allocator (#83632)
* 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
2023-04-13 15:43:40 +02:00
Aaron Robinson 4f010449b1 Removal of IBC infrastructure (#68717)
* Removal of IBC infrastructure

* Crossgen2 - remove tuning flag.
2022-05-16 13:18:53 -07:00
Aaron Robinson 6a9245f9a1 Reenable 4244 (#68615)
* Remove disable of 4244 in root compiler settings.
2022-05-04 13:53:32 -07:00
Qiao Pengchengandqiaopengcheng febeba309d [LoongArch64] coreclr-vm directory (#62885)
* 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>
2022-04-21 09:55:30 -07:00
Jan Vorlicek eb8460fd29 Reimplement stubs to improve performance (#65738)
* 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.
2022-03-17 23:19:15 +01:00
Jeremy Koritzinsky cbf90d593e Remove last vestiges of nidump now that NGEN is dead (#58052)
* 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
2021-08-25 11:25:44 -07:00
Jeremy Koritzinsky 948770a23b Remove CROSSGEN_COMPILE define usage (#57697)
* 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.
2021-08-19 23:36:03 +00:00
Elinor Fung 4ae06696b8 Delete code under FEATURE_NATIVE_IMAGE_GENERATION (#57669) 2021-08-18 12:21:28 -07:00
Jan Vorlicek d617e830ec Add writeable holders for executable memory (#53934)
* 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.
2021-06-10 15:26:40 +02:00
Tomáš Rylek 69e114c1ab December infra rollout - remove duplicated 'src' from coreclr subrepo (src/coreclr/src becomes src/coreclr) (#44973)
* 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
2020-12-08 03:19:44 +01:00