-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Towards s390x support #19822
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
Towards s390x support #19822
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m a little confused; Apple doesn’t ship an ObjC runtime on s390x. Can you comment on what’s up a little?
@millenomi - these changes are to address several validation test-case failures and continuation of earlier commits -e.g.: 85fde8b OBJC related changes are mostly addressing test case failures (>500 in number otherwise). |
What are those test failures? Ideally the ObjC defines would not impact platforms without an ObjC runtime. |
I'm not familiar with the current status quo, but @mikeash has been refactoring some of this logic. BridgeObjects still need to work on Linux, so I suspect that the ObjC defines shouldn't be necessary, just the Swift ones. |
@jckarter - here is a snippet of failures after restoring SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK :
So it appears that test cases are heavily dependent on how these masks are defined |
#19540 shuffled a bunch of this stuff around about a week ago. The ObjC masks shouldn't be needed if ObjC interop isn't available, but in practice it looks like they are. In particular, we unconditionally incorporate the ObjC reserved bits into the https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftObject.mm#L495 Ideally, we shouldn't have the ObjC masks around at all if interop isn't available. I think the best solution would be to put the |
I think this area has seen quite a bit of refactoring in recent years. 3d04fb5#diff-ac47cb08ca19bd2108eaf8cb32ddcbc4 appears to have moved bit masks out of Metadata.h. Scope of this PR is more on s390x big-endian enablement. I wonder if broader cleanup can be attempted elsewhere to keep the scope separate with correct SME involved. |
@millenomi - please let me know if changes are acceptable within s390x arch context. Thanks. |
While I do keep an eye on patches that may affect Foundation or general ObjC interop, I think runtime people like @mikeash are more suited to review. |
@mikeash - let me know your thoughts on limiting this PR to s390x arch and whether proposed changes are acceptable. Thanks again for your insight. |
Yes, they look good. The cleanup I mentioned would be nice but there is no reason to make this change wait for it. Just curious, when the comment says, "On s390x it is theoretically possible to have high bit set but in practice it is unlikely." How unlikely is it? |
@mikeash - until recently this was not even possible on s390x with kernels supporting 4-level page table. On recent kernels with 5-level page tables, it is possible but we haven't seen any code using it. It remains unlikely but there can be always be cases where explicit address requests can be made in this range. |
Interesting. Thanks for the explanation. |
@rposts question. Once we get this working would it be possible to get a community bot for s390x so we stop breaking you ; )? I.e. here: https://ci-external.swift.org |
@gottesmm there were some attempts early on but they were stalled due to T&Cs. I am not sure what the latest status is but this is definitely something we would like to pursue. |
@swift-ci please test |
Build failed |
Build failed |
@compnerd OS X platform failure above appears to be timeout related. Please let me know if something is regressed as part of this PR. I could not find anything off the top. thx. |
@compnerd - can we please kick of another swift-ci. Failure source remains unclear to me - Thx |
@swift-ci please test |
Let's see if it works better this time. |
Build failed |
@swift-ci please test os x platform |
Build failed |
@swift-ci please test os x platform |
Thanks @milseman - I assume all set to go. |
// kernel, so we can assume that pointer values in this range are invalid. | ||
// On s390x it is theoretically possible to have high bit set but in practice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This last commit is a bit nerve-wracking. Is there somewhere we could add an assertion for s390x so if this ever goes awry, it's easy to debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks all for helping us narrow the s390x gap!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine as long as swift_*alloc*
never use the high half of address space. The issue here is whether a pointer to a refcountable Swift object is ever in the high half—if that's never the case, then it's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to make this comment more descriptive then? Maybe mention that while the address space theoretically includes it, swift_alloc can never allocated objects at those addresses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milseman I cannot be sure if swift_alloc can never allocate objects at those addresses. Is there somewhere I can look to confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default the allocator functions just call down to the platform malloc
, so you could look at whatever malloc
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok - yes, malloc can allocate upper range if other address space is exhausted.
How about changing the comment to read this:
// On s390x it is theoretically possible to have high bit set but in practice the swift/system allocators do not allocate in this range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it'll happen but only if you allocate ~9.2 exabytes of memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - that is correct.
This PR partially enables s390x architecture support for Swift.
Specifically: