< prev index next >

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

Print this page
@@ -21,10 +21,11 @@
   * questions.
   *
   */
  
  #include "asm/macroAssembler.inline.hpp"
+ #include "code/aotCodeCache.hpp"
  #include "gc/shared/barrierSet.hpp"
  #include "gc/shared/cardTable.hpp"
  #include "gc/shared/cardTableBarrierSet.hpp"
  #include "gc/shared/cardTableBarrierSetAssembler.hpp"
  #include "gc/shared/gc_globals.hpp"

@@ -44,11 +45,11 @@
  void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                                                      Register addr, Register count, Register tmp) {
    BarrierSet *bs = BarrierSet::barrier_set();
    CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
    CardTable* ct = ctbs->card_table();
-   intptr_t disp = (intptr_t) ct->byte_map_base();
+   intptr_t byte_map_base = (intptr_t) ct->byte_map_base();
    SHENANDOAHGC_ONLY(assert(!UseShenandoahGC, "Shenandoah byte_map_base is not constant.");)
  
    Label L_loop, L_done;
    const Register end = count;
    assert_different_registers(addr, end);

@@ -61,48 +62,62 @@
    __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
    __ shrptr(addr, CardTable::card_shift());
    __ shrptr(end, CardTable::card_shift());
    __ subptr(end, addr); // end --> cards count
  
-   __ mov64(tmp, disp);
+ #if INCLUDE_CDS
+   if (AOTCodeCache::is_on_for_dump()) {
+     __ movptr(tmp, ExternalAddress(AOTRuntimeConstants::card_table_address()));
+   } else
+ #endif
+   {
+     __ mov64(tmp, byte_map_base);
+   }
    __ addptr(addr, tmp);
  __ BIND(L_loop);
    __ movb(Address(addr, count, Address::times_1), 0);
    __ decrement(count);
    __ jcc(Assembler::greaterEqual, L_loop);
  
  __ BIND(L_done);
  }
  
- void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) {
+ void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst, Register rscratch) {
    // Does a store check for the oop in register obj. The content of
    // register obj is destroyed afterwards.
    BarrierSet* bs = BarrierSet::barrier_set();
  
    CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
    CardTable* ct = ctbs->card_table();
  
    __ shrptr(obj, CardTable::card_shift());
  
    Address card_addr;
+   precond(rscratch != noreg);
  
    // The calculation for byte_map_base is as follows:
    // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
    // So this essentially converts an address to a displacement and it will
    // never need to be relocated. On 64bit however the value may be too
    // large for a 32bit displacement.
    intptr_t byte_map_base = (intptr_t)ct->byte_map_base();
+ #if INCLUDE_CDS
+   if (AOTCodeCache::is_on_for_dump()) {
+     __ movptr(rscratch, ExternalAddress(AOTRuntimeConstants::card_table_address()));
+     card_addr = Address(rscratch, obj, Address::times_1, 0);
+   } else
+ #endif
    if (__ is_simm32(byte_map_base)) {
      card_addr = Address(noreg, obj, Address::times_1, byte_map_base);
    } else {
      // By doing it as an ExternalAddress 'byte_map_base' could be converted to a rip-relative
      // displacement and done in a single instruction given favorable mapping and a
      // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
      // entry and that entry is not properly handled by the relocation code.
      AddressLiteral cardtable((address)byte_map_base, relocInfo::none);
      Address index(noreg, obj, Address::times_1);
-     card_addr = __ as_Address(ArrayAddress(cardtable, index), rscratch1);
+     card_addr = __ as_Address(ArrayAddress(cardtable, index), rscratch);
    }
  
    int dirty = CardTable::dirty_card_val();
    if (UseCondCardMark) {
      Label L_already_dirty;

@@ -127,12 +142,12 @@
  
    BarrierSetAssembler::store_at(masm, decorators, type, dst, val, noreg, noreg, noreg);
    if (needs_post_barrier) {
      // flatten object address if needed
      if (!precise || (dst.index() == noreg && dst.disp() == 0)) {
-       store_check(masm, dst.base(), dst);
+       store_check(masm, dst.base(), dst, tmp2);
      } else {
        __ lea(tmp1, dst);
-       store_check(masm, tmp1, dst);
+       store_check(masm, tmp1, dst, tmp2);
      }
    }
  }
< prev index next >