Am 04.04.2011 05:45, schrieb Charles Oliver Nutter:
On Sun, Apr 3, 2011 at 5:04 PM, Jochen Theodorou<[email protected]>  wrote:
[...]
I am wondering... in what case does it *not* make sense to inline? I mean I
can imagine reasons like certain limitations, but in the end... Does anyone
know?

There's the black art of runtime optimization :)

ohhh, yes :)

I actually reported a performance bug in invokedynamic a couple weeks
back that turned out to be Hotspot inlining the *wrong* logic.

yes, I did read that... and getting from that I had the impression the inlining logic for MethodHandles is quite eager.... which then of course could be used in this case... but it doesn't turn out well all the time I guess.

[...]
As a rule of thumb I suppose I'd say you want to inline methods that
have the best cost/size ratio; basically, inline the smallest, hottest
methods first. I'd love to hear from the JVM vendors what rules their
compilers follow, though (and whether there are papers the rest of us
could read to understand them better).

I don't really know, I can only assume because I am really not too much into the JVM details. From what I learned I assume that in the following example

public static void doSomething(MyInterface x, Object[] args) {
  x.call(args) //C_1
}
public static void doSomethingSmall(){...}
MyInterface mi = new MyInterface() {
  public void call(Object[] args) {
    doSomethingSmall() //C_2
  }
}
doSomething(mi) //C_3

doSomethingSmall in callsite C_2 will be inlined. C_1 is megamorphic (because called from many other places in many variations), so no inlining. But C_3 could maybe. I don't know if the megamorphic C_2 taints C_3, or if that does not matter at all... no idea.

What I assume is that the JVM has a kind of global concept of a callsite being megamorphic or monomorphic. Even if C_3 would be inlined it would not help C_2.

If - and I am being crazy here I guess, because I talk about things I essentially have no idea of - if C_3 is inlined doesn't that make C_1 kind of monomorphic in a local sense? Wouldn't that mean that if at C_3 is inlined we can inline at C_2 and C_1 as well? Isn't that exactly what we would need the JVM doing for "generalized code that calls code"? Wouldn't that mean that if the JVM means a megamorphic hot call site that there could be maybe a transformation making it partially monomorphic by isolating part of the call graph? Wouldn't that be a strategy the JVM could implement in general, without special marker? Or does the JVM do this already?

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead
http://blackdragsview.blogspot.com/
For Groovy programming sources visit http://groovy.codehaus.org

--
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to