< prev index next >

src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp

Print this page
rev 58062 : 8239081: Shenandoah: Consolidate C1 LRB and native barriers

@@ -105,19 +105,19 @@
 
   __ branch(lir_cond_notEqual, T_INT, slow);
   __ branch_destination(slow->continuation());
 }
 
-LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr) {
+LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr, bool is_native) {
   if (ShenandoahLoadRefBarrier) {
-    return load_reference_barrier_impl(gen, obj, addr);
+    return load_reference_barrier_impl(gen, obj, addr, is_native);
   } else {
     return obj;
   }
 }
 
-LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier_impl(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr) {
+LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier_impl(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr, bool is_native) {
   assert(ShenandoahLoadRefBarrier, "Should be enabled");
 
   obj = ensure_in_register(gen, obj, T_OBJECT);
   assert(obj->is_register(), "must be a register at this point");
   addr = ensure_in_register(gen, addr, T_ADDRESS);

@@ -148,11 +148,11 @@
     __ logical_and(flag_val, mask_reg, masked_flag);
     flag_val = masked_flag;
   }
   __ cmp(lir_cond_notEqual, flag_val, LIR_OprFact::intConst(0));
 
-  CodeStub* slow = new ShenandoahLoadReferenceBarrierStub(obj, addr, result, tmp1, tmp2);
+  CodeStub* slow = new ShenandoahLoadReferenceBarrierStub(obj, addr, result, tmp1, tmp2, is_native);
   __ branch(lir_cond_notEqual, T_INT, slow);
   __ branch_destination(slow->continuation());
 
   return result;
 }

@@ -209,30 +209,15 @@
   DecoratorSet decorators = access.decorators();
   BasicType type = access.type();
 
   // 2: load a reference from src location and apply LRB if ShenandoahLoadRefBarrier is set
   if (ShenandoahBarrierSet::need_load_reference_barrier(decorators, type)) {
-    if (ShenandoahBarrierSet::use_load_reference_barrier_native(decorators, type)) {
-      BarrierSetC1::load_at_resolved(access, result);
-      LIR_OprList* args = new LIR_OprList();
-      LIR_Opr addr = access.resolved_addr();
-      addr = ensure_in_register(gen, addr, T_ADDRESS);
-      args->append(result);
-      args->append(addr);
-      BasicTypeList signature;
-      signature.append(T_OBJECT);
-      signature.append(T_ADDRESS);
-      LIR_Opr call_result = gen->call_runtime(&signature, args,
-                                              CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native),
-                                              objectType, NULL);
-      __ move(call_result, result);
-    } else {
       LIR_Opr tmp = gen->new_register(T_OBJECT);
       BarrierSetC1::load_at_resolved(access, tmp);
-      tmp = load_reference_barrier(gen, tmp, access.resolved_addr());
+    bool is_native = ShenandoahBarrierSet::use_load_reference_barrier_native(decorators, type);
+    tmp = load_reference_barrier(gen, tmp, access.resolved_addr(), is_native);
       __ move(tmp, result);
-    }
   } else {
     BarrierSetC1::load_at_resolved(access, result);
   }
 
   // 3: apply keep-alive barrier if ShenandoahKeepAliveBarrier is set

@@ -266,31 +251,35 @@
     return NULL;
   }
 };
 
 class C1ShenandoahLoadReferenceBarrierCodeGenClosure : public StubAssemblerCodeGenClosure {
+private:
+  const bool _is_native;
+
+public:
+  C1ShenandoahLoadReferenceBarrierCodeGenClosure(bool is_native) : _is_native(is_native) {}
+
   virtual OopMapSet* generate_code(StubAssembler* sasm) {
     ShenandoahBarrierSetAssembler* bs = (ShenandoahBarrierSetAssembler*)BarrierSet::barrier_set()->barrier_set_assembler();
-    bs->generate_c1_load_reference_barrier_runtime_stub(sasm);
+    bs->generate_c1_load_reference_barrier_runtime_stub(sasm, _is_native);
     return NULL;
   }
 };
 
 void ShenandoahBarrierSetC1::generate_c1_runtime_stubs(BufferBlob* buffer_blob) {
   C1ShenandoahPreBarrierCodeGenClosure pre_code_gen_cl;
   _pre_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, -1,
                                                               "shenandoah_pre_barrier_slow",
                                                               false, &pre_code_gen_cl);
   if (ShenandoahLoadRefBarrier) {
-    C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_code_gen_cl;
+    C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_code_gen_cl(false);
     _load_reference_barrier_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1,
                                                                   "shenandoah_load_reference_barrier_slow",
                                                                   false, &lrb_code_gen_cl);
-  }
-}
 
-const char* ShenandoahBarrierSetC1::rtcall_name_for_address(address entry) {
-  if (entry == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native)) {
-    return "ShenandoahRuntime::load_reference_barrier_native";
+    C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_native_code_gen_cl(true);
+    _load_reference_barrier_native_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1,
+                                                                   "shenandoah_load_reference_barrier_native_slow",
+                                                                   false, &lrb_native_code_gen_cl);
   }
-  return NULL;
 }
< prev index next >