Commits
David Farler committed fbbb593b1c7
IRGen: Lower `super_method` SIL instruction for native classes
This is the first part of making class method dispatch resilient.
If we have the following class hierarchy:
// Module A
class Parent {
func foo() {}
}
class Child : Parent {}
// Module B
class Grandchild : Child {
override func foo() {
super.foo()
}
}
dispatch to `Parent.foo` will be static via a `function_ref`, so if
someone adds a `foo()` to `Child` later on, `Grandchild` won't know
about it without recompiling.
Stage in the IRGen portion of dynamic dispatch when calling methods on
`super`:
- Don't assert in IRGen if we see a native super_method instruction.
- Perform virtual lookup on superclass's metadata. If we see a
`super_method` instruction for a native class:
- Get the address of the superclass's metadata at offset 1
- Load the superclass's metadata
- Perform virtual lookup on this metadata instead
TODO: SILGen super_method instructions for native classes.
TODO: Devirtualize back down to static dispatch with a reslience lookup
mechanism.
rdar://problem/22749732