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

MemArena: Add Darwin implementation #13269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OatmealDome
Copy link
Member

This implements all the MemArena and LazyMemoryRegion functions using Mach APIs. We can't use the generic Unix implementation on some Apple platforms as they don't support shared memory. However, we can easily re-create the existing functionality with mach_make_memory_entry_64.

Also, I use the normal vm APIs instead as the newer mach_vm APIs aren't available on those same platforms. As far as I can tell, the mach_vm APIs were introduced to properly handle a scenario where virtual memory is manipulated cross-process and the architectures differ (for example, one is 32-bit and the other is 64-bit). We don't need to worry about that.

First part in a (probably very long) PR series, as previously discussed.

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Just some minor nits, but I can't really test that. Does this have any measurable effect on macOS too, or is it just for iOS?

Source/Core/Common/MemArenaDarwin.cpp Outdated Show resolved Hide resolved
Source/Core/Common/MemArenaDarwin.cpp Outdated Show resolved Hide resolved
Source/Core/Common/MemArenaDarwin.cpp Outdated Show resolved Hide resolved
@OatmealDome OatmealDome reopened this Jan 8, 2025
@OatmealDome
Copy link
Member Author

OK, I resolved your comments (made everything constexpr). I also had this PR tested on an Intel Mac and an M1 Mac, and no problems were found.

Does this have any measurable effect on macOS too [...]

I answered this on Discord, but reposting it here for completeness: while this code will be used on macOS going forward, there should be no user-visible changes from this PR. Theoretically, there might be an extremely minor performance benefit due to the kernel APIs being called directly instead of going through POSIX mmap etc.

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

Successfully merging this pull request may close these issues.

2 participants