Walter Bright wrote: > Ary Borenszweig wrote: >> Walter Bright escribió: >>> Jari-Matti Mäkelä wrote: >>>> bearophile wrote: >>>> - OOP: Scala supports dynamic OOP optimizations unlike D (unless a VM >>>> is used). >>> >>> Do you mean knowing a class or virtual method has no descendants? >>> Sure, you need to know the whole program to do that, or just declare >>> it as final. >> >> I think the standard name is "adaptive optimization": >> >> http://en.wikipedia.org/wiki/Adaptive_optimization >> >> "Adaptive optimization is a technique in computer science that performs >> dynamic recompilation of portions of a program based on the current >> execution profile." >> >> "Consider a hypothetical banking application that handles transactions >> one after another. These transactions may be checks, deposits, and a >> large number of more obscure transactions. When the program executes, >> the actual data may consist of clearing tens of thousands of checks >> without processing a single deposit and without processing a single >> check with a fraudulent account number. An adaptive optimizer would >> compile assembly code to optimize for this common case. If the system >> then started processing tens of thousands of deposits instead, the >> adaptive optimizer would recompile the assembly code to optimize the new >> common case. This optimization may include inlining code or moving error >> processing code to secondary cache." > > It's also called profile guided optimization, but Jari-Matti said it was > "OOP" related, so I wondered how that fit in.
I meant this "Another important example of this kind of optimization is class-hierarchy- based optimization. A virtual method invocation, for example, involves looking at the class of the receiver object for the call to discover which actual target implements the virtual method for the receiver object. Research has shown that most virtual invocations have only a single target for all receiver objects, and JIT compilers can generate more-efficient code for a direct call than for a virtual invocation. By analyzing the class hierarchy's state when the code is compiled, the JIT compiler can find the single target method for a virtual invocation and generate code that directly calls the target method rather than performing the slower virtual invocation. Of course, if the class hierarchy changes and a second target method becomes possible, then the JIT compiler can correct the originally generated code so that the virtual invocation is performed. In practice, these corrections are rarely required. Again, the potential need to make such corrections makes performing this optimization statically troublesome." http://www.ibm.com/developerworks/java/library/j-rtj2/index.html