src/cpu/sparc/vm/templateTable_sparc.cpp

Print this page
rev 4468 : 8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc.
Summary: In do_oop_store the uncompressed value of the oop being stored needs to be preserved and passed to g1_write_barrier_post. This is necessary for the heap region cross check to work correctly.
Reviewed-by: coleenp, johnc
Contributed-by: Martin Doerr <martin.doerr@sap.com>

@@ -60,10 +60,17 @@
         // Load and record the previous value.
         __ g1_write_barrier_pre(base, index, offset,
                                 noreg /* pre_val */,
                                 tmp, true /*preserve_o_regs*/);
 
+        // G1 barrier needs uncompressed oop for region cross check.
+        Register new_val = val;
+        if (UseCompressedOops && val != G0) {
+          new_val = tmp;
+          __ mov(val, new_val);
+        }
+
         if (index == noreg ) {
           assert(Assembler::is_simm13(offset), "fix this code");
           __ store_heap_oop(val, base, offset);
         } else {
           __ store_heap_oop(val, base, index);

@@ -76,11 +83,11 @@
               __ add(base, offset, base);
             } else {
               __ add(base, index, base);
             }
           }
-          __ g1_write_barrier_post(base, val, tmp);
+          __ g1_write_barrier_post(base, new_val, tmp);
         }
       }
       break;
 #endif // SERIALGC
     case BarrierSet::CardTableModRef: