Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS - Implement remaining portions for native ARM64 #15992

Merged
merged 4 commits into from
Aug 25, 2024
Merged

Conversation

kd-11
Copy link
Contributor

@kd-11 kd-11 commented Aug 25, 2024

  1. CPU topology, brand names, etc are available from sysctl. I couldn't find much info if these variables have codes we can use with sysconf command so I just used a shell to get it. Works well enough on my system where the CPU brand and number of P and E cores is correctly detected.
  2. Change JIT environment to linux-android instead of linux-gnu. MacOS and android reserve use of the x18 register and it should not be used in emitted JIT.
  3. Fix a rare crash when compiling a large number of SPU blocks without overcommit being available.

With these changes, LLVM is now usable on the M-series apple chips natively without going through rosetta. Same caveats as linux apply - not all games will work right now, but most of them should be fine, including AAA titles.

@Megamouse
Copy link
Contributor

Why is this in arch64 code? Isn't there already CPU detection for Mac?

@kd-11
Copy link
Contributor Author

kd-11 commented Aug 25, 2024

Why is this in arch64 code? Isn't there already CPU detection for Mac?

X86 uses CPU registers that are accessible in el0/ring3. Arm uses registers only accessible by the kernel at el1. On x86 builds apple just reports "virtual apple" as the cpu.

@@ -4,6 +4,10 @@
#include <thread>
#include <map>

#if defined(__APPLE__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this path also be used for FREEBSD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but I have no idea if they use a different path. I have 0 experience with BSD unfortunately, we'll have to rely on their community to help fill in the missing pieces.

@kd-11 kd-11 changed the title Implement basic system info detection on macos using sysctl MacOS - Implement remaining portions for native ARM64 Aug 25, 2024
@kd-11 kd-11 merged commit 56d35bf into RPCS3:master Aug 25, 2024
6 checks passed
{
static std::mutex mcommit_lock;
std::lock_guard lock(mcommit_lock);
utils::memory_commit(pointer + olda, newa - olda, Prot);
Copy link
Contributor

@elad335 elad335 Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this should somehow be implemented insidr memory_commit
edit: I'll add locks by pointer hash or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware of overlapping regions as well, though I doubt that's a problem in practice.
This operation is pretty quick so I haven't experienced any slowdown. It can also be copied as-is into the memory_commit function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants