Run optimizations before Escape Analysis?

Edward Lee edilee at gmail.com
Tue Dec 2 23:59:31 PST 2008


I've been trying to help EA find more NoEscape allocations because
I've noticed it missing out on some cases that could be made available
by simple optimizations. For example..

void foo(int a, int b)
  Object newObj = new Object();
  if (a != b)
    staticField = newObj;

If a method bar() always calls foo() with both arguments as the same
value, even if foo() is inlined into bar(), escape analysis won't
realize the static field isn't set from bar().

It seems that initializing IterGVN before escape analysis and then
running another instance of IterGVN from Optimize causes badness
(issues relating to GVN hash table being an invalid address when
creating oop_null for EA). I've coded a little pass that gets run
right before escape analysis basically doing some of what
IterGVN.optimize() would have done on IfNodes, and EA is able to say
newObj doesn't escape. But this is quite hacky, and I'm basically
reimplementing transform+subsume_node. (Using substitute_by ran into
gvn hash lock issues.)

Is there a better way to run a stripped down IterGVN/CCP without
having issues of running them twice?

Ed



More information about the hotspot-dev mailing list