On Wed, Dec 17, 2003 at 12:15:04AM +0000, Piers Cawley wrote: > There's still a hell of a lot of stuff you can do with 'cached' > optimization that can be thrown away if anything changes. What the > 'final' type declarations would do is allow the compiler to throw away > the unoptimized paths and the checks for dynamic changes that mean the > optimization has to be thrown out and started again.
As Luke pointed out in an earlier message, you can encounter grave difficulty (i.e. halting problem unsolvable sort of difficulty) in trying to unoptimize a piece of code that is in the middle of being executed. Just about any subroutine call might (but almost always won't :-) happen to execute code that makes the current subroutine have to revert to unoptimized (or differently optimized) form. When that subroutine call returns after such a rare occurrence, it can't return to the unoptimized code (because there could be missing context because the calling routine got this far using the optimized code and may have skipped stuff that is (now) necessary) and it can't return to the old code (because its optimization might now be wrong).