src/hotspot/cpu/x86/templateTable_x86.cpp
changeset 49748 6a880e576856
parent 49480 d7df2dd501ce
child 49987 e4b3cc56e2b2
child 56448 76d86de267b9
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Wed Apr 11 10:05:02 2018 -0400
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Wed Apr 11 16:07:42 2018 +0200
@@ -149,84 +149,18 @@
 
 
 static void do_oop_store(InterpreterMacroAssembler* _masm,
-                         Address obj,
+                         Address dst,
                          Register val,
-                         BarrierSet::Name barrier,
-                         bool precise) {
+                         DecoratorSet decorators = 0) {
   assert(val == noreg || val == rax, "parameter is just for looks");
-  switch (barrier) {
-#if INCLUDE_ALL_GCS
-    case BarrierSet::G1BarrierSet:
-      {
-        // flatten object address if needed
-        // We do it regardless of precise because we need the registers
-        if (obj.index() == noreg && obj.disp() == 0) {
-          if (obj.base() != rdx) {
-            __ movptr(rdx, obj.base());
-          }
-        } else {
-          __ lea(rdx, obj);
-        }
-
-        Register rtmp    = LP64_ONLY(r8)         NOT_LP64(rsi);
-        Register rthread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
-
-        NOT_LP64(__ get_thread(rcx));
-        NOT_LP64(__ save_bcp());
-
-        __ g1_write_barrier_pre(rdx /* obj */,
-                                rbx /* pre_val */,
-                                rthread /* thread */,
-                                rtmp  /* tmp */,
-                                val != noreg /* tosca_live */,
-                                false /* expand_call */);
-        if (val == noreg) {
-          __ store_heap_oop_null(Address(rdx, 0));
-        } else {
-          // G1 barrier needs uncompressed oop for region cross check.
-          Register new_val = val;
-          if (UseCompressedOops) {
-            new_val = rbx;
-            __ movptr(new_val, val);
-          }
-          __ store_heap_oop(Address(rdx, 0), val);
-          __ g1_write_barrier_post(rdx /* store_adr */,
-                                   new_val /* new_val */,
-                                   rthread /* thread */,
-                                   rtmp /* tmp */,
-                                   rbx /* tmp2 */);
-        }
-        NOT_LP64( __ restore_bcp());
-      }
-      break;
-#endif // INCLUDE_ALL_GCS
-    case BarrierSet::CardTableBarrierSet:
-      {
-        if (val == noreg) {
-          __ store_heap_oop_null(obj);
-        } else {
-          __ store_heap_oop(obj, val);
-          // flatten object address if needed
-          if (!precise || (obj.index() == noreg && obj.disp() == 0)) {
-            __ store_check(obj.base());
-          } else {
-            __ lea(rdx, obj);
-            __ store_check(rdx);
-          }
-        }
-      }
-      break;
-    case BarrierSet::ModRef:
-      if (val == noreg) {
-        __ store_heap_oop_null(obj);
-      } else {
-        __ store_heap_oop(obj, val);
-      }
-      break;
-    default      :
-      ShouldNotReachHere();
-
-  }
+  __ store_heap_oop(dst, val, rdx, rbx, decorators);
+}
+
+static void do_oop_load(InterpreterMacroAssembler* _masm,
+                        Address src,
+                        Register dst,
+                        DecoratorSet decorators = 0) {
+  __ load_heap_oop(dst, src, rdx, rbx, decorators);
 }
 
 Address TemplateTable::at_bcp(int offset) {
@@ -876,9 +810,12 @@
   // rax: index
   // rdx: array
   index_check(rdx, rax); // kills rbx
-  __ load_heap_oop(rax, Address(rdx, rax,
-                                UseCompressedOops ? Address::times_4 : Address::times_ptr,
-                                arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
+  do_oop_load(_masm,
+              Address(rdx, rax,
+                      UseCompressedOops ? Address::times_4 : Address::times_ptr,
+                      arrayOopDesc::base_offset_in_bytes(T_OBJECT)),
+              rax,
+              IN_HEAP_ARRAY);
 }
 
 void TemplateTable::baload() {
@@ -1189,7 +1126,7 @@
   // Get the value we will store
   __ movptr(rax, at_tos());
   // Now store using the appropriate barrier
-  do_oop_store(_masm, Address(rdx, 0), rax, _bs->kind(), true);
+  do_oop_store(_masm, Address(rdx, 0), rax, IN_HEAP_ARRAY);
   __ jmp(done);
 
   // Have a NULL in rax, rdx=array, ecx=index.  Store NULL at ary[idx]
@@ -1197,7 +1134,7 @@
   __ profile_null_seen(rbx);
 
   // Store a NULL
-  do_oop_store(_masm, element_address, noreg, _bs->kind(), true);
+  do_oop_store(_masm, element_address, noreg, IN_HEAP_ARRAY);
 
   // Pop stack arguments
   __ bind(done);
@@ -2951,7 +2888,7 @@
   __ cmpl(flags, atos);
   __ jcc(Assembler::notEqual, notObj);
   // atos
-  __ load_heap_oop(rax, field);
+  do_oop_load(_masm, field, rax);
   __ push(atos);
   if (!is_static && rc == may_rewrite) {
     patch_bytecode(Bytecodes::_fast_agetfield, bc, rbx);
@@ -3226,7 +3163,7 @@
     __ pop(atos);
     if (!is_static) pop_and_check_object(obj);
     // Store into the field
-    do_oop_store(_masm, field, rax, _bs->kind(), false);
+    do_oop_store(_masm, field, rax);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_aputfield, bc, rbx, true, byte_no);
     }
@@ -3479,7 +3416,7 @@
   // access field
   switch (bytecode()) {
   case Bytecodes::_fast_aputfield:
-    do_oop_store(_masm, field, rax, _bs->kind(), false);
+    do_oop_store(_masm, field, rax);
     break;
   case Bytecodes::_fast_lputfield:
 #ifdef _LP64
@@ -3568,7 +3505,7 @@
   // access field
   switch (bytecode()) {
   case Bytecodes::_fast_agetfield:
-    __ load_heap_oop(rax, field);
+    do_oop_load(_masm, field, rax);
     __ verify_oop(rax);
     break;
   case Bytecodes::_fast_lgetfield:
@@ -3630,7 +3567,7 @@
     __ movl(rax, field);
     break;
   case atos:
-    __ load_heap_oop(rax, field);
+    do_oop_load(_masm, field, rax);
     __ verify_oop(rax);
     break;
   case ftos: