Skip to content
Permalink
Browse files
8255995: templateTable_x86.cpp (TemplateTable::if_acmp) not always do…
… correct null check.

Reviewed-by: fparain, thartmann
  • Loading branch information
David Simms committed Nov 18, 2020
1 parent cc1f08e commit e9217dad98d10d313ad710e25e4e1a2cb9d4bc6e
Showing with 19 additions and 1 deletion.
  1. +3 −1 src/hotspot/cpu/x86/templateTable_x86.cpp
  2. +16 −0 test/hotspot/jtreg/runtime/valhalla/inlinetypes/Ifacmp.java
@@ -2490,7 +2490,9 @@ void TemplateTable::if_acmp(Condition cc) {
__ jcc(Assembler::equal, (cc == equal) ? taken : not_taken);

// might be substitutable, test if either rax or rdx is null
__ testptr(rdx, rax);
__ testptr(rax, rax);
__ jcc(Assembler::zero, (cc == equal) ? not_taken : taken);
__ testptr(rdx, rdx);
__ jcc(Assembler::zero, (cc == equal) ? not_taken : taken);

// and both are values ?
@@ -128,6 +128,7 @@ public void testAllUseCases() {
checkEqual(pair[0], pair[1], false);
}
testLocalValues();
testAlot();
}

public void testValues() {
@@ -160,6 +161,21 @@ public void testLocalValues() {
checkEqual(a, a2, false);
}

public void testAlot() {
MyValue a = new MyValue(4711);
Reference ref = new WeakReference<Object>(new Object(), new ReferenceQueue<>());
do {
for (int i = 0; i < 1000; i++) {
MyValue b = new MyValue(4711);
if (acmpModeInlineAlwaysFalse) {
if (a == b) throw new RuntimeException("Always false fail " + a + " == " + b);
} else {
if (a != b) throw new RuntimeException("Substitutability test failed" + a + " != " + b);
}
}
} while (ref.get() != null);
}

boolean shouldEqualSelf(Object a) {
return acmpModeInlineAlwaysFalse ? (!(a != null && a.getClass().isInlineClass())) : true;
}

0 comments on commit e9217da

Please sign in to comment.