< prev index next >

src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp

Print this page

  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 "precompiled.hpp"
 26 #include "asm/macroAssembler.inline.hpp"

 27 #include "gc/shared/barrierSet.hpp"
 28 #include "gc/shared/cardTable.hpp"
 29 #include "gc/shared/cardTableBarrierSet.hpp"
 30 #include "gc/shared/cardTableBarrierSetAssembler.hpp"
 31 #include "gc/shared/gc_globals.hpp"
 32 
 33 #define __ masm->
 34 
 35 #ifdef PRODUCT
 36 #define BLOCK_COMMENT(str) /* nothing */
 37 #else
 38 #define BLOCK_COMMENT(str) __ block_comment(str)
 39 #endif
 40 
 41 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
 42 
 43 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
 44 
 45 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
 46                                                                     Register addr, Register count, Register tmp) {
 47   BarrierSet *bs = BarrierSet::barrier_set();
 48   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
 49   CardTable* ct = ctbs->card_table();
 50   intptr_t disp = (intptr_t) ct->byte_map_base();
 51 
 52   Label L_loop, L_done;
 53   const Register end = count;
 54   assert_different_registers(addr, end);
 55 
 56   __ testl(count, count);
 57   __ jcc(Assembler::zero, L_done); // zero count - nothing to do
 58 
 59 
 60 #ifdef _LP64
 61   __ leaq(end, Address(addr, count, TIMES_OOP, 0));  // end == addr+count*oop_size
 62   __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
 63   __ shrptr(addr, CardTable::card_shift());
 64   __ shrptr(end, CardTable::card_shift());
 65   __ subptr(end, addr); // end --> cards count
 66 
 67   __ mov64(tmp, disp);





 68   __ addptr(addr, tmp);
 69 __ BIND(L_loop);
 70   __ movb(Address(addr, count, Address::times_1), 0);
 71   __ decrement(count);
 72   __ jcc(Assembler::greaterEqual, L_loop);
 73 #else
 74   __ lea(end,  Address(addr, count, Address::times_ptr, -wordSize));
 75   __ shrptr(addr, CardTable::card_shift());
 76   __ shrptr(end,   CardTable::card_shift());
 77   __ subptr(end, addr); // end --> count
 78 __ BIND(L_loop);
 79   Address cardtable(addr, count, Address::times_1, disp);
 80   __ movb(cardtable, 0);
 81   __ decrement(count);
 82   __ jcc(Assembler::greaterEqual, L_loop);
 83 #endif
 84 
 85 __ BIND(L_done);
 86 }
 87 
 88 void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) {
 89   // Does a store check for the oop in register obj. The content of
 90   // register obj is destroyed afterwards.
 91   BarrierSet* bs = BarrierSet::barrier_set();
 92 
 93   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
 94   CardTable* ct = ctbs->card_table();
 95 
 96   __ shrptr(obj, CardTable::card_shift());
 97 
 98   Address card_addr;
 99 
100   // The calculation for byte_map_base is as follows:
101   // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
102   // So this essentially converts an address to a displacement and it will
103   // never need to be relocated. On 64bit however the value may be too
104   // large for a 32bit displacement.
105   intptr_t byte_map_base = (intptr_t)ct->byte_map_base();






106   if (__ is_simm32(byte_map_base)) {
107     card_addr = Address(noreg, obj, Address::times_1, byte_map_base);
108   } else {
109     // By doing it as an ExternalAddress 'byte_map_base' could be converted to a rip-relative
110     // displacement and done in a single instruction given favorable mapping and a
111     // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
112     // entry and that entry is not properly handled by the relocation code.
113     AddressLiteral cardtable((address)byte_map_base, relocInfo::none);
114     Address index(noreg, obj, Address::times_1);
115     card_addr = __ as_Address(ArrayAddress(cardtable, index), rscratch1);
116   }
117 
118   int dirty = CardTable::dirty_card_val();
119   if (UseCondCardMark) {
120     Label L_already_dirty;
121     __ cmpb(card_addr, dirty);
122     __ jccb(Assembler::equal, L_already_dirty);
123     __ movb(card_addr, dirty);
124     __ bind(L_already_dirty);
125   } else {

  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 "precompiled.hpp"
 26 #include "asm/macroAssembler.inline.hpp"
 27 #include "code/SCCache.hpp"
 28 #include "gc/shared/barrierSet.hpp"
 29 #include "gc/shared/cardTable.hpp"
 30 #include "gc/shared/cardTableBarrierSet.hpp"
 31 #include "gc/shared/cardTableBarrierSetAssembler.hpp"
 32 #include "gc/shared/gc_globals.hpp"
 33 
 34 #define __ masm->
 35 
 36 #ifdef PRODUCT
 37 #define BLOCK_COMMENT(str) /* nothing */
 38 #else
 39 #define BLOCK_COMMENT(str) __ block_comment(str)
 40 #endif
 41 
 42 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
 43 
 44 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
 45 
 46 void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
 47                                                                     Register addr, Register count, Register tmp) {
 48   BarrierSet *bs = BarrierSet::barrier_set();
 49   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
 50   CardTable* ct = ctbs->card_table();
 51   intptr_t byte_map_base = (intptr_t) ct->byte_map_base();
 52 
 53   Label L_loop, L_done;
 54   const Register end = count;
 55   assert_different_registers(addr, end);
 56 
 57   __ testl(count, count);
 58   __ jcc(Assembler::zero, L_done); // zero count - nothing to do
 59 
 60 
 61 #ifdef _LP64
 62   __ leaq(end, Address(addr, count, TIMES_OOP, 0));  // end == addr+count*oop_size
 63   __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
 64   __ shrptr(addr, CardTable::card_shift());
 65   __ shrptr(end, CardTable::card_shift());
 66   __ subptr(end, addr); // end --> cards count
 67 
 68   if (SCCache::is_on_for_write()) {
 69     // SCA needs relocation info for this address
 70     __ lea(tmp, ExternalAddress((address)byte_map_base));
 71   } else {
 72     __ mov64(tmp, byte_map_base);
 73   }
 74   __ addptr(addr, tmp);
 75 __ BIND(L_loop);
 76   __ movb(Address(addr, count, Address::times_1), 0);
 77   __ decrement(count);
 78   __ jcc(Assembler::greaterEqual, L_loop);
 79 #else
 80   __ lea(end,  Address(addr, count, Address::times_ptr, -wordSize));
 81   __ shrptr(addr, CardTable::card_shift());
 82   __ shrptr(end,   CardTable::card_shift());
 83   __ subptr(end, addr); // end --> count
 84 __ BIND(L_loop);
 85   Address cardtable(addr, count, Address::times_1, byte_map_base);
 86   __ movb(cardtable, 0);
 87   __ decrement(count);
 88   __ jcc(Assembler::greaterEqual, L_loop);
 89 #endif
 90 
 91 __ BIND(L_done);
 92 }
 93 
 94 void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) {
 95   // Does a store check for the oop in register obj. The content of
 96   // register obj is destroyed afterwards.
 97   BarrierSet* bs = BarrierSet::barrier_set();
 98 
 99   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
100   CardTable* ct = ctbs->card_table();
101 
102   __ shrptr(obj, CardTable::card_shift());
103 
104   Address card_addr;
105 
106   // The calculation for byte_map_base is as follows:
107   // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
108   // So this essentially converts an address to a displacement and it will
109   // never need to be relocated. On 64bit however the value may be too
110   // large for a 32bit displacement.
111   intptr_t byte_map_base = (intptr_t)ct->byte_map_base();
112   if (SCCache::is_on_for_write()) {
113     // SCA needs relocation info for this address
114     ExternalAddress cardtable((address)byte_map_base);
115     Address index(noreg, obj, Address::times_1);
116     card_addr = __ as_Address(ArrayAddress(cardtable, index), rscratch1);
117   } else
118   if (__ is_simm32(byte_map_base)) {
119     card_addr = Address(noreg, obj, Address::times_1, byte_map_base);
120   } else {
121     // By doing it as an ExternalAddress 'byte_map_base' could be converted to a rip-relative
122     // displacement and done in a single instruction given favorable mapping and a
123     // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
124     // entry and that entry is not properly handled by the relocation code.
125     AddressLiteral cardtable((address)byte_map_base, relocInfo::none);
126     Address index(noreg, obj, Address::times_1);
127     card_addr = __ as_Address(ArrayAddress(cardtable, index), rscratch1);
128   }
129 
130   int dirty = CardTable::dirty_card_val();
131   if (UseCondCardMark) {
132     Label L_already_dirty;
133     __ cmpb(card_addr, dirty);
134     __ jccb(Assembler::equal, L_already_dirty);
135     __ movb(card_addr, dirty);
136     __ bind(L_already_dirty);
137   } else {
< prev index next >