Implement class hierarchy method caching

cc @github/mri-hackers