Request for reviews (M): 7105605: Use EA info to optimize pointers compare
Vladimir Kozlov
vladimir.kozlov at oracle.com
Thu Nov 10 13:14:47 PST 2011
intelsdv39% cat A.java
public class A {
A next;
// Use -XX:CompileCommand=exclude,A.foo
static void foo(A a, int x) {
if (x > 0) {
a.next = null;
}
}
static int test(int x) {
A a0 = new A(); // argument escape
A a1 = new A(); // argument escape
A a2 = new A(); // not escaping but not scalar replaceable
A a3 = new A(); // not escaping but not scalar replaceable
if (x > 0) {
a0.next = a1;
a2 = a3;
}
foo(a0, x); // Do not inline
if (a2 == a3) { // Can not eliminate
return 3;
}
if (a0.next == a1) { // Can not eliminate
return 1;
}
if (a0.next == a2) { // Can eliminate!!!
return 2;
}
return 0;
}
public static void main(String args[]) {
int x = 0;
for (int i=0; i<10000; i++) {
x = test(i&1);
}
}
}
intelsdv39% gamma -Xbatch -XX:+OptimizePtrCompare -XX:+PrintCompilation
-XX:CICompilerCount=1 -XX:+PrintOptimizePtrCompare -XX:+Verbose
-XX:CompileCommand=exclude,A.foo A
Using java runtime at: /export/kvn/jdk7u2/jre
VM option '+OptimizePtrCompare'
VM option '+PrintCompilation'
VM option 'CICompilerCount=1'
VM option '+PrintOptimizePtrCompare'
VM option '+Verbose'
VM option 'CompileCommand=exclude,A.foo'
CompilerOracle: exclude A.foo
875 1 b java.lang.Object::<init> (1 bytes)
915 2 b A::<init> (5 bytes)
java.lang.Object::<init> (1 bytes)
921 3 b A::test (80 bytes)
A::<init> (5 bytes)
java.lang.Object::<init> (1 bytes)
A::<init> (5 bytes)
java.lang.Object::<init> (1 bytes)
A::<init> (5 bytes)
java.lang.Object::<init> (1 bytes)
A::<init> (5 bytes)
java.lang.Object::<init> (1 bytes)
++++ Replaced: 312 CmpP(296,272) --> NotEQ
272 Phi === 258 215 161 [[ 287 273 312 305 319 ]]
Oop:A:NotNull:exact * !jvms: A::test @ bci:45
296 LoadP === _ 276 260 [[ 305 297 319 312 ]] @A:BotPTR+8 *, name=next,
idx=4; Oop:A:BotPTR * !jvms: A::test @ bci:59
312 CmpP === _ 296 272 [[ 313 ]] Type:int:-1..1 !jvms: A::test @ bci:73
### Excluding compile: static A::foo
Tom Rodriguez wrote:
> On Nov 9, 2011, at 11:27 AM, Vladimir Kozlov wrote:
>
>> Thank you, Tom
>>
>> Tom Rodriguez wrote:
>>> I like the renaming you did in optimize_ptr_compare. This comment:
>>> + // Check if one set has only not escaping allocations.
>>> seems like it needs more detail explaining why that's important. I presume it's because if they are all non-escaping then they must be disjoint from the other set. Is that right?
>> There is explicit disjoint check (!ptset1.disjoint(ptset2)) before that code. It guaranties that not escaping allocations from one set are not present in second set. And they did not lost their identity since they did not escape.
>
> Then I'm unclear what this logic is trying to capture. Can you give me an example?
>
> tom
>
>>> Does the _scalar_replaceable flag change any of this? I thought if that was false then we might lose track of the identity of the object.
>> No, if Connection Graph is correct. I actually hit problem today with OSR state loads which were not marked as loads of unknown object.
>>
>> The condition "set has only not escaping allocations" means java code merged only non escaping allocations and Connection Graph knowns which allocations.
>>
>>> How effective is this at eliminating compares? Is it useful even if there aren't non-escaping object?
>> Unfortunately I don't see improvement in refworkload. I added test case which shows that this optimization eliminates next check in HashMap.get():
>> (k = e.key) == key
>>
>> But in JBB it is already eliminated by EliminateAutoBox optimization.
>>
>> Thanks,
>> Vladimir
>>
>>> tom
>>> On Nov 8, 2011, at 8:27 PM, Vladimir Kozlov wrote:
>>>> http://cr.openjdk.java.net/~kvn/7105605/webrev
>>>>
>>>> 7105605: Use EA info to optimize pointers compare
>>>>
>>>> EA Connection Graph can help to optimize pointers compare for non escaping allocations.
>>>>
>>>> Tested with CTW, jtreg, NSK, refworkload.
>>>>
>>>> Thanks,
>>>> Vladimir
>
More information about the hotspot-compiler-dev
mailing list