8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects
authorrkennke
Mon, 23 Oct 2017 09:33:14 -0400
changeset 47683 f433d49aceb4
parent 47682 e4a89dfa1247
child 47685 1aecd400f2fa
8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects Reviewed-by: coleenp
src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
src/hotspot/cpu/x86/macroAssembler_x86.cpp
src/hotspot/cpu/x86/macroAssembler_x86.hpp
src/hotspot/cpu/x86/methodHandles_x86.cpp
src/hotspot/cpu/x86/templateTable_x86.cpp
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Mon Oct 23 10:45:07 2017 +0000
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Mon Oct 23 09:33:14 2017 -0400
@@ -2571,7 +2571,7 @@
     if (opr2->is_single_cpu()) {
       // cpu register - cpu register
       if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
-        __ cmpptr(reg1, opr2->as_register());
+        __ cmpoop(reg1, opr2->as_register());
       } else {
         assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?");
         __ cmpl(reg1, opr2->as_register());
@@ -2579,7 +2579,7 @@
     } else if (opr2->is_stack()) {
       // cpu register - stack
       if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
-        __ cmpptr(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
+        __ cmpoop(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
       } else {
         __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
       }
@@ -2594,12 +2594,7 @@
         if (o == NULL) {
           __ cmpptr(reg1, (int32_t)NULL_WORD);
         } else {
-#ifdef _LP64
-          __ movoop(rscratch1, o);
-          __ cmpptr(reg1, rscratch1);
-#else
-          __ cmpoop(reg1, c->as_jobject());
-#endif // _LP64
+          __ cmpoop(reg1, o);
         }
       } else {
         fatal("unexpected type: %s", basictype_to_str(c->type()));
@@ -2709,7 +2704,7 @@
 #ifdef _LP64
       // %%% Make this explode if addr isn't reachable until we figure out a
       // better strategy by giving noreg as the temp for as_Address
-      __ cmpptr(rscratch1, as_Address(addr, noreg));
+      __ cmpoop(rscratch1, as_Address(addr, noreg));
 #else
       __ cmpoop(as_Address(addr), c->as_jobject());
 #endif // _LP64
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Mon Oct 23 10:45:07 2017 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Mon Oct 23 09:33:14 2017 -0400
@@ -2783,6 +2783,21 @@
 #endif // _LP64
 }
 
+void MacroAssembler::cmpoop(Register src1, Register src2) {
+  cmpptr(src1, src2);
+}
+
+void MacroAssembler::cmpoop(Register src1, Address src2) {
+  cmpptr(src1, src2);
+}
+
+#ifdef _LP64
+void MacroAssembler::cmpoop(Register src1, jobject src2) {
+  movoop(rscratch1, src2);
+  cmpptr(src1, rscratch1);
+}
+#endif
+
 void MacroAssembler::locked_cmpxchgptr(Register reg, AddressLiteral adr) {
   if (reachable(adr)) {
     if (os::is_MP())
@@ -8399,7 +8414,7 @@
 
   if (is_array_equ) {
     // Check the input args
-    cmpptr(ary1, ary2);
+    cmpoop(ary1, ary2);
     jcc(Assembler::equal, TRUE_LABEL);
 
     // Need additional checks for arrays_equals.
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Mon Oct 23 10:45:07 2017 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Mon Oct 23 09:33:14 2017 -0400
@@ -750,8 +750,11 @@
   void cmpklass(Address dst, Metadata* obj);
   void cmpklass(Register dst, Metadata* obj);
   void cmpoop(Address dst, jobject obj);
+#endif // _LP64
+
+  void cmpoop(Register src1, Register src2);
+  void cmpoop(Register src1, Address src2);
   void cmpoop(Register dst, jobject obj);
-#endif // _LP64
 
   // NOTE src2 must be the lval. This is NOT an mem-mem compare
   void cmpptr(Address src1, AddressLiteral src2);
--- a/src/hotspot/cpu/x86/methodHandles_x86.cpp	Mon Oct 23 10:45:07 2017 +0000
+++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp	Mon Oct 23 09:33:14 2017 -0400
@@ -182,7 +182,7 @@
                         sizeof(u2), /*is_signed*/ false);
     // assert(sizeof(u2) == sizeof(Method::_size_of_parameters), "");
     Label L;
-    __ cmpptr(recv, __ argument_address(temp2, -1));
+    __ cmpoop(recv, __ argument_address(temp2, -1));
     __ jcc(Assembler::equal, L);
     __ movptr(rax, __ argument_address(temp2, -1));
     __ STOP("receiver not on stack");
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Mon Oct 23 10:45:07 2017 +0000
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Mon Oct 23 09:33:14 2017 -0400
@@ -2315,7 +2315,7 @@
   // assume branch is more often taken than not (loops use backward branches)
   Label not_taken;
   __ pop_ptr(rdx);
-  __ cmpptr(rdx, rax);
+  __ cmpoop(rdx, rax);
   __ jcc(j_not(cc), not_taken);
   branch(false, false);
   __ bind(not_taken);