MIPS32r2: Fix Chromium runtime crash

Crash is caused by ldxc1 instruction, which traps when double values are
not aligned on 8-byte boundaries. Problem was tracked to SkChunkAlloc which
produces pointers aligned on 4-byte boundaries leading to misalignment.

This change makes sure that SkChunkAlloc will produce pointers that are
aligned to 8 bytes.

Appropriate tests are added to tests/MemsetTest.cpp

TEST=Build Chromium with Clang and run on MIPS32r2 platform
TEST=./out/Debug/dm --match Memset
BUG=130022
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1849183004

Review-Url: https://codereview.chromium.org/1849183004
diff --git a/tests/MemsetTest.cpp b/tests/MemsetTest.cpp
index e1f844e..fb5a337 100644
--- a/tests/MemsetTest.cpp
+++ b/tests/MemsetTest.cpp
@@ -6,6 +6,7 @@
  */
 
 #include "SkChunkAlloc.h"
+#include "SkRandom.h"
 #include "SkUtils.h"
 #include "Test.h"
 
@@ -23,6 +24,14 @@
     return ptr;
 }
 
+static void check_alloc_alignment(skiatest::Reporter* reporter,
+                                  SkChunkAlloc* alloc, size_t size) {
+    const size_t kAlignment = 8;
+    void* ptr = alloc->allocThrow(size);
+    REPORTER_ASSERT(reporter, ptr != nullptr);
+    REPORTER_ASSERT(reporter, (size_t)ptr % kAlignment == 0);
+}
+
 static void test_chunkalloc(skiatest::Reporter* reporter) {
     static const size_t kMin = 1024;
     SkChunkAlloc alloc(kMin);
@@ -76,6 +85,14 @@
     REPORTER_ASSERT(reporter, freed == kMin);
     check_alloc(reporter, alloc, 2*kMin, size, 2);
     REPORTER_ASSERT(reporter, !alloc.contains(ptr));
+
+    //------------------------------------------------------------------------
+    // test the alignment
+    alloc.reset();
+    SkRandom rand;
+    for (int i = 0; i < 1000; i++) {
+        check_alloc_alignment(reporter, &alloc, rand.nextU16());
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////