RFR: Fix conditional store in interpreter matrix barrier

Roman Kennke rkennke at redhat.com
Wed Oct 4 17:44:45 UTC 2017


We attempt to do a conditional store in the interpreter matrix barrier. 
We use testb(addr, 0) for this. testb and-s its operands and sets the 
condition flags. And-ing with 0 always yields 0, so the zero-flag will 
always be set, resulting in the matrix barrier always storing 1 into the 
matrix. This is not fatal, but it leads to unintentional false sharing 
and the like.

Fix:

diff --git a/src/cpu/x86/vm/macroAssembler_x86.cpp 
b/src/cpu/x86/vm/macroAssembler_x86.cpp
--- a/src/cpu/x86/vm/macroAssembler_x86.cpp
+++ b/src/cpu/x86/vm/macroAssembler_x86.cpp
@@ -5493,7 +5493,7 @@
    // Address is _matrix[to * stride + from]
    movptr(rscratch1, (intptr_t) matrix_addr);
    // Test if the element is already set.
-  testb(Address(rscratch1, tmp, Address::times_1), 0);
+  testb(Address(rscratch1, tmp, Address::times_1), 1);
    jcc(Assembler::notZero, done);
    // Store true, if not yet set.
    movb(Address(rscratch1, tmp, Address::times_1), 1);

Test: hotspot_gc_shenandoah

ok?



More information about the shenandoah-dev mailing list