Implement class hierarchy method caching

I've implemented class hierarchy method caching against the current trunk.

I've skipped a bunch of commits relating to constant caching in this pull request that were in the `klasscache-trunk` branch, because they were causing hard to resolve merge conflicts.

Once this patch set is reviewed and I have merged it into SVN trunk, I'll work on implementing better constant caching again.

cc @ko1