8217747: ZGC: Minor optimization of ZLoadBarrierStubC1
authorpliden
Tue, 29 Jan 2019 10:23:38 +0100
changeset 53538 cbefe308b543
parent 53537 b5c92b95fe45
child 53539 4ffdb0093c89
8217747: ZGC: Minor optimization of ZLoadBarrierStubC1 Reviewed-by: neliasso, eosterlund
src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp
--- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp	Tue Jan 29 10:23:38 2019 +0100
+++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp	Tue Jan 29 10:23:38 2019 +0100
@@ -278,11 +278,12 @@
 
   Register ref = stub->ref()->as_register();
   Register ref_addr = noreg;
+  Register tmp = noreg;
 
   if (stub->tmp()->is_valid()) {
     // Load address into tmp register
     ce->leal(stub->ref_addr(), stub->tmp());
-    ref_addr = stub->tmp()->as_pointer_register();
+    ref_addr = tmp = stub->tmp()->as_pointer_register();
   } else {
     // Address already in register
     ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register();
@@ -290,8 +291,8 @@
 
   assert_different_registers(ref, ref_addr, noreg);
 
-  // Save rax unless it is the result register
-  if (ref != rax) {
+  // Save rax unless it is the result or tmp register
+  if (ref != rax && tmp != rax) {
     __ push(rax);
   }
 
@@ -305,9 +306,13 @@
   // Verify result
   __ verify_oop(rax, "Bad oop");
 
-  // Restore rax unless it is the result register
+  // Move result into place
   if (ref != rax) {
     __ movptr(ref, rax);
+  }
+
+  // Restore rax unless it is the result or tmp register
+  if (ref != rax && tmp != rax) {
     __ pop(rax);
   }