< prev index next >

src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp

Print this page

15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 #include "asm/macroAssembler.inline.hpp"
26 #include "gc/shared/barrierSet.hpp"
27 #include "gc/shared/cardTable.hpp"
28 #include "gc/shared/cardTableBarrierSet.hpp"
29 #include "gc/shared/cardTableBarrierSetAssembler.hpp"
30 #include "gc/shared/gc_globals.hpp"
31 #include "interpreter/interp_masm.hpp"
32 
33 #define __ masm->
34 
35 void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) {
36 
37   BarrierSet* bs = BarrierSet::barrier_set();
38   assert(bs->kind() == BarrierSet::CardTableBarrierSet, "Wrong barrier set kind");
39 
40   __ lsr(obj, obj, CardTable::card_shift());
41 
42   assert(CardTable::dirty_card_val() == 0, "must be");
43 
44   __ load_byte_map_base(rscratch1);
45 
46   if (UseCondCardMark) {

47     Label L_already_dirty;
48     __ ldrb(rscratch2,  Address(obj, rscratch1));
49     __ cbz(rscratch2, L_already_dirty);
50     __ strb(zr, Address(obj, rscratch1));
51     __ bind(L_already_dirty);
52   } else {
53     __ strb(zr, Address(obj, rscratch1));
54   }
55 }
56 
57 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
58                                                                     Register start, Register count, Register scratch, RegSet saved_regs) {
59   Label L_loop, L_done;
60   const Register end = count;
61 
62   __ cbz(count, L_done); // zero count - nothing to do
63 
64   __ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop))); // end = start + count << LogBytesPerHeapOop
65   __ sub(end, end, BytesPerHeapOop); // last element address to make inclusive
66   __ lsr(start, start, CardTable::card_shift());
67   __ lsr(end, end, CardTable::card_shift());
68   __ sub(count, end, start); // number of bytes to copy
69 
70   __ load_byte_map_base(scratch);
71   __ add(start, start, scratch);
72   __ bind(L_loop);
73   __ strb(zr, Address(start, count));
74   __ subs(count, count, 1);
75   __ br(Assembler::GE, L_loop);
76   __ bind(L_done);
77 }
78 
79 void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
80                                                 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
81   bool in_heap = (decorators & IN_HEAP) != 0;
82   bool is_array = (decorators & IS_ARRAY) != 0;
83   bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
84   bool precise = is_array || on_anonymous;
85 
86   bool needs_post_barrier = val != noreg && in_heap;
87   BarrierSetAssembler::store_at(masm, decorators, type, dst, val, noreg, noreg, noreg);
88   if (needs_post_barrier) {
89     // flatten object address if needed
90     if (!precise || (dst.index() == noreg && dst.offset() == 0)) {
91       store_check(masm, dst.base(), dst);
92     } else {
93       __ lea(tmp3, dst);
94       store_check(masm, tmp3, dst);
95     }
96   }
97 }

15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 #include "asm/macroAssembler.inline.hpp"
26 #include "gc/shared/barrierSet.hpp"
27 #include "gc/shared/cardTable.hpp"
28 #include "gc/shared/cardTableBarrierSet.hpp"
29 #include "gc/shared/cardTableBarrierSetAssembler.hpp"
30 #include "gc/shared/gc_globals.hpp"
31 #include "interpreter/interp_masm.hpp"
32 
33 #define __ masm->
34 
35 void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst, Register rscratch) {
36   precond(rscratch != noreg);
37   BarrierSet* bs = BarrierSet::barrier_set();
38   assert(bs->kind() == BarrierSet::CardTableBarrierSet, "Wrong barrier set kind");
39 
40   __ lsr(obj, obj, CardTable::card_shift());
41 
42   assert(CardTable::dirty_card_val() == 0, "must be");
43 
44   __ load_byte_map_base(rscratch);
45 
46   if (UseCondCardMark) {
47     precond(rscratch != rscratch2);
48     Label L_already_dirty;
49     __ ldrb(rscratch2,  Address(obj, rscratch));
50     __ cbz(rscratch2, L_already_dirty);
51     __ strb(zr, Address(obj, rscratch));
52     __ bind(L_already_dirty);
53   } else {
54     __ strb(zr, Address(obj, rscratch));
55   }
56 }
57 
58 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
59                                                                     Register start, Register count, Register scratch, RegSet saved_regs) {
60   Label L_loop, L_done;
61   const Register end = count;
62 
63   __ cbz(count, L_done); // zero count - nothing to do
64 
65   __ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop))); // end = start + count << LogBytesPerHeapOop
66   __ sub(end, end, BytesPerHeapOop); // last element address to make inclusive
67   __ lsr(start, start, CardTable::card_shift());
68   __ lsr(end, end, CardTable::card_shift());
69   __ sub(count, end, start); // number of bytes to copy
70 
71   __ load_byte_map_base(scratch);
72   __ add(start, start, scratch);
73   __ bind(L_loop);
74   __ strb(zr, Address(start, count));
75   __ subs(count, count, 1);
76   __ br(Assembler::GE, L_loop);
77   __ bind(L_done);
78 }
79 
80 void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
81                                                 Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
82   bool in_heap = (decorators & IN_HEAP) != 0;
83   bool is_array = (decorators & IS_ARRAY) != 0;
84   bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
85   bool precise = is_array || on_anonymous;
86 
87   bool needs_post_barrier = val != noreg && in_heap;
88   BarrierSetAssembler::store_at(masm, decorators, type, dst, val, noreg, noreg, noreg);
89   if (needs_post_barrier) {
90     // flatten object address if needed
91     if (!precise || (dst.index() == noreg && dst.offset() == 0)) {
92       store_check(masm, dst.base(), dst, tmp2);
93     } else {
94       __ lea(tmp3, dst);
95       store_check(masm, tmp3, dst, tmp2);
96     }
97   }
98 }
< prev index next >