Skip to content

Commit f17f924

Browse files
authored
RISC-V: Only use conditional far branch in copy_memory for ZGC (openjdk#16)
* Only use conditional far branch in copy_memory for zgc * Remove unused code
1 parent 65a0a19 commit f17f924

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,11 @@ class StubGenerator: public StubCodeGenerator {
957957
Label same_aligned;
958958
Label copy_big, copy32_loop, copy8_loop, copy_small, done;
959959

960-
__ beqz(count, done);
960+
// The size of copy32_loop body increases significantly with ZGC GC barriers.
961+
// Need conditional far branches to reach a point beyond the loop in this case.
962+
bool is_far = UseZGC ? true : false;
963+
964+
__ beqz(count, done, is_far);
961965
__ slli(cnt, count, exact_log2(granularity));
962966
if (is_backwards) {
963967
__ add(src, s, cnt);
@@ -971,15 +975,15 @@ class StubGenerator: public StubCodeGenerator {
971975
__ addi(t0, cnt, -32);
972976
__ bgez(t0, copy32_loop);
973977
__ addi(t0, cnt, -8);
974-
__ bgez(t0, copy8_loop);
978+
__ bgez(t0, copy8_loop, is_far);
975979
__ j(copy_small);
976980
} else {
977981
__ mv(t0, 16);
978-
__ blt(cnt, t0, copy_small);
982+
__ blt(cnt, t0, copy_small, is_far);
979983

980984
__ xorr(t0, src, dst);
981985
__ andi(t0, t0, 0b111);
982-
__ bnez(t0, copy_small);
986+
__ bnez(t0, copy_small, is_far);
983987

984988
__ bind(same_aligned);
985989
__ andi(t0, src, 0b111);
@@ -995,26 +999,27 @@ class StubGenerator: public StubCodeGenerator {
995999
__ addi(dst, dst, step);
9961000
}
9971001
__ addi(cnt, cnt, -granularity);
998-
__ beqz(cnt, done);
1002+
__ beqz(cnt, done, is_far);
9991003
__ j(same_aligned);
10001004

10011005
__ bind(copy_big);
10021006
__ mv(t0, 32);
1003-
__ blt(cnt, t0, copy8_loop);
1007+
__ blt(cnt, t0, copy8_loop, is_far);
10041008
}
1009+
10051010
__ bind(copy32_loop);
10061011
if (is_backwards) {
10071012
__ addi(src, src, -wordSize * 4);
10081013
__ addi(dst, dst, -wordSize * 4);
10091014
}
10101015
// we first load 32 bytes, then write it, so the direction here doesn't matter
1011-
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp3, Address(src), gct1);
1012-
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp4, Address(src, 8), gct1);
1016+
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp3, Address(src), gct1);
1017+
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp4, Address(src, 8), gct1);
10131018
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp5, Address(src, 16), gct1);
10141019
bs_asm->copy_load_at(_masm, decorators, type, 8, tmp6, Address(src, 24), gct1);
10151020

1016-
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst), tmp3, gct1, gct2, gct3);
1017-
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst, 8), tmp4, gct1, gct2, gct3);
1021+
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst), tmp3, gct1, gct2, gct3);
1022+
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst, 8), tmp4, gct1, gct2, gct3);
10181023
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst, 16), tmp5, gct1, gct2, gct3);
10191024
bs_asm->copy_store_at(_masm, decorators, type, 8, Address(dst, 24), tmp6, gct1, gct2, gct3);
10201025

0 commit comments

Comments
 (0)