-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove stdlib and runtime dependencies on Foundation and CF #26630
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
Conversation
return [[NSProcessInfo processInfo] operatingSystemVersion]; | ||
} else { | ||
// Otherwise load and parse from SystemVersion dictionary. | ||
return operatingSystemVersionFromPlist(); |
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.
Now that we're in the OS, we no longer need this fallback path
stdlib/public/runtime/SwiftObject.mm
Outdated
NSString *swift::getDescription(OpaqueValue *value, const Metadata *type) { | ||
auto result = swift_stdlib_getDescription(value, type); | ||
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API | ||
id swift_stdlib_boxUTF8CString(const char *cstr, int len); |
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.
How do you make an NSString without going through ObjC? Ask Swift to do it ;D
@@ -171,6 +171,10 @@ internal protocol _NSSetCore: _NSCopying, _NSFastEnumeration { | |||
/// supplies. | |||
@unsafe_no_objc_tagged_pointer @objc | |||
internal protocol _NSSet: _NSSetCore { | |||
@objc(getObjects:count:) func getObjects( |
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 should be a small speedup relative to the CF call :)
@@ -58,7 +75,7 @@ - (NSString*)description { | |||
static id getSentinelForDepth(unsigned depth) { | |||
// For unnested optionals, use NSNull. | |||
if (depth == 1) | |||
return id_const_cast(kCFNull); | |||
return SWIFT_LAZY_CONSTANT(id_const_cast([objc_getClass("NSNull") null])); |
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 burns a tiny bit of memory, which makes me sad. We could possibly not cache it, I'm not sure how hot this code path is.
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.
The cache is probably a good idea. I don't think you need id_const_cast
if you're going through Objective-C, by the way.
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 code path should only come up in cases that shouldn't be that common to begin with (bridging a nil Optional to a non-nullable id
, such as when turning a [T?]
into NSArray), so it may be sufficiently cold that the cache isn't needed.
test/api-digester/Outputs/stability-stdlib-abi.asserts.additional.swift.expected
Outdated
Show resolved
Hide resolved
stdlib/public/stubs/Availability.mm
Outdated
#include <os/system_version.h> | ||
static NSOperatingSystemVersion getOSVersion() { | ||
struct os_system_version_s vers; | ||
if (os_system_version_get_current_version(&vers)) { |
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 believe this should make availability checking significantly more efficient :)
@swift-ci please smoke test |
@swift-ci please smoke benchmark |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
Looks pretty much in the noise. The tests that maybe-regressed are all ones I recognize as maybe-progressions from other PRs, and should be unrelated to this code. |
6fdac98
to
edb478d
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci please smoke benchmark |
Test failure is just the ABI one, which I mis-merged. So tests look good! That's progress. Still investigating the mystery of why the F/CF dependency in the cmake file is needed even though nothing references them anymore. |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
big sigh of relief I was NOT sure that benchmark run would be ok |
@swift-ci please test |
@swift-ci please smoke benchmark |
Build failed |
Build failed |
@swift-ci please test |
@swift-ci please smoke benchmark |
@@ -153,16 +167,29 @@ - (BOOL)isEqual:(id)other { | |||
@end | |||
|
|||
Class swift::getNSErrorClass() { | |||
return SWIFT_LAZY_CONSTANT([NSError class]); | |||
return SWIFT_LAZY_CONSTANT(objc_lookUpClass("NSError")); |
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 still a difference between this and objc_getClass
in the modern runtime?
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.
Nope
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.
One small difference: they pass different values to the third, unused parameter of the internal function that implements the functionality. Don't ask me why.
// RUN: %target-build-swift -Xfrontend -disable-access-control -module-name a %s -o %t.out -O | ||
// RUN: %empty-directory(%t) | ||
// RUN: %gyb %s > %t/main.swift | ||
// RUN: %target-build-swift -Xfrontend -disable-access-control -module-name a %t/main.swift %S/../Inputs/SmallStringTestUtilities.swift -o %t.out -O |
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.
Do you still need -disable-access-control
? Because -disable-access-control
is basically not guaranteed to work, especially with -O
.
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.
Well, that's not new, just moved, but yes. This uses _SmallString
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 guess as long as it's just @usableFromInline
things you use it should be okay…
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.
Maybe we should have a different frontend flag for that.
// RUN: %target-run-simple-swift | ||
// RUN: %empty-directory(%t) | ||
// RUN: %gyb %s > %t/main.swift | ||
// RUN: %target-build-swift -Xfrontend -disable-access-control -module-name a %t/main.swift %S/../Inputs/SmallStringTestUtilities.swift -o %t.out -O |
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.
Also not gyb, also hopefully doesn't need -disable-access-control!
a82092d
to
ed19f1d
Compare
@swift-ci please test |
Build failed |
Build failed |
ed19f1d
to
bc4900a
Compare
@swift-ci please test |
Build failed |
Build failed |
bc4900a
to
3fe46e3
Compare
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.
LGTM
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
No description provided.