< prev index next >

src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp

Print this page
@@ -23,10 +23,13 @@
   */
  
  #include "precompiled.hpp"
  #include "c1/c1_LIRGenerator.hpp"
  #include "c1/c1_CodeStubs.hpp"
+ #if INCLUDE_CDS
+ #include "code/SCCache.hpp"
+ #endif
  #include "gc/g1/c1/g1BarrierSetC1.hpp"
  #include "gc/g1/g1BarrierSet.hpp"
  #include "gc/g1/g1BarrierSetAssembler.hpp"
  #include "gc/g1/g1HeapRegion.hpp"
  #include "gc/g1/g1ThreadLocalData.hpp"

@@ -151,24 +154,61 @@
    }
    assert(addr->is_register(), "must be a register at this point");
  
    LIR_Opr xor_res = gen->new_pointer_register();
    LIR_Opr xor_shift_res = gen->new_pointer_register();
+ #if INCLUDE_CDS
+   // we need to load the grain shift from the AOT Runtime
+   // Constants Area
+   LIR_Opr grain_shift_addr = LIR_OprFact::intptrConst(AOTRuntimeConstants::grain_shift_address());
+   LIR_Opr grain_shift_reg = gen->new_pointer_register();
+   LIR_Address* grain_shift_indirect = new LIR_Address(grain_shift_reg, 0, T_INT);
+ #ifdef X86
+   LIR_Opr grain_shift = gen->shiftCountOpr();
+ #else // X86
+   LIR_Opr grain_shift = gen->new_register(T_INT);
+ #endif // X86
+ #endif
    if (two_operand_lir_form) {
      __ move(addr, xor_res);
      __ logical_xor(xor_res, new_val, xor_res);
-     __ move(xor_res, xor_shift_res);
-     __ unsigned_shift_right(xor_shift_res,
-                             LIR_OprFact::intConst(checked_cast<jint>(G1HeapRegion::LogOfHRGrainBytes)),
-                             xor_shift_res,
-                             LIR_Opr::illegalOpr());
+ #if INCLUDE_CDS
+     if (SCCache::is_on_for_write()) {
+       __ move(grain_shift_addr, grain_shift_reg);
+       __ move(xor_res, xor_shift_res);
+       __ move(grain_shift_indirect, grain_shift);
+       __ unsigned_shift_right(xor_shift_res,
+                               grain_shift,
+                               xor_shift_res,
+                               LIR_Opr::illegalOpr());
+     } else
+ #endif
+     {
+       __ move(xor_res, xor_shift_res);
+       __ unsigned_shift_right(xor_shift_res,
+                               LIR_OprFact::intConst(checked_cast<jint>(G1HeapRegion::LogOfHRGrainBytes)),
+                               xor_shift_res,
+                               LIR_Opr::illegalOpr());
+     }
    } else {
      __ logical_xor(addr, new_val, xor_res);
-     __ unsigned_shift_right(xor_res,
-                             LIR_OprFact::intConst(checked_cast<jint>(G1HeapRegion::LogOfHRGrainBytes)),
-                             xor_shift_res,
-                             LIR_Opr::illegalOpr());
+ #if INCLUDE_CDS
+     if (SCCache::is_on_for_write()) {
+       __ move(grain_shift_addr, grain_shift_reg);
+       __ move(grain_shift_indirect, grain_shift);
+       __ unsigned_shift_right(xor_res,
+                               grain_shift,
+                               xor_shift_res,
+                               LIR_Opr::illegalOpr());
+     } else
+ #endif
+     {
+       __ unsigned_shift_right(xor_res,
+                               LIR_OprFact::intConst(checked_cast<jint>(G1HeapRegion::LogOfHRGrainBytes)),
+                               xor_shift_res,
+                               LIR_Opr::illegalOpr());
+     }
    }
  
    __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
  
    CodeStub* slow = new G1PostBarrierStub(addr, new_val);
< prev index next >