-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3356 from Sonicadvance1/modify_code_lock
Jitarm64: Implements spin-loop futex for JIT blocks
- Loading branch information
Showing
7 changed files
with
494 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "Utils/SpinWaitLock.h" | ||
|
||
namespace FEXCore::Utils::SpinWaitLock { | ||
#ifdef _M_ARM_64 | ||
constexpr uint64_t NanosecondsInSecond = 1'000'000'000ULL; | ||
|
||
static uint32_t GetCycleCounterFrequency() { | ||
uint64_t Result{}; | ||
__asm("mrs %[Res], CNTFRQ_EL0" | ||
: [Res] "=r" (Result)); | ||
return Result; | ||
} | ||
|
||
static uint64_t CalculateCyclesPerNanosecond() { | ||
// Snapdragon devices historically use a 19.2Mhz cycle counter frequency | ||
// This means that the number of cycles per nanosecond ends up being 52.0833... | ||
// | ||
// ARMv8.6 and ARMv9.1 requires the cycle counter frequency to be 1Ghz. | ||
// This means the number of cycles per nanosecond ends up being 1. | ||
uint64_t CounterFrequency = GetCycleCounterFrequency(); | ||
return NanosecondsInSecond / CounterFrequency; | ||
} | ||
|
||
uint32_t CycleCounterFrequency = GetCycleCounterFrequency(); | ||
uint64_t CyclesPerNanosecond = CalculateCyclesPerNanosecond(); | ||
#endif | ||
} |
Oops, something went wrong.