Reviewers: danno, Benedikt Meurer, Bangfu, Paul Lind, kisg, palfia,

Description:
MIPS: Fixed a bug in CopyBytes() and new test cases for MIPS macro assembler.

Port r16873 (c2880bc)

BUG=
TEST=cctest/test-macro-assembler-mips

Please review this at https://codereview.chromium.org/24266007/

SVN Base: https://github.com/v8/v8.git@gbl

Affected files (+17, -17 lines):
  M src/mips/macro-assembler-mips.cc
  M test/cctest/cctest.gyp
  A + test/cctest/test-macro-assembler-mips.cc


Index: src/mips/macro-assembler-mips.cc
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index 159c924b5bf044a442f23f0b1e8919581a076788..cbb538f39d34d8977c978fd08681f5dbce3b31a8 100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -3220,11 +3220,10 @@ void MacroAssembler::CopyBytes(Register src,
                                Register dst,
                                Register length,
                                Register scratch) {
-  Label align_loop, align_loop_1, word_loop, byte_loop, byte_loop_1, done;
+  Label align_loop_1, word_loop, byte_loop, byte_loop_1, done;

   // Align src before copying in word size chunks.
-  bind(&align_loop);
-  Branch(&done, eq, length, Operand(zero_reg));
+  Branch(&byte_loop, le, length, Operand(kPointerSize));
   bind(&align_loop_1);
   And(scratch, src, kPointerSize - 1);
   Branch(&word_loop, eq, scratch, Operand(zero_reg));
@@ -3233,7 +3232,7 @@ void MacroAssembler::CopyBytes(Register src,
   sb(scratch, MemOperand(dst));
   Addu(dst, dst, 1);
   Subu(length, length, Operand(1));
-  Branch(&byte_loop_1, ne, length, Operand(zero_reg));
+  Branch(&align_loop_1, ne, length, Operand(zero_reg));

   // Copy bytes in word size chunks.
   bind(&word_loop);
Index: test/cctest/cctest.gyp
diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp
index 8c6bf95d0e285d187ba0ce898f085850d41a835b..c8f6e57ae2194209ee088bc7c050f20e2513b7a8 100644
--- a/test/cctest/cctest.gyp
+++ b/test/cctest/cctest.gyp
@@ -147,6 +147,7 @@
           'sources': [
             'test-assembler-mips.cc',
             'test-disasm-mips.cc',
+            'test-macro-assembler-mips.cc'
           ],
         }],
         [ 'OS=="linux"', {
Index: test/cctest/test-macro-assembler-mips.cc
diff --git a/test/cctest/test-macro-assembler-arm.cc b/test/cctest/test-macro-assembler-mips.cc
similarity index 90%
copy from test/cctest/test-macro-assembler-arm.cc
copy to test/cctest/test-macro-assembler-mips.cc
index 77f7abbd44356c7684e90c99cd12d77247a60cba..b7151dc85348f46c87050ce0eb92cf681811e1d0 100644
--- a/test/cctest/test-macro-assembler-arm.cc
+++ b/test/cctest/test-macro-assembler-mips.cc
@@ -29,8 +29,8 @@

 #include "v8.h"
 #include "macro-assembler.h"
-#include "arm/macro-assembler-arm.h"
-#include "arm/simulator-arm.h"
+#include "mips/macro-assembler-mips.h"
+#include "mips/simulator-mips.h"
 #include "cctest.h"


@@ -74,20 +74,20 @@ TEST(CopyBytes) {
   CHECK(act_size >= static_cast<size_t>(data_size));

   // Storage for R0 and R1.
-  byte* r0_;
-  byte* r1_;
+  byte* a0_;
+  byte* a1_;

   MacroAssembler assembler(isolate, NULL, 0);
   MacroAssembler* masm = &assembler;

// Code to be generated: The stuff in CopyBytes followed by a store of R0 and
   // R1, respectively.
-  __ CopyBytes(r0, r1, r2, r3);
-  __ mov(r2, Operand(reinterpret_cast<int>(&r0_)));
-  __ mov(r3, Operand(reinterpret_cast<int>(&r1_)));
-  __ str(r0, MemOperand(r2));
-  __ str(r1, MemOperand(r3));
-  __ bx(lr);
+  __ CopyBytes(a0, a1, a2, a3);
+  __ li(a2, Operand(reinterpret_cast<int>(&a0_)));
+  __ li(a3, Operand(reinterpret_cast<int>(&a1_)));
+  __ sw(a0, MemOperand(a2));
+  __ jr(ra);
+  __ sw(a1, MemOperand(a3));

   CodeDesc desc;
   masm->GetCode(&desc);
@@ -97,7 +97,7 @@ TEST(CopyBytes) {
       Handle<Code>())->ToObjectChecked();
   CHECK(code->IsCode());

-  F f = FUNCTION_CAST<F>(Code::cast(code)->entry());
+  ::F f = FUNCTION_CAST< ::F>(Code::cast(code)->entry());

   // Initialise source data with non-zero bytes.
   for (int i = 0; i < data_size; i++) {
@@ -114,8 +114,8 @@ TEST(CopyBytes) {
         (void) CALL_GENERATED_CODE(f, reinterpret_cast<int>(src),
reinterpret_cast<int>(dest), size, 0, 0);
         // R0 and R1 should point at the first byte after the copied data.
-        CHECK_EQ(src + size, r0_);
-        CHECK_EQ(dest + size, r1_);
+        CHECK_EQ(src + size, a0_);
+        CHECK_EQ(dest + size, a1_);
         // Check that we haven't written outside the target area.
         CHECK(all_zeroes(dest_buffer, dest));
         CHECK(all_zeroes(dest + size, dest_buffer + data_size));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to