Skip to content

[runtime] Register a hook for class name lookup from libobjc #20650

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

gparker42
Copy link
Contributor

libobjc needs to look up classes by name. Some Swift classes, such as
instantiated generics and their subclasses, are created only on demand.
Now a by-name lookup from libobjc counts as a demand for those classes.

rdar://problem/27808571

libobjc needs to look up classes by name. Some Swift classes, such as
instantiated generics and their subclasses, are created only on demand.
Now a by-name lookup from libobjc counts as a demand for those classes.

rdar://problem/27808571
@gparker42
Copy link
Contributor Author

@slavapestov I only have tests for generic classes here; are there resilience cases that we can test now?

@gparker42
Copy link
Contributor Author

@swift-ci please test

@slavapestov
Copy link
Contributor

@gparker42 Look at how test/Interpreter/objc_class_resilience.swift builds and links test/Inputs/resilient_classes.swift and test/Inputs/resilient_structs.swift as a dylib with resilience enabled. What you want to do is test two cases:

  • Class is defined inside your test itself, and it has a field whose type is a resilient struct. This triggers the runtime in-place initialization mechanism. To make sure the class metadata is properly initialized, try creating an instance of the class and access a field.

  • Class is defined inside your test itself, and inherits from a class in another resilient module. This triggers the runtime relocation mechanism.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but more tests will always be good of course

@gparker42
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 1c415ca

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 1c415ca

@gparker42 gparker42 merged commit 70bbeaa into swiftlang:master Nov 30, 2018
@gparker42 gparker42 deleted the GrP-PR-666F21B3-41F3-4DC7-A4B0-E569F2DE4B01 branch November 30, 2018 01:06
gparker42 pushed a commit to gparker42/swift that referenced this pull request Nov 30, 2018
…ng#20650)

libobjc needs to look up classes by name. Some Swift classes, such as
instantiated generics and their subclasses, are created only on demand.
Now a by-name lookup from libobjc counts as a demand for those classes.

rdar://problem/27808571
bob-wilson added a commit that referenced this pull request Dec 5, 2018
[5.0][runtime] Register a hook for class name lookup from libobjc (#20650)
PopFlamingo pushed a commit to PopFlamingo/swift that referenced this pull request Dec 6, 2018
…ng#20650)

libobjc needs to look up classes by name. Some Swift classes, such as
instantiated generics and their subclasses, are created only on demand.
Now a by-name lookup from libobjc counts as a demand for those classes.

rdar://problem/27808571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants