< prev index next >

src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp

Print this page

  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());

109   CardTable* ct = ctbs->card_table();
110   LIR_Const* card_table_base = new LIR_Const(ct->byte_map_base());
111   SHENANDOAHGC_ONLY(assert(!UseShenandoahGC, "Shenandoah byte_map_base is not constant.");)
112 
113   if (addr->is_address()) {
114     LIR_Address* address = addr->as_address_ptr();
115     // ptr cannot be an object because we use this barrier for array card marks
116     // and addr can point in the middle of an array.
117     LIR_Opr ptr = gen->new_pointer_register();
118     if (!address->index()->is_valid() && address->disp() == 0) {
119       __ move(address->base(), ptr);
120     } else {
121       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
122       __ leal(addr, ptr);
123     }
124     addr = ptr;
125   }
126   assert(addr->is_register(), "must be a register at this point");
127 
128 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER

129   gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base);
130 #else
131   LIR_Opr tmp = gen->new_pointer_register();
132   if (two_operand_lir_form) {
133     LIR_Opr addr_opr = LIR_OprFact::address(new LIR_Address(addr, addr->type()));
134     __ leal(addr_opr, tmp);
135     __ unsigned_shift_right(tmp, CardTable::card_shift(), tmp);
136   } else {
137     __ unsigned_shift_right(addr, CardTable::card_shift(), tmp);
138   }
139 
140   LIR_Address* card_addr;











141   if (gen->can_inline_as_constant(card_table_base)) {
142     card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);
143   } else {
144     card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);
145   }
146 
147   LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());
148   if (UseCondCardMark) {
149     LIR_Opr cur_value = gen->new_register(T_INT);
150     __ move(card_addr, cur_value);
151 
152     LabelObj* L_already_dirty = new LabelObj();
153     __ cmp(lir_cond_equal, cur_value, dirty);
154     __ branch(lir_cond_equal, L_already_dirty->label());
155     __ move(dirty, card_addr);
156     __ branch_destination(L_already_dirty->label());
157   } else {
158     __ move(dirty, card_addr);
159   }
160 #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());

110   CardTable* ct = ctbs->card_table();
111   LIR_Const* card_table_base = new LIR_Const(ct->byte_map_base());
112   SHENANDOAHGC_ONLY(assert(!UseShenandoahGC, "Shenandoah byte_map_base is not constant.");)
113 
114   if (addr->is_address()) {
115     LIR_Address* address = addr->as_address_ptr();
116     // ptr cannot be an object because we use this barrier for array card marks
117     // and addr can point in the middle of an array.
118     LIR_Opr ptr = gen->new_pointer_register();
119     if (!address->index()->is_valid() && address->disp() == 0) {
120       __ move(address->base(), ptr);
121     } else {
122       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
123       __ leal(addr, ptr);
124     }
125     addr = ptr;
126   }
127   assert(addr->is_register(), "must be a register at this point");
128 
129 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
130   assert(!AOTCodeCache::is_on(), "this path is not implemented");
131   gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base);
132 #else
133   LIR_Opr tmp = gen->new_pointer_register();
134   if (two_operand_lir_form) {
135     LIR_Opr addr_opr = LIR_OprFact::address(new LIR_Address(addr, addr->type()));
136     __ leal(addr_opr, tmp);
137     __ unsigned_shift_right(tmp, CardTable::card_shift(), tmp);
138   } else {
139     __ unsigned_shift_right(addr, CardTable::card_shift(), tmp);
140   }
141 
142   LIR_Address* card_addr;
143 #if INCLUDE_CDS
144   if (AOTCodeCache::is_on_for_dump()) {
145     // load the card table address from the AOT Runtime Constants area
146     LIR_Opr byte_map_base_adr = LIR_OprFact::intptrConst(AOTRuntimeConstants::card_table_address());
147     LIR_Opr byte_map_base_reg = gen->new_pointer_register();
148     __ move(byte_map_base_adr, byte_map_base_reg);
149     LIR_Address* byte_map_base_indirect = new LIR_Address(byte_map_base_reg, 0, T_LONG);
150     __ move(byte_map_base_indirect, byte_map_base_reg);
151     card_addr = new LIR_Address(tmp, byte_map_base_reg, T_BYTE);
152   } else
153 #endif
154   if (gen->can_inline_as_constant(card_table_base)) {
155     card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);
156   } else {
157     card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);
158   }
159 
160   LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());
161   if (UseCondCardMark) {
162     LIR_Opr cur_value = gen->new_register(T_INT);
163     __ move(card_addr, cur_value);
164 
165     LabelObj* L_already_dirty = new LabelObj();
166     __ cmp(lir_cond_equal, cur_value, dirty);
167     __ branch(lir_cond_equal, L_already_dirty->label());
168     __ move(dirty, card_addr);
169     __ branch_destination(L_already_dirty->label());
170   } else {
171     __ move(dirty, card_addr);
172   }
173 #endif
< prev index next >