< prev index next >

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

Print this page




  26 #include "c1/c1_Defs.hpp"
  27 #include "c1/c1_LIRGenerator.hpp"
  28 #include "gc/shared/c1/barrierSetC1.hpp"
  29 #include "utilities/macros.hpp"
  30 
  31 #ifndef PATCHED_ADDR
  32 #define PATCHED_ADDR  (max_jint)
  33 #endif
  34 
  35 #ifdef ASSERT
  36 #define __ gen->lir(__FILE__, __LINE__)->
  37 #else
  38 #define __ gen->lir()->
  39 #endif
  40 
  41 LIR_Opr BarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {
  42   DecoratorSet decorators = access.decorators();
  43   bool is_array = (decorators & IS_ARRAY) != 0;
  44   bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;
  45 
  46   LIRItem& base = access.base().item();





  47   LIR_Opr offset = access.offset().opr();
  48   LIRGenerator *gen = access.gen();
  49 
  50   LIR_Opr addr_opr;
  51   if (is_array) {
  52     addr_opr = LIR_OprFact::address(gen->emit_array_address(base.result(), offset, access.type()));
  53   } else if (needs_patching) {
  54     // we need to patch the offset in the instruction so don't allow
  55     // generate_address to try to be smart about emitting the -1.
  56     // Otherwise the patching code won't know how to find the
  57     // instruction to patch.
  58     addr_opr = LIR_OprFact::address(new LIR_Address(base.result(), PATCHED_ADDR, access.type()));
  59   } else {
  60     addr_opr = LIR_OprFact::address(gen->generate_address(base.result(), offset, 0, 0, access.type()));
  61   }
  62 
  63   if (resolve_in_register) {
  64     LIR_Opr resolved_addr = gen->new_pointer_register();
  65     __ leal(addr_opr, resolved_addr);
  66     resolved_addr = LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
  67     return resolved_addr;
  68   } else {
  69     return addr_opr;
  70   }
  71 }
  72 
  73 void BarrierSetC1::store_at(LIRAccess& access, LIR_Opr value) {
  74   DecoratorSet decorators = access.decorators();
  75   bool in_heap = (decorators & IN_HEAP) != 0;
  76   assert(in_heap, "not supported yet");
  77 
  78   LIR_Opr resolved = resolve_address(access, false);
  79   access.set_resolved_addr(resolved);
  80   store_at_resolved(access, value);


 310       __ branch(lir_cond_notEqual, offset->type(), cont->label());
 311     }
 312     if (gen_source_check) {
 313       // offset is a const and equals referent offset
 314       // if (source == null) -> continue
 315       __ cmp(lir_cond_equal, base_reg, LIR_OprFact::oopConst(NULL));
 316       __ branch(lir_cond_equal, T_OBJECT, cont->label());
 317     }
 318     LIR_Opr src_klass = gen->new_register(T_OBJECT);
 319     if (gen_type_check) {
 320       // We have determined that offset == referent_offset && src != null.
 321       // if (src->_klass->_reference_type == REF_NONE) -> continue
 322       __ move(new LIR_Address(base_reg, oopDesc::klass_offset_in_bytes(), T_ADDRESS), src_klass);
 323       LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
 324       LIR_Opr reference_type = gen->new_register(T_INT);
 325       __ move(reference_type_addr, reference_type);
 326       __ cmp(lir_cond_equal, reference_type, LIR_OprFact::intConst(REF_NONE));
 327       __ branch(lir_cond_equal, T_INT, cont->label());
 328     }
 329   }








 330 }


  26 #include "c1/c1_Defs.hpp"
  27 #include "c1/c1_LIRGenerator.hpp"
  28 #include "gc/shared/c1/barrierSetC1.hpp"
  29 #include "utilities/macros.hpp"
  30 
  31 #ifndef PATCHED_ADDR
  32 #define PATCHED_ADDR  (max_jint)
  33 #endif
  34 
  35 #ifdef ASSERT
  36 #define __ gen->lir(__FILE__, __LINE__)->
  37 #else
  38 #define __ gen->lir()->
  39 #endif
  40 
  41 LIR_Opr BarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {
  42   DecoratorSet decorators = access.decorators();
  43   bool is_array = (decorators & IS_ARRAY) != 0;
  44   bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;
  45 
  46   LIR_Opr base;
  47   if (access.base().opr() != NULL) {
  48     base = access.base().opr();
  49   } else {
  50     base = access.base().item().result();
  51   }
  52   LIR_Opr offset = access.offset().opr();
  53   LIRGenerator *gen = access.gen();
  54 
  55   LIR_Opr addr_opr;
  56   if (is_array) {
  57     addr_opr = LIR_OprFact::address(gen->emit_array_address(base, offset, access.type()));
  58   } else if (needs_patching) {
  59     // we need to patch the offset in the instruction so don't allow
  60     // generate_address to try to be smart about emitting the -1.
  61     // Otherwise the patching code won't know how to find the
  62     // instruction to patch.
  63     addr_opr = LIR_OprFact::address(new LIR_Address(base, PATCHED_ADDR, access.type()));
  64   } else {
  65     addr_opr = LIR_OprFact::address(gen->generate_address(base, offset, 0, 0, access.type()));
  66   }
  67 
  68   if (resolve_in_register) {
  69     LIR_Opr resolved_addr = gen->new_pointer_register();
  70     __ leal(addr_opr, resolved_addr);
  71     resolved_addr = LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
  72     return resolved_addr;
  73   } else {
  74     return addr_opr;
  75   }
  76 }
  77 
  78 void BarrierSetC1::store_at(LIRAccess& access, LIR_Opr value) {
  79   DecoratorSet decorators = access.decorators();
  80   bool in_heap = (decorators & IN_HEAP) != 0;
  81   assert(in_heap, "not supported yet");
  82 
  83   LIR_Opr resolved = resolve_address(access, false);
  84   access.set_resolved_addr(resolved);
  85   store_at_resolved(access, value);


 315       __ branch(lir_cond_notEqual, offset->type(), cont->label());
 316     }
 317     if (gen_source_check) {
 318       // offset is a const and equals referent offset
 319       // if (source == null) -> continue
 320       __ cmp(lir_cond_equal, base_reg, LIR_OprFact::oopConst(NULL));
 321       __ branch(lir_cond_equal, T_OBJECT, cont->label());
 322     }
 323     LIR_Opr src_klass = gen->new_register(T_OBJECT);
 324     if (gen_type_check) {
 325       // We have determined that offset == referent_offset && src != null.
 326       // if (src->_klass->_reference_type == REF_NONE) -> continue
 327       __ move(new LIR_Address(base_reg, oopDesc::klass_offset_in_bytes(), T_ADDRESS), src_klass);
 328       LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
 329       LIR_Opr reference_type = gen->new_register(T_INT);
 330       __ move(reference_type_addr, reference_type);
 331       __ cmp(lir_cond_equal, reference_type, LIR_OprFact::intConst(REF_NONE));
 332       __ branch(lir_cond_equal, T_INT, cont->label());
 333     }
 334   }
 335 }
 336 
 337 LIR_Opr BarrierSetC1::resolve_for_read(LIRAccess& access) {
 338   return access.base().opr();
 339 }
 340 
 341 LIR_Opr BarrierSetC1::resolve_for_write(LIRAccess& access) {
 342   return access.base().opr();
 343 }
< prev index next >