5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
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 "gc/shared/c1/cardTableBarrierSetC1.hpp"
26 #include "gc/shared/cardTable.hpp"
27 #include "gc/shared/cardTableBarrierSet.hpp"
28 #include "gc/shared/gc_globals.hpp"
29 #include "utilities/macros.hpp"
30
31 #ifdef ASSERT
32 #define __ gen->lir(__FILE__, __LINE__)->
33 #else
34 #define __ gen->lir()->
35 #endif
36
37 void CardTableBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {
38 DecoratorSet decorators = access.decorators();
39 bool is_array = (decorators & IS_ARRAY) != 0;
40 bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
41
42 if (access.is_oop()) {
43 pre_barrier(access, access.resolved_addr(),
44 LIR_OprFact::illegalOpr /* pre_val */, access.patch_emit_info());
106
107 CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
108 LIR_Const* card_table_base = new LIR_Const(ctbs->card_table_base_const());
109
110 if (addr->is_address()) {
111 LIR_Address* address = addr->as_address_ptr();
112 // ptr cannot be an object because we use this barrier for array card marks
113 // and addr can point in the middle of an array.
114 LIR_Opr ptr = gen->new_pointer_register();
115 if (!address->index()->is_valid() && address->disp() == 0) {
116 __ move(address->base(), ptr);
117 } else {
118 assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
119 __ leal(addr, ptr);
120 }
121 addr = ptr;
122 }
123 assert(addr->is_register(), "must be a register at this point");
124
125 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
126 gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base);
127 #else
128 LIR_Opr tmp = gen->new_pointer_register();
129 if (two_operand_lir_form) {
130 LIR_Opr addr_opr = LIR_OprFact::address(new LIR_Address(addr, addr->type()));
131 __ leal(addr_opr, tmp);
132 __ unsigned_shift_right(tmp, CardTable::card_shift(), tmp);
133 } else {
134 __ unsigned_shift_right(addr, CardTable::card_shift(), tmp);
135 }
136
137 LIR_Address* card_addr;
138 if (gen->can_inline_as_constant(card_table_base)) {
139 card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);
140 } else {
141 card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);
142 }
143
144 LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());
145 if (UseCondCardMark) {
146 LIR_Opr cur_value = gen->new_register(T_INT);
147 __ move(card_addr, cur_value);
148
149 LabelObj* L_already_dirty = new LabelObj();
150 __ cmp(lir_cond_equal, cur_value, dirty);
151 __ branch(lir_cond_equal, L_already_dirty->label());
152 __ move(dirty, card_addr);
153 __ branch_destination(L_already_dirty->label());
154 } else {
155 __ move(dirty, card_addr);
156 }
157 #endif
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
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 "code/aotCodeCache.hpp"
26 #include "gc/shared/c1/cardTableBarrierSetC1.hpp"
27 #include "gc/shared/cardTable.hpp"
28 #include "gc/shared/cardTableBarrierSet.hpp"
29 #include "gc/shared/gc_globals.hpp"
30 #include "utilities/macros.hpp"
31
32 #ifdef ASSERT
33 #define __ gen->lir(__FILE__, __LINE__)->
34 #else
35 #define __ gen->lir()->
36 #endif
37
38 void CardTableBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {
39 DecoratorSet decorators = access.decorators();
40 bool is_array = (decorators & IS_ARRAY) != 0;
41 bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
42
43 if (access.is_oop()) {
44 pre_barrier(access, access.resolved_addr(),
45 LIR_OprFact::illegalOpr /* pre_val */, access.patch_emit_info());
107
108 CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());
109 LIR_Const* card_table_base = new LIR_Const(ctbs->card_table_base_const());
110
111 if (addr->is_address()) {
112 LIR_Address* address = addr->as_address_ptr();
113 // ptr cannot be an object because we use this barrier for array card marks
114 // and addr can point in the middle of an array.
115 LIR_Opr ptr = gen->new_pointer_register();
116 if (!address->index()->is_valid() && address->disp() == 0) {
117 __ move(address->base(), ptr);
118 } else {
119 assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
120 __ leal(addr, ptr);
121 }
122 addr = ptr;
123 }
124 assert(addr->is_register(), "must be a register at this point");
125
126 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
127 assert(!AOTCodeCache::is_on(), "this path is not implemented");
128 gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base);
129 #else
130 LIR_Opr tmp = gen->new_pointer_register();
131 if (two_operand_lir_form) {
132 LIR_Opr addr_opr = LIR_OprFact::address(new LIR_Address(addr, addr->type()));
133 __ leal(addr_opr, tmp);
134 __ unsigned_shift_right(tmp, CardTable::card_shift(), tmp);
135 } else {
136 __ unsigned_shift_right(addr, CardTable::card_shift(), tmp);
137 }
138
139 LIR_Address* card_addr;
140 #if INCLUDE_CDS
141 if (AOTCodeCache::is_on_for_dump()) {
142 // load the card table address from the AOT Runtime Constants area
143 LIR_Opr byte_map_base_adr = LIR_OprFact::intptrConst(AOTRuntimeConstants::card_table_address());
144 LIR_Opr byte_map_base_reg = gen->new_pointer_register();
145 __ move(byte_map_base_adr, byte_map_base_reg);
146 LIR_Address* byte_map_base_indirect = new LIR_Address(byte_map_base_reg, 0, T_LONG);
147 __ move(byte_map_base_indirect, byte_map_base_reg);
148 card_addr = new LIR_Address(tmp, byte_map_base_reg, T_BYTE);
149 } else
150 #endif
151 if (gen->can_inline_as_constant(card_table_base)) {
152 card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);
153 } else {
154 card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);
155 }
156
157 LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());
158 if (UseCondCardMark) {
159 LIR_Opr cur_value = gen->new_register(T_INT);
160 __ move(card_addr, cur_value);
161
162 LabelObj* L_already_dirty = new LabelObj();
163 __ cmp(lir_cond_equal, cur_value, dirty);
164 __ branch(lir_cond_equal, L_already_dirty->label());
165 __ move(dirty, card_addr);
166 __ branch_destination(L_already_dirty->label());
167 } else {
168 __ move(dirty, card_addr);
169 }
170 #endif
|