[aarch64-port-dev ] RFR: Fix out by one in writing array barriers
Edward Nevill
edward.nevill at linaro.org
Thu Dec 12 05:03:00 PST 2013
Hi,
The following patch fixes some problems I am seeing with GC in the JTReg hotspot tests, specifically compiler/8010927/Test8010927
The problem seems to be an out by one error in gen_write_ref_array_post_barrier
The original code reads
__ lsr(start, start, CardTableModRefBS::card_shift);
__ add(end, end, BytesPerHeapOop);
__ lsr(end, end, CardTableModRefBS::card_shift);
__ sub(end, end, start); // number of bytes to copy
const Register count = end; // 'end' register contains bytes count now
__ mov(scratch, (address)ct->byte_map_base);
__ add(start, start, scratch);
__ BIND(L_loop);
__ strb(zr, Address(start, count));
__ subs(count, count, 1);
__ br(Assembler::HI, L_loop);
This seems to me to be broken. The last store in the loop is always
strb zr, [start, 1]
because of the BHI. However it must store to [start, 0] because for each HeapOOP it must do
[base + [addr >> card_shift]] = 0
However in the above the last store is done to
[base + [addr >> card_shift] + 1] = 0
The end condition of the loop should therefore be BHS, not BHI to include 0.
However, this sometimes stores 1 too many (and sometimes not). The problem is the
add end, end, BytesPerHeapOop
which converts the inclusive pointer to an exclusive pointer. However this is not what we want. What we want is to store 0 in all the bytes in the range
[base + [start >> card_shift]] to [base + [end >> card_shift]]
The following patch fixes this.
OK to push?
Ed.
--- CUT HERE ---
exporting patch:
# HG changeset patch
# User Edward Nevill edward.nevill at linaro.org
# Date 1386852655 0
# Thu Dec 12 12:50:55 2013 +0000
# Node ID 36ec6f5b872338684a26d353b77d7b747558281d
# Parent 3c620760454c2c4ea1f871d178e7ca8700bf92d3
Fix out by 1 errors in writing array barriers
diff -r 3c620760454c -r 36ec6f5b8723 src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
--- a/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Wed Dec 11 09:06:48 2013 +0000
+++ b/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Thu Dec 12 12:50:55 2013 +0000
@@ -905,7 +905,6 @@
Label L_loop;
__ lsr(start, start, CardTableModRefBS::card_shift);
- __ add(end, end, BytesPerHeapOop);
__ lsr(end, end, CardTableModRefBS::card_shift);
__ sub(end, end, start); // number of bytes to copy
@@ -915,7 +914,7 @@
__ BIND(L_loop);
__ strb(zr, Address(start, count));
__ subs(count, count, 1);
- __ br(Assembler::HI, L_loop);
+ __ br(Assembler::HS, L_loop);
}
break;
default:
--- CUT HERE ---
More information about the aarch64-port-dev
mailing list