Fri, 31 Mar 2017 12:43:02 -0400
[C2] Optimize the oop/klass encoding and decoding (Follows a4946a9e94b0).
1.1 --- a/src/cpu/mips/vm/assembler_mips.cpp Thu Mar 30 08:45:59 2017 -0400 1.2 +++ b/src/cpu/mips/vm/assembler_mips.cpp Fri Mar 31 12:43:02 2017 -0400 1.3 @@ -4023,7 +4023,41 @@ 1.4 1.5 movz(r, S5_heapbase, r); 1.6 dsub(r, r, S5_heapbase); 1.7 - shr(r, LogMinObjAlignmentInBytes); 1.8 + if (Universe::narrow_oop_shift() != 0) { 1.9 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.10 + shr(r, LogMinObjAlignmentInBytes); 1.11 + } 1.12 +} 1.13 + 1.14 +void MacroAssembler::encode_heap_oop(Register dst, Register src) { 1.15 +#ifdef ASSERT 1.16 + verify_heapbase("MacroAssembler::encode_heap_oop:heap base corrupted?"); 1.17 +#endif 1.18 + verify_oop(src, "broken oop in encode_heap_oop"); 1.19 + if (Universe::narrow_oop_base() == NULL) { 1.20 + if (Universe::narrow_oop_shift() != 0) { 1.21 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.22 + dsrl(dst, src, LogMinObjAlignmentInBytes); 1.23 + } else { 1.24 + if (dst != src) move(dst, src); 1.25 + } 1.26 + } else { 1.27 + if (dst == src) { 1.28 + movz(dst, S5_heapbase, dst); 1.29 + dsub(dst, dst, S5_heapbase); 1.30 + if (Universe::narrow_oop_shift() != 0) { 1.31 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.32 + shr(dst, LogMinObjAlignmentInBytes); 1.33 + } 1.34 + } else { 1.35 + dsub(dst, src, S5_heapbase); 1.36 + if (Universe::narrow_oop_shift() != 0) { 1.37 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.38 + shr(dst, LogMinObjAlignmentInBytes); 1.39 + } 1.40 + movz(dst, R0, src); 1.41 + } 1.42 + } 1.43 } 1.44 1.45 void MacroAssembler::encode_heap_oop_not_null(Register r) { 1.46 @@ -4060,18 +4094,21 @@ 1.47 } 1.48 #endif 1.49 verify_oop(src, "broken oop in encode_heap_oop_not_null2"); 1.50 - if (dst != src) { 1.51 - move(dst, src); 1.52 + 1.53 + if (Universe::narrow_oop_base() != NULL) { 1.54 + dsub(dst, src, S5_heapbase); 1.55 + if (Universe::narrow_oop_shift() != 0) { 1.56 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.57 + shr(dst, LogMinObjAlignmentInBytes); 1.58 + } 1.59 + } else { 1.60 + if (Universe::narrow_oop_shift() != 0) { 1.61 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.62 + dsrl(dst, src, LogMinObjAlignmentInBytes); 1.63 + } else { 1.64 + if (dst != src) move(dst, src); 1.65 + } 1.66 } 1.67 - 1.68 - if (Universe::narrow_oop_base() != NULL) { 1.69 - dsub(dst, dst, S5_heapbase); 1.70 - } 1.71 - if (Universe::narrow_oop_shift() != 0) { 1.72 - assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.73 - shr(dst, LogMinObjAlignmentInBytes); 1.74 - } 1.75 - 1.76 } 1.77 1.78 void MacroAssembler::decode_heap_oop(Register r) { 1.79 @@ -4085,13 +4122,50 @@ 1.80 } 1.81 } else { 1.82 move(AT, r); 1.83 - shl(r, LogMinObjAlignmentInBytes); 1.84 + if (Universe::narrow_oop_shift() != 0) { 1.85 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.86 + shl(r, LogMinObjAlignmentInBytes); 1.87 + } 1.88 dadd(r, r, S5_heapbase); 1.89 movz(r, R0, AT); 1.90 } 1.91 verify_oop(r, "broken oop in decode_heap_oop"); 1.92 } 1.93 1.94 +void MacroAssembler::decode_heap_oop(Register dst, Register src) { 1.95 +#ifdef ASSERT 1.96 + verify_heapbase("MacroAssembler::decode_heap_oop corrupted?"); 1.97 +#endif 1.98 + if (Universe::narrow_oop_base() == NULL) { 1.99 + if (Universe::narrow_oop_shift() != 0) { 1.100 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.101 + dsll(dst, src, LogMinObjAlignmentInBytes); 1.102 + } else { 1.103 + if (dst != src) move(dst, src); 1.104 + } 1.105 + } else { 1.106 + if (dst == src) { 1.107 + move(AT, dst); 1.108 + if (Universe::narrow_oop_shift() != 0) { 1.109 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.110 + shl(dst, LogMinObjAlignmentInBytes); 1.111 + } 1.112 + dadd(dst, dst, S5_heapbase); 1.113 + movz(dst, R0, AT); 1.114 + } else { 1.115 + if (Universe::narrow_oop_shift() != 0) { 1.116 + assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong"); 1.117 + dsll(dst, src, LogMinObjAlignmentInBytes); 1.118 + daddu(dst, dst, S5_heapbase); 1.119 + } else { 1.120 + daddu(dst, src, S5_heapbase); 1.121 + } 1.122 + movz(dst, R0, src); 1.123 + } 1.124 + } 1.125 + verify_oop(dst, "broken oop in decode_heap_oop"); 1.126 +} 1.127 + 1.128 void MacroAssembler::decode_heap_oop_not_null(Register r) { 1.129 // Note: it will change flags 1.130 assert (UseCompressedOops, "should only be used for compressed headers"); 1.131 @@ -4124,10 +4198,7 @@ 1.132 dsll(dst, src, LogMinObjAlignmentInBytes); 1.133 daddu(dst, dst, S5_heapbase); 1.134 } else { 1.135 - if (dst != src) { 1.136 - move(dst, src); 1.137 - } 1.138 - shl(dst, LogMinObjAlignmentInBytes); 1.139 + dsll(dst, src, LogMinObjAlignmentInBytes); 1.140 if (Universe::narrow_oop_base() != NULL) { 1.141 daddu(dst, dst, S5_heapbase); 1.142 } 1.143 @@ -4163,12 +4234,17 @@ 1.144 if (Universe::narrow_klass_base() != NULL) { 1.145 set64(dst, (int64_t)Universe::narrow_klass_base()); 1.146 dsub(dst, src, dst); 1.147 + if (Universe::narrow_klass_shift() != 0) { 1.148 + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); 1.149 + shr(dst, LogKlassAlignmentInBytes); 1.150 + } 1.151 } else { 1.152 - move(dst, src); 1.153 - } 1.154 - if (Universe::narrow_klass_shift() != 0) { 1.155 - assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); 1.156 - shr(dst, LogKlassAlignmentInBytes); 1.157 + if (Universe::narrow_klass_shift() != 0) { 1.158 + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); 1.159 + dsrl(dst, src, LogKlassAlignmentInBytes); 1.160 + } else { 1.161 + move(dst, src); 1.162 + } 1.163 } 1.164 } 1.165 }
2.1 --- a/src/cpu/mips/vm/assembler_mips.hpp Thu Mar 30 08:45:59 2017 -0400 2.2 +++ b/src/cpu/mips/vm/assembler_mips.hpp Fri Mar 31 12:43:02 2017 -0400 2.3 @@ -2015,7 +2015,9 @@ 2.4 void load_heap_oop(Register dst, Address src); 2.5 void store_heap_oop(Address dst, Register src); 2.6 void encode_heap_oop(Register r); 2.7 + void encode_heap_oop(Register dst, Register src); 2.8 void decode_heap_oop(Register r); 2.9 + void decode_heap_oop(Register dst, Register src); 2.10 void encode_heap_oop_not_null(Register r); 2.11 void decode_heap_oop_not_null(Register r); 2.12 void encode_heap_oop_not_null(Register dst, Register src);
3.1 --- a/src/cpu/mips/vm/mips_64.ad Thu Mar 30 08:45:59 2017 -0400 3.2 +++ b/src/cpu/mips/vm/mips_64.ad Fri Mar 31 12:43:02 2017 -0400 3.3 @@ -12089,10 +12089,8 @@ 3.4 ins_encode %{ 3.5 Register src = $src$$Register; 3.6 Register dst = $dst$$Register; 3.7 - if (src != dst) { 3.8 - __ move(dst, src); 3.9 - } 3.10 - __ encode_heap_oop(dst); 3.11 + 3.12 + __ encode_heap_oop(dst, src); 3.13 %} 3.14 ins_pipe( ialu_regL_regL ); 3.15 %} 3.16 @@ -12115,10 +12113,8 @@ 3.17 ins_encode %{ 3.18 Register s = $src$$Register; 3.19 Register d = $dst$$Register; 3.20 - if (s != d) { 3.21 - __ move(d, s); 3.22 - } 3.23 - __ decode_heap_oop(d); 3.24 + 3.25 + __ decode_heap_oop(d, s); 3.26 %} 3.27 ins_pipe( ialu_regL_regL ); 3.28 %}