src/cpu/sparc/vm/templateTable_sparc.cpp

Print this page
rev 4482 : G1: Fix bug with compressed oops in template interpreter on x86 and sparc.

In do_oop_store an uncompressed oop needs to be preserved and passed to
g1_write_barrier_post. This is necessary for the heap region cross
check which did not work correctly.

@@ -61,10 +61,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);

@@ -77,11 +84,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 // INCLUDE_ALL_GCS
     case BarrierSet::CardTableModRef: