[aarch64-port-dev ] Error (but not bug) in MacroAssembler::repne_scanw
Andrew Dinn
adinn at redhat.com
Wed Sep 10 15:47:45 UTC 2014
MacroAssembler::repne_scanw was copied as is form JDK8-aarch64 and used
in JDK7 under check_klass_subtype_slow_path to search subclass arrays
when CompressedOops is enabled
// This part is tricky, as values in supers array could be 32 or 64
bit wide
// and we store values in objArrays always encoded, thus we need to encode
// the value of r0 before repne. Note that r0 is dead after the repne.
if (UseCompressedOops) {
encode_heap_oop_not_null(r0); // Changes flags.
cmp(sp, zr); // Clear Z flag; SP is never zero
repne_scanw(r5, r0, r2, rscratch1);
} else {
cmp(sp, zr); // Clear Z flag; SP is never zero
// Scan R2 words at [R5] for an occurrence of R0.
// Set NZ/Z based on last compare.
repne_scan(r5, r0, r2, rscratch1);
}
This caused a bug as explained below.
repne_scanw is is not used by check_klass_subtype_slow_path in JDK8
since it appears that subclass arrays are always 64 bit values.
cmp(sp, zr); // Clear Z flag; SP is never zero
// Scan R2 words at [R5] for an occurrence of R0.
// Set NZ/Z based on last compare.
repne_scan(r5, r0, r2, rscratch1);
However, the implementation of repne_scanw in JDK8 is still wrong and
ought to be patched in case anyoneis tempted to use it elsewhere. Here
is the corrected code:
// scans count 4 byte words at [addr] for occurence of value,
// generic
void MacroAssembler::repne_scanw(Register addr, Register value, Register
count,
Register scratch) {
Label Lloop, Lexit;
cbz(count, Lexit);
bind(Lloop);
// ldrw(scratch, post(addr, wordSize)); // skips every 2nd compressed
oop!!
ldrw(scratch, post(addr, wordSize/2)); // correct auto-increment
cmpw(value, scratch);
br(EQ, Lexit);
sub(count, count, 1);
cbnz(count, Lloop);
bind(Lexit);
}
If this routine is only used to manipulate arrays of oops (which appears
to be the intent of the JDK7-x86 code) then the supplied size really
ought to be heapOopSize both here and in repne_scan. However, I think
the intention in JDK8 is always to scan an array of 64 bit values. So, I
have followed suit in JDK and passed wordSize/2.
regards,
Andrew Dinn
-----------
More information about the aarch64-port-dev
mailing list