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

[SR-9374] It would be useful to have a way to tag classes used in bridging as not dynamically subclassable #51840

Open
Catfish-Man opened this issue Nov 29, 2018 · 2 comments
Labels
compiler The Swift compiler in itself improvement standard library Area: Standard library umbrella

Comments

@Catfish-Man
Copy link
Member

Previous ID SR-9374
Radar None
Original Reporter @Catfish-Man
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels Improvement
Assignee None
Priority Medium

md5: 2c87dbccb5c814733a7fb36549d7dc6f

Issue Description:

Classes like _StringStorage and _DictionaryStorage are private details of the standard library, and can (I'm making a PR shortly) have KVO subclassing disabled at runtime safely, but we jump through slow hoops to support the possibility that they might be (see swift_getObjectType and swift_getObjCClassFromObject in SwiftObject.mm). If we could put a flag on the metadata that indicates that we guarantee it's safe to skip the hoop jumping, we could speed up some things.

I've worked around this for String bridging by adding a stub that calls object_getClass, but it would be neat to a) not have to work around this, and b) take advantage of the fact that _swift_getClass knows how to do direct isa access where supported.

@Catfish-Man
Copy link
Member Author

This would also be relevant for irgen::emitDynamicTypeOfHeapObject, which emits faster code if 'allowArtificialSubclasses' is not set

@Catfish-Man
Copy link
Member Author

PR to disable auto-subclassing here #20853

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant