-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove Builtin.UnknownObject completely #12325
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
Remove Builtin.UnknownObject completely #12325
Conversation
- The runtime now provides prebuilt value witnesses for AnyObject (mangled name yXl). - The demangler and remangler continue to support "BO" because it's convenient to be able to demangle old symbols. - Reflection still uses the notion of "unknown object" to mean an object with unknown refcounting. That's different from AnyObject because AnyObject is still an existential, meaning it /contains/ an object with unknown refcounting. - The reflection tests are broken at the moment. - Type-based alias analysis for Builtin.UnknownObject was incorrect, so it's a good thing we weren't using it. - Same with enum layout. (This one assumed UnknownObject never referred to an Objective-C tagged pointer. That certainly wasn't how we were using it!)
@swift-ci Please test |
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 reflection tests are busted; I just get "invalid lowering" when I try to use yXl
.
@@ -3,6 +3,8 @@ | |||
// RUN: %target-build-swift %S/Inputs/TypeLowering.swift -parse-as-library -emit-module -emit-library -module-name TypeLowering -o %t/libTypesToReflect.%target-dylib-extension | |||
// RUN: %target-swift-reflection-dump -binary-filename %t/libTypesToReflect.%target-dylib-extension -binary-filename %platform-module-dir/libswiftCore.%target-dylib-extension -dump-type-lowering < %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize | |||
|
|||
// REQUIRES: UnknownObject_removal |
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.
Help?
@@ -4,6 +4,7 @@ | |||
|
|||
// REQUIRES: objc_interop | |||
// REQUIRES: CPU=x86_64 | |||
// REQUIRES: UnknownObject_removal |
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.
Help?
Build failed |
@@ -906,7 +906,6 @@ emitAssociatedTypeMetadataRecord(const ProtocolConformance *Conformance) { | |||
void IRGenModule::emitBuiltinReflectionMetadata() { | |||
if (getSwiftModule()->isStdlibModule()) { | |||
BuiltinTypes.insert(Context.TheNativeObjectType); | |||
BuiltinTypes.insert(Context.TheUnknownObjectType); |
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.
Can you try something like BuiltinTypes.insert(Context.getAnyObjectType()->getCanonicalType())?
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.
... it would have to emit the descriptor under the old name "BO" too. Also see my comments in Reflection/TypeLowering.cpp
@jrose-apple This is awesome, but I'm worried we're going to break reflection when binaries built with Swift 4.1 are used with an older version of the library. The way it works is for "primitive" types, we emit "builtin type descriptors" which just state the size, alignment and extra inhabitants of the type. You changed it to no longer emit this descriptor for UnknownObject, which makes sense, but I think it should now emit a descriptor for AnyObject, but probably under the old name so that the old library can find it. |
@@ -607,7 +607,7 @@ const TypeRef *TypeConverter::getUnknownObjectTypeRef() { | |||
if (UnknownObjectTR != nullptr) | |||
return UnknownObjectTR; | |||
|
|||
UnknownObjectTR = BuiltinTypeRef::create(Builder, "BO"); | |||
UnknownObjectTR = BuiltinTypeRef::create(Builder, "yXl"); |
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.
Ok, keep this as "BO" -- the mangled name here doesn't 'mean' anything, it's just used to find the descriptor emitted in IRGen/GenReflection
@@ -1048,9 +1048,6 @@ class LowerType | |||
if (B->getMangledName() == "Bo") { | |||
return TC.getReferenceTypeInfo(ReferenceKind::Strong, | |||
ReferenceCounting::Native); | |||
} else if (B->getMangledName() == "BO") { |
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.
And keep this too, maybe add a comment that "BO" is no longer a real type
Build failed |
@jrose-apple Take a look at lldb too, thankfully most of the usages look trivially removable:
|
Oops, thanks for the LLDB reminder! I'll probably need to talk to you about yXl vs BO, but this isn't high-priority. |
Closing in favor of #27378. |
The runtime now provides prebuilt value witnesses for AnyObject (mangled name yXl).
The demangler and remangler continue to support "BO" because it's convenient to be able to demangle old symbols.
Reflection still uses the notion of "unknown object" to mean an object with unknown refcounting. That's different from AnyObject because AnyObject is still an existential, meaning it contains an object with unknown refcounting.
The reflection tests are broken at the moment.
Type-based alias analysis for Builtin.UnknownObject was incorrect, so it's a good thing we weren't using it.
Same with enum layout. (This one assumed UnknownObject never referred to an Objective-C tagged pointer. That certainly wasn't how we were using it!)