hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp
changeset 6464 cd40daf5b832
parent 6452 cc624b341ab2
child 6770 a67870aaedb3
--- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Mon Sep 13 23:24:30 2010 -0700
+++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Tue Sep 14 14:09:24 2010 -0700
@@ -1609,7 +1609,7 @@
     assert_clean_int(count, O3);     // Make sure 'count' is clean int.
 
     Label L_exit, L_skip_align1, L_skip_align2, L_fill_byte;
-    Label L_fill_2_bytes, L_fill_4_bytes, L_fill_32_bytes;
+    Label L_fill_2_bytes, L_fill_elements, L_fill_32_bytes;
 
     int shift = -1;
     switch (t) {
@@ -1635,8 +1635,8 @@
     }
     if (t == T_SHORT) {
       // Zero extend value
-      __ sethi(0xffff0000, O3);
-      __ andn(value, O3, value);
+      __ sllx(value, 48, value);
+      __ srlx(value, 48, value);
     }
     if (t == T_BYTE || t == T_SHORT) {
       __ sllx(value, 16, O3);
@@ -1644,8 +1644,8 @@
     }
 
     __ cmp(count, 2<<shift); // Short arrays (< 8 bytes) fill by element
-    __ brx(Assembler::lessUnsigned, false, Assembler::pn, L_fill_4_bytes); // use unsigned cmp
-    __ delayed()->andcc(count, 1<<shift, G0);
+    __ brx(Assembler::lessUnsigned, false, Assembler::pn, L_fill_elements); // use unsigned cmp
+    __ delayed()->andcc(count, 1, G0);
 
     if (!aligned && (t == T_BYTE || t == T_SHORT)) {
       // align source address at 4 bytes address boundary
@@ -1698,7 +1698,7 @@
     __ brx(Assembler::less, false, Assembler::pt, L_check_fill_8_bytes);
     __ delayed()->nop();
 
-    Label L_fill_32_bytes_loop;
+    Label L_fill_32_bytes_loop, L_fill_4_bytes;
     __ align(16);
     __ BIND(L_fill_32_bytes_loop);
 
@@ -1730,6 +1730,9 @@
 
     // fill trailing 4 bytes
     __ andcc(count, 1<<shift, G0);  // in delay slot of branches
+    if (t == T_INT) {
+      __ BIND(L_fill_elements);
+    }
     __ BIND(L_fill_4_bytes);
     __ brx(Assembler::zero, false, Assembler::pt, L_fill_2_bytes);
     if (t == T_BYTE || t == T_SHORT) {
@@ -1762,7 +1765,48 @@
     }
     __ BIND(L_exit);
     __ retl();
-    __ delayed()->mov(G0, O0); // return 0
+    __ delayed()->nop();
+
+    // Handle copies less than 8 bytes.  Int is handled elsewhere.
+    if (t == T_BYTE) {
+      __ BIND(L_fill_elements);
+      Label L_fill_2, L_fill_4;
+      // in delay slot __ andcc(count, 1, G0);
+      __ brx(Assembler::zero, false, Assembler::pt, L_fill_2);
+      __ delayed()->andcc(count, 2, G0);
+      __ stb(value, to, 0);
+      __ inc(to, 1);
+      __ BIND(L_fill_2);
+      __ brx(Assembler::zero, false, Assembler::pt, L_fill_4);
+      __ delayed()->andcc(count, 4, G0);
+      __ stb(value, to, 0);
+      __ stb(value, to, 1);
+      __ inc(to, 2);
+      __ BIND(L_fill_4);
+      __ brx(Assembler::zero, false, Assembler::pt, L_exit);
+      __ delayed()->nop();
+      __ stb(value, to, 0);
+      __ stb(value, to, 1);
+      __ stb(value, to, 2);
+      __ retl();
+      __ delayed()->stb(value, to, 3);
+    }
+
+    if (t == T_SHORT) {
+      Label L_fill_2;
+      __ BIND(L_fill_elements);
+      // in delay slot __ andcc(count, 1, G0);
+      __ brx(Assembler::zero, false, Assembler::pt, L_fill_2);
+      __ delayed()->andcc(count, 2, G0);
+      __ sth(value, to, 0);
+      __ inc(to, 2);
+      __ BIND(L_fill_2);
+      __ brx(Assembler::zero, false, Assembler::pt, L_exit);
+      __ delayed()->nop();
+      __ sth(value, to, 0);
+      __ retl();
+      __ delayed()->sth(value, to, 2);
+    }
     return start;
   }