Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: base/memory/aligned_memory_unittest.cc

Issue 2740753002: Enable alignment unittests on iOS arm device builds. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/aligned_memory.h" 5 #include "base/memory/aligned_memory.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 26 matching lines...) Expand all
37 AlignedMemory<8, 8> raw8; 37 AlignedMemory<8, 8> raw8;
38 AlignedMemory<8, 16> raw16; 38 AlignedMemory<8, 16> raw16;
39 AlignedMemory<8, 128> raw128; 39 AlignedMemory<8, 128> raw128;
40 40
41 EXPECT_EQ(8u, ALIGNOF(raw8)); 41 EXPECT_EQ(8u, ALIGNOF(raw8));
42 EXPECT_EQ(16u, ALIGNOF(raw16)); 42 EXPECT_EQ(16u, ALIGNOF(raw16));
43 EXPECT_EQ(128u, ALIGNOF(raw128)); 43 EXPECT_EQ(128u, ALIGNOF(raw128));
44 44
45 EXPECT_ALIGNED(raw8.void_data(), 8); 45 EXPECT_ALIGNED(raw8.void_data(), 8);
46 EXPECT_ALIGNED(raw16.void_data(), 16); 46 EXPECT_ALIGNED(raw16.void_data(), 16);
47
48 // TODO(ios): __attribute__((aligned(X))) with X >= 128 does not works on
49 // the stack when building for arm64 on iOS, http://crbug.com/349003
50 #if !(defined(OS_IOS) && defined(ARCH_CPU_ARM64))
51 EXPECT_ALIGNED(raw128.void_data(), 128); 47 EXPECT_ALIGNED(raw128.void_data(), 128);
52 48
53 // NaCl x86-64 compiler emits non-validating instructions for >128 49 // NaCl x86-64 compiler emits non-validating instructions for >128
54 // bytes alignment. 50 // bytes alignment.
55 // http://www.chromium.org/nativeclient/design-documents/nacl-sfi-model-on-x86 -64-systems 51 // http://www.chromium.org/nativeclient/design-documents/nacl-sfi-model-on-x86 -64-systems
56 // TODO(hamaji): Ideally, NaCl compiler for x86-64 should workaround 52 // TODO(hamaji): Ideally, NaCl compiler for x86-64 should workaround
57 // this limitation and this #if should be removed. 53 // this limitation and this #if should be removed.
58 // https://code.google.com/p/nativeclient/issues/detail?id=3463 54 // https://code.google.com/p/nativeclient/issues/detail?id=3463
59 #if !(defined(OS_NACL) && defined(ARCH_CPU_X86_64)) 55 #if !(defined(OS_NACL) && defined(ARCH_CPU_X86_64))
60 AlignedMemory<8, 256> raw256; 56 AlignedMemory<8, 256> raw256;
61 EXPECT_EQ(256u, ALIGNOF(raw256)); 57 EXPECT_EQ(256u, ALIGNOF(raw256));
62 EXPECT_ALIGNED(raw256.void_data(), 256); 58 EXPECT_ALIGNED(raw256.void_data(), 256);
63 59
64 // TODO(ios): This test hits an armv7 bug in clang. crbug.com/138066
65 #if !(defined(OS_IOS) && defined(ARCH_CPU_ARM_FAMILY))
66 AlignedMemory<8, 4096> raw4096; 60 AlignedMemory<8, 4096> raw4096;
67 EXPECT_EQ(4096u, ALIGNOF(raw4096)); 61 EXPECT_EQ(4096u, ALIGNOF(raw4096));
68 EXPECT_ALIGNED(raw4096.void_data(), 4096); 62 EXPECT_ALIGNED(raw4096.void_data(), 4096);
69 #endif // !(defined(OS_IOS) && defined(ARCH_CPU_ARM_FAMILY))
70 #endif // !(defined(OS_NACL) && defined(ARCH_CPU_X86_64)) 63 #endif // !(defined(OS_NACL) && defined(ARCH_CPU_X86_64))
71 #endif // !(defined(OS_IOS) && defined(ARCH_CPU_ARM64))
72 } 64 }
73 65
74 TEST(AlignedMemoryTest, DynamicAllocation) { 66 TEST(AlignedMemoryTest, DynamicAllocation) {
75 void* p = base::AlignedAlloc(8, 8); 67 void* p = base::AlignedAlloc(8, 8);
76 EXPECT_TRUE(p); 68 EXPECT_TRUE(p);
77 EXPECT_ALIGNED(p, 8); 69 EXPECT_ALIGNED(p, 8);
78 base::AlignedFree(p); 70 base::AlignedFree(p);
79 71
80 p = base::AlignedAlloc(8, 16); 72 p = base::AlignedAlloc(8, 16);
81 EXPECT_TRUE(p); 73 EXPECT_TRUE(p);
(...skipping 12 matching lines...) Expand all
94 } 86 }
95 87
96 TEST(AlignedMemoryTest, ScopedDynamicAllocation) { 88 TEST(AlignedMemoryTest, ScopedDynamicAllocation) {
97 std::unique_ptr<float, base::AlignedFreeDeleter> p( 89 std::unique_ptr<float, base::AlignedFreeDeleter> p(
98 static_cast<float*>(base::AlignedAlloc(8, 8))); 90 static_cast<float*>(base::AlignedAlloc(8, 8)));
99 EXPECT_TRUE(p.get()); 91 EXPECT_TRUE(p.get());
100 EXPECT_ALIGNED(p.get(), 8); 92 EXPECT_ALIGNED(p.get(), 8);
101 } 93 }
102 94
103 } // namespace 95 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698