changeset 32:ab0d284dc313

Fix the bug when the C1 compiler dealing with CAS. In C1 compiler, the CAS operations(cas_int, cas_long and cas_obj) use AT as the result register. However, the CAS operation does not define the result operand.
author LIN Chuanwen <linchuanwen@loongson.cn>
date Thu, 18 Nov 2010 16:19:42 +0800
parents 202786aed583
children 9fdc8715b0a2
files hotspot/src/cpu/mips/vm/c1_LIRGenerator_mips.cpp hotspot/src/share/vm/c1/c1_LIR.cpp hotspot/src/share/vm/c1/c1_LIR.hpp
diffstat 3 files changed, 58 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/cpu/mips/vm/c1_LIRGenerator_mips.cpp	Wed Nov 17 17:52:29 2010 +0800
+++ b/hotspot/src/cpu/mips/vm/c1_LIRGenerator_mips.cpp	Thu Nov 18 16:19:42 2010 +0800
@@ -707,7 +707,7 @@
 	__ add(addr, LIR_OprFact::intConst(value_offset), addr);
 	LIR_Opr t1 = LIR_OprFact::illegalOpr;  // no temp needed
 	LIR_Opr t2 = LIR_OprFact::illegalOpr;  // no temp needed
-	__ cas_long(addr, cmp_value.result(), new_value.result(), t1, t2);
+	__ cas_long(addr, cmp_value.result(), new_value.result(), t1, t2, FrameMap::_at_opr);
 
 	// generate conditional move of boolean result
 	LIR_Opr result = rlock_result(x);
@@ -749,17 +749,17 @@
 	} else {
 		ShouldNotReachHere();
 	}
-	LIR_Opr addr = new_register(T_OBJECT);
+	LIR_Opr addr = new_pointer_register();
 	__ move(obj.result(), addr);
 	__ add(addr, offset.result(), addr);
 
 	LIR_Opr ill = LIR_OprFact::illegalOpr;  // for convenience
 	if (type == objectType) 
-		__ cas_obj(addr, cmp.result(), val.result(), ill, ill);
+		__ cas_obj(addr, cmp.result(), val.result(), ill, ill, FrameMap::_at_opr);
 	else if (type == intType)
-		__ cas_int(addr, cmp.result(), val.result(), ill, ill);
+		__ cas_int(addr, cmp.result(), val.result(), ill, ill, FrameMap::_at_opr);
 	else if (type == longType)
-		__ cas_long(addr, cmp.result(), val.result(), ill, ill);
+		__ cas_long(addr, cmp.result(), val.result(), ill, ill, FrameMap::_at_opr);
 	else {
 		ShouldNotReachHere();
 	}
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp	Wed Nov 17 17:52:29 2010 +0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp	Thu Nov 18 16:19:42 2010 +0800
@@ -1507,7 +1507,7 @@
 			0));
 }
 
-
+#ifndef MIPS32
 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2) {
   // Compare and swap produces condition code "zero" if contents_of(addr) == cmp_value,
   // implying successful swap of new_value into addr
@@ -1540,7 +1540,43 @@
 			t1, 
 			t2));
 }
+#else
+void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
+  // Compare and swap produces condition code "zero" if contents_of(addr) == cmp_value,
+  // implying successful swap of new_value into addr
+  append(new LIR_OpCompareAndSwap(lir_cas_long, 
+			addr, 
+			cmp_value, 
+			new_value, 
+			t1, 
+			t2,
+			result));
+}
 
+void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
+  // Compare and swap produces condition code "zero" if contents_of(addr) == cmp_value,
+  // implying successful swap of new_value into addr
+  append(new LIR_OpCompareAndSwap(lir_cas_obj, 
+			addr, 
+			cmp_value, 
+			new_value, 
+			t1, 
+			t2,
+			result));
+}
+
+void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
+  // Compare and swap produces condition code "zero" if contents_of(addr) == cmp_value,
+  // implying successful swap of new_value into addr
+  append(new LIR_OpCompareAndSwap(lir_cas_int, 
+			addr, 
+			cmp_value, 
+			new_value, 
+			t1, 
+			t2,
+			result));
+}
+#endif
 
 #ifdef PRODUCT
 
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Nov 17 17:52:29 2010 +0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Thu Nov 18 16:19:42 2010 +0800
@@ -1868,6 +1868,7 @@
   LIR_Opr _tmp2;
 
  public:
+#ifndef MIPS32
   LIR_OpCompareAndSwap(LIR_Code code, LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2)
     : LIR_Op(code, LIR_OprFact::illegalOpr, NULL)  // no result, no info
     , _addr(addr)
@@ -1875,7 +1876,15 @@
     , _new_value(new_value)
     , _tmp1(t1)
     , _tmp2(t2)                                  { }
-
+#else
+  LIR_OpCompareAndSwap(LIR_Code code, LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result)
+    : LIR_Op(code, result, NULL)  // no result, no info
+    , _addr(addr)
+    , _cmp_value(cmp_value)
+    , _new_value(new_value)
+    , _tmp1(t1)
+    , _tmp2(t2)                                  { }
+#endif
   LIR_Opr addr()        const                    { return _addr;  }
   LIR_Opr cmp_value()   const                    { return _cmp_value; }
   LIR_Opr new_value()   const                    { return _new_value; }
@@ -2105,11 +2114,15 @@
   }
 
 #endif
-
+#ifndef MIPS32
   void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2);
   void cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2);
   void cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2);
-
+#else
+  void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result);
+  void cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result);
+  void cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, LIR_Opr t1, LIR_Opr t2, LIR_Opr result);
+#endif
   void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp)                { append(new LIR_Op2(lir_abs , from, tmp, to)); }
   void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp)                { append(new LIR_Op2(lir_sqrt, from, tmp, to)); }
   void log (LIR_Opr from, LIR_Opr to, LIR_Opr tmp)                { append(new LIR_Op2(lir_log,  from, tmp, to)); }