-
Notifications
You must be signed in to change notification settings - Fork 119
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
PowerPC {32, 64}-bit Block Trampolines #272
Conversation
I cannot reproduce the build error from the The |
@rmottola do you want to try the changes out on real hardware, or perhaps have a look at the ASM? |
Take a look at what we do in snmalloc for the hacks required to make PowerPC run correctly. The Debian / Ubuntu binfmt packages set it up with the wrong page size. It's very annoying. |
Alright. Thank you :)
The weird thing is that it works on a fresh 22.04 aarch64 rootfs with powerpc cross. |
Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
It seems that snalloc only has a powerpc64le configuration in the workflow, but the problem lies with PowerPC (32-bit, Big-Endian). We can skip the integration for now, as it is a legacy architecture. |
Yes, I can test it on real hardware. Setting up thinks on my iBook G4 as a first test. Will report. I can use:
|
Built completes of the branch I get a couple of warnings
|
How should I run tests?
|
Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
c26e311
to
ef781fd
Compare
|
Hmm, that’s needed for the safe caching, but it isn’t useful on platforms where 64-bit atomic reads are expensive. It needs to be 64-bit to avoid overflows. We can probably just not enable it on PowerPC32. |
Sorry my question was malformed.
This answers it.
I am not familiar with the performance differences of non-native atomic reads, but is it that big of a deal? |
Non-native ones require acquiring a lock and then doing the read. This basically serialises them all and so will offset any potential benefit from caching.
Don't do lookup caching on PowerPC32. The compiler doesn't (yet?) do this automatically anyway. |
If I understand the lookup caching implementation correctly, the caller can opt in and cache a pointer to the current slot, checking whether the slot was invalidated before using it.
What about wrapping the atomic |
Yup, I think the thing to do on PowerPC32 is to always write 0 to |
But does the declaration of an _Atomic type pull in the libatomic library? |
I do not like conditionally hiding parts of the public API. |
Updates to it will pull in atomic things, we should simply remove it if we’re on a platform without 64-bit atomics. |
Caching is now disabled on ppc32. All tests are passing. 100% tests passed, 0 tests failed out of 190
Total Test time (real) = 201.64 sec
The following tests did not run:
115 - objc_msgSend (Skipped)
116 - objc_msgSend_optimised (Skipped)
117 - objc_msgSend_legacy (Skipped)
118 - objc_msgSend_legacy_optimised (Skipped)
151 - UnexpectedException (Skipped)
152 - UnexpectedException_optimised (Skipped)
153 - UnexpectedException_legacy (Skipped)
154 - UnexpectedException_legacy_optimised (Skipped)
171 - FastPathAlloc (Skipped)
172 - FastPathAlloc_optimised (Skipped)
root@debian:~/libobjc2/build-ppc# uname -a
Linux debian 6.6.8-powerpc-smp #1 SMP Debian 6.6.8-1 (2023-12-22) ppc GNU/Linux |
LGTM, please do some squashing before you merge! |
* Implement PowerPC block trampoline * Adjust pagesize on ppc64 * Skip UnexpectedException test for PowerPC * Move PAGE_SIZE to asmconstants.h * Use PAGE_SIZE and PAGE_SHIFT macros for PowerPC * Add ppc64el and powerpc qemu-crossbuild targets * Add NO_SAFE_CACHING definition and guards * Do not export objc_method_cache_version on ppc32 --------- Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
Status
Besides UnexpectedException failing (just like on AArch64), all unit tests are passing. However, I would like to incorporate a proper fix for the hard-coded page sizes (See #271) as marking the whole page RWX is not really great... (edit: This was due to mprotect failing to set PROT_EXEC on an unaligned page as ppc64el has a page size of 64k on Debian)
This is why this PR is still marked as a draft.
It would also be good to have a CI workflow for PowerPC.
PowerPC 32-bit
System (QEMU):
Clang:
I needed to link objc to
libatomic
. Ideas on how to check this in CMake are welcome!Results:
100% tests passed, 0 tests failed out of 190 Total Test time (real) = 213.12 sec The following tests did not run: 115 - objc_msgSend (Skipped) 116 - objc_msgSend_optimised (Skipped) 117 - objc_msgSend_legacy (Skipped) 118 - objc_msgSend_legacy_optimised (Skipped) 151 - UnexpectedException (Skipped) 152 - UnexpectedException_optimised (Skipped) 153 - UnexpectedException_legacy (Skipped) 154 - UnexpectedException_legacy_optimised (Skipped) 171 - FastPathAlloc (Skipped) 172 - FastPathAlloc_optimised (Skipped)
POWER9 (PowerPC 64-bit Little-Endian)
System (QEMU):
Clang:
root@debian:~/libobjc2# clang --version Debian clang version 16.0.6 (19) Target: powerpc64le-unknown-linux-gnu
Results:
100% tests passed, 0 tests failed out of 190 Total Test time (real) = 116.38 sec The following tests did not run: 115 - objc_msgSend (Skipped) 116 - objc_msgSend_optimised (Skipped) 117 - objc_msgSend_legacy (Skipped) 118 - objc_msgSend_legacy_optimised (Skipped) 151 - UnexpectedException (Skipped) 152 - UnexpectedException_optimised (Skipped) 153 - UnexpectedException_legacy (Skipped) 154 - UnexpectedException_legacy_optimised (Skipped) 171 - FastPathAlloc (Skipped) 172 - FastPathAlloc_optimised (Skipped)