8537 Commits

Author SHA1 Message Date
Ryan Houdek
6efc4a967c
Merge pull request #3373 from neobrain/feature_thunk_custom_repacking
Library Forwarding: Implement assisted struct repacking
2024-01-18 13:56:20 -08:00
Tony Wasserka
190d8020ff FEXLinuxTests/Thunks: Add tests for assisted struct repacking 2024-01-15 20:40:13 +01:00
Tony Wasserka
6eaeb48fac Thunks/gen: Implement assisted struct repacking
This can be used to allow automatically handling structures that require
special behavior for one member but are automatically repackable otherwise.
The feature is enabled using the new custom_repack annotation and requires
additional repacking functions to be defined in the host file for each
customized member.
2024-01-15 20:40:13 +01:00
Ryan Houdek
f956f008ea
Merge pull request #3372 from alyssarosenzweig/opt/cmpxchg-review
Optimize GPR cmpxchg
2024-01-15 05:11:12 -08:00
Ryan Houdek
be4d1a8860
Merge pull request #3365 from Sonicadvance1/pidof
Tools: Adds new FEXpidof tool
2024-01-15 05:10:56 -08:00
Ryan Houdek
8ff4b525fc
Merge pull request #3367 from bylaws/prepwow
Windows: Commonise WOW64 logic that can be shared with ARM64EC
2024-01-15 05:09:50 -08:00
Tony Wasserka
832072362b
Merge pull request #3371 from neobrain/feature_thunk_automatic_repacking
Library Forwarding: Implement automatic argument repacking
2024-01-15 11:23:42 +01:00
Ryan Houdek
ddfd393789 Tools: Adds new FEXpidof tool
This behaves exactly like pidof but only searches for FEX applications.
This fixes a long standing annoyance of mine that pidof doesn't work for
FEX. This behaves exactly like pidof but knows how to decode the command
line options to pull out the program data.

If the Linux kernel ever accepts the patches for binfmt_misc to change
how the interpreter is handled then this will become redundant, but
until that happens here is a utility that I want.
2024-01-12 19:05:37 -08:00
Alyssa Rosenzweig
d9985eb877 InstCountCI: Update
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2024-01-12 12:23:34 -04:00
Alyssa Rosenzweig
58127bd0e8 OpcodeDispatcher: optimize trivial cmpxchgs
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2024-01-12 12:23:34 -04:00
Alyssa Rosenzweig
e8945dfb6d OpcodeDispatcher: optimize gpr cmpxchg
NZCV stuff.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2024-01-12 12:03:28 -04:00
Alyssa Rosenzweig
0a6e875329 InstCountCI: add nontrivial gpr cmpxchg cases
cmpxchg handles rax specially, so cmpxchg with dest=rax is a special case. test
also the general case.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2024-01-12 11:50:43 -04:00
Tony Wasserka
cd4578de27 FEXLinuxTests/thunks: Add tests for automatic repacking 2024-01-12 14:47:10 +01:00
Tony Wasserka
295fe03eef unittests/ThunkLibs: Add simple struct repacking tests
These just ensure that two specific but common patterns continue to compile.
2024-01-12 14:47:10 +01:00
Tony Wasserka
4cbaad298a Thunks/gen: Repack out-parameters on exit
To avoid performance traps, several conditions must hold for exit repacking
to apply:
* Argument must be a pointer
* The pointee type must have differing data layout between guest and host
* The pointee type must be non-const

Arguments that don't meet the first two conditions are safe *not* to repack
on exit, since they're either passed by copy or have consistent data layout.
The third condition is a heuristic: In principle, an API function could modify
data through nested pointers even if the argument pointer is const. However,
automatic repacking is not supported for such types anyway, so this is a safe
heuristic to use.
2024-01-12 14:47:10 +01:00
Tony Wasserka
dc477c3bd7 Thunks/gen: Implement automatic struct (entry-)repacking 2024-01-12 14:47:10 +01:00
Tony Wasserka
52419d9911 Thunks/gen: Emit metadata to check if a type has consistent data layout 2024-01-12 14:47:10 +01:00
Ryan Houdek
8c3163096b
Merge pull request #3363 from Sonicadvance1/fix_label_allocations
ArmEmitter: Support single use forward labels
2024-01-12 00:26:31 -08:00
Billy Laws
9f311cd97e CommonWindows: Split out code invalidation logic from WOW64
This will also be used by FEX ARM64EC module.
2024-01-12 00:12:26 +00:00
Billy Laws
1115ce4a95 CommonWindows: Introduce, and split out CPU feature logic from WOW64
This can also be used by the FEX ARM64EC module.
2024-01-12 00:12:26 +00:00
Billy Laws
03b802cf8e Windows: Use MinGW importlib functions when possible for ntdll
Switch to only defining imports that are not part of MinGW in the FEX importlib
definitions, this is necessary to avoid linker problems with ARM64EC.
2024-01-12 00:12:26 +00:00
Ryan Houdek
615cfe0246
Merge pull request #3361 from Sonicadvance1/decompose_std_function
FEXCore: Decompose some std::function usage to regular pointers
2024-01-10 16:55:29 -08:00
Ryan Houdek
dae16aaf18
Merge pull request #3362 from Sonicadvance1/glibc_alloc
Fixes some new glibc allocations that cropped up
2024-01-10 02:05:24 -08:00
Ryan Houdek
3d5f876585 Fixes some new glibc allocations that cropped up
I guess this was handled by brk things before.
2024-01-09 13:55:04 -08:00
Ryan Houdek
37102400b5 Arm64: Switches uses of forward label over to SingleUse if possible
Primary goal for this is to ensure that the delinker doesn't need to
allocate any memory. This delinker can end up getting hit heavily with
JIT code so we don't want it to be allocating memory.
2024-01-08 22:18:20 -08:00
Ryan Houdek
c01e6283ae CodeEmitter: Support a single use forward label
Currently all uses of the forward label calls in to jemalloc to allocate
memory. This allows a forward label that doesn't require any memory
allocation, which is the common case in FEX.
2024-01-08 22:18:20 -08:00
Ryan Houdek
248dc97993 FEXCore: Decompose some std::function usage to regular pointers
The delinker step of the JIT was using std::function with capture
lambdas that required memory allocation when unnecessary.
Because the compiler can't see through our std::function usage it could
never decompose these by itself.

By passing the Thread's frame and record to the function as arguments
then we can have the signature be a raw function pointer.

This fixes an area of concern from:
https://github.com/FEX-Emu/FEX/blob/main/docs/ProgrammingConcerns.md#stdfunction-and-lambdas
2024-01-06 19:39:54 -08:00
Ryan Houdek
d488592eda
Merge pull request #3339 from Sonicadvance1/pass_thread_unaligned_fault_handler
FEXCore: Pass thread object to HandleUnalignedAccess
2024-01-04 18:20:37 -08:00
Ryan Houdek
743df8dfae
Merge pull request #3327 from Sonicadvance1/remove_syscall_indirection
Arm64: Removes a vtable indirection in syscalls
2024-01-04 18:19:40 -08:00
Ryan Houdek
4b3792196f
Merge pull request #3303 from Sonicadvance1/initial_runtime_longmode_switch
OpcodeDispatcher: Initial support for runtime long-mode switch
2024-01-04 18:17:54 -08:00
Ryan Houdek
c333aac4f9
Merge pull request #3354 from Sonicadvance1/uprev_kernel_2
Linux uprev to v6.6
2024-01-03 14:25:13 -08:00
Ryan Houdek
db7d7a6bd7
Merge pull request #3349 from Sonicadvance1/revert_frontend_ownership
Revert "FEXLoader: Moves thread management to the frontend"
2024-01-03 14:25:04 -08:00
Alyssa Rosenzweig
04a88ed3ab
Merge pull request #3353 from Sonicadvance1/public_interface_cleaning
FEXCore interface cleaning
2024-01-03 15:14:54 -04:00
Alyssa Rosenzweig
9da08b40bd
Merge pull request #3344 from Sonicadvance1/xbyak_upstream
Externals: Update xbyak to v7.02 and switch away from fork
2024-01-03 15:13:58 -04:00
Alyssa Rosenzweig
5467c3e478
Merge pull request #3357 from Sonicadvance1/remove_non_sra
FEXCore: Removes SRA option, it's now permanently enabled
2024-01-03 15:10:04 -04:00
Ryan Houdek
9841983955
Merge pull request #3358 from wannacu/main
JIT: Fixes broken register in VTBX1
2023-12-30 00:44:09 -08:00
wannacu
4e7bab849c JIT: Fixes broken register in VTBX1
If the Dst register is allocated as VectorIndices or VectorTable,
using Dst as an operand to perform the tbx operation will result in an error.
For example:
%131(FPR0) i128 = LoadNamedVectorIndexedConstant u8:Tmp:RegisterSize, #0x6, #0xaa0
%132(FPR0) i128 = VTBX1 u8:Tmp:RegisterSize, %129(FPRFixed6) i32v4, %126(FPRFixed10) i16v8, %131(FPR0) i128
Since the tbx instruction's destination register is also the original operand,
this is consistent with the semantics of VTBX1. Therefore,
directly using VectorSrcDst as the destination operand for the tbx instruction is safe.
2023-12-29 16:18:40 +08:00
Ryan Houdek
d098545c20 FEXCore: Removes SRA option, it's now permanently enabled 2023-12-28 18:28:02 -08:00
Ryan Houdek
5358af7794 Revert "FEXLoader: Moves thread management to the frontend"
This reverts commit 58f26939548cba8b26ec4771aeed6b54e3700046.
2023-12-27 04:33:50 -08:00
Ryan Houdek
eea2e7bb57
Merge pull request #3351 from Sonicadvance1/remove_context_lock
FEXCore: Removes context wide and map lookup
2023-12-27 00:59:22 -08:00
Ryan Houdek
25bcddf3a5 FEXCore: Removes context wide and map lookup
While locking a shared_lock and doing an empty table lookup is fairly
fast, just remove them from the hot path entirely if no custom IR
handlers are installed.

This is only used for our IRLoader, which is losing its importance
significantly and should probably be removed anyway.
2023-12-26 11:11:44 -08:00
Ryan Houdek
f785b38e4d
Merge pull request #3352 from Sonicadvance1/remove_irloader
Removes IRLoader, unittests, and public interface
2023-12-26 11:08:26 -08:00
Ryan Houdek
0071c1bda2
Merge pull request #3350 from Sonicadvance1/minor_opt
FEXCore: Optimize HostFeatures and CPUID feature calculation
2023-12-26 09:01:58 -08:00
Ryan Houdek
058e691ef1
Merge pull request #3348 from Sonicadvance1/disable_sha
Support disabling SHA in CPUID
2023-12-26 08:24:59 -08:00
Tony Wasserka
d806db53ec
Merge pull request #3318 from neobrain/feature_thunk_layout_wrappers
Library Forwarding: Emit layout helpers to allow repacking struct data
2023-12-26 16:25:53 +01:00
Tony Wasserka
bcd0efa724 Thunks: Build fix for clang versions older than 15
Returning incomplete types from deleted functions is valid C++, but clang
did not support it until version 15:
https://github.com/llvm/llvm-project/issues/52802
2023-12-26 16:02:08 +01:00
Tony Wasserka
48c2e0689a Thunks/gen: Specialize layout wrappers for pointer types
Pointer types inherently cause data layout compatibility issues, so they're
worth special-casing here. The wrappers will type-pun pointers to 32-bit or
64-bit integers (matching the guest architecture) to avoid direct host-side
use of guest pointers without consideration.
2023-12-26 16:02:08 +01:00
Tony Wasserka
4b09a6bee1 Thunks/gen: Implement host_layout->guest_layout conversion
This enables use of guest_layout for return values.
2023-12-26 16:02:08 +01:00
Tony Wasserka
af645cb750 Thunks/gen: Fill guest_layout stub and implement conversion to host_layout
The guest_layout wrapper provides an architecture-agnostic representation of
the guest data layout of each struct used in a thunked library. A constructor
is added to host_layout to allow conversion of the data to the host layout.

For types that are already fully compatible, both layout wrappers are simple
type aliases to minimize overhead.
2023-12-26 16:02:07 +01:00
Ryan Houdek
b8b9b2f1a7 Linux: Update syscalls for v6.6 2023-12-25 08:40:46 -08:00