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

Side by Side Diff: test/cctest/test-utils.cc

Issue 6777007: Add thread-safety to creation of MemCopy and modulo functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add Release_Store to change. Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 83
84 void TestMemCopy(Vector<byte> src, 84 void TestMemCopy(Vector<byte> src,
85 Vector<byte> dst, 85 Vector<byte> dst,
86 int source_alignment, 86 int source_alignment,
87 int destination_alignment, 87 int destination_alignment,
88 int length_alignment) { 88 int length_alignment) {
89 memset(dst.start(), 0xFF, dst.length()); 89 memset(dst.start(), 0xFF, dst.length());
90 byte* to = dst.start() + 32 + destination_alignment; 90 byte* to = dst.start() + 32 + destination_alignment;
91 byte* from = src.start() + source_alignment; 91 byte* from = src.start() + source_alignment;
92 int length = kMinComplexMemCopy + length_alignment; 92 int length = OS::kMinComplexMemCopy + length_alignment;
93 MemCopy(to, from, static_cast<size_t>(length)); 93 OS::MemCopy(to, from, static_cast<size_t>(length));
94 printf("[%d,%d,%d]\n", 94 printf("[%d,%d,%d]\n",
95 source_alignment, destination_alignment, length_alignment); 95 source_alignment, destination_alignment, length_alignment);
96 for (int i = 0; i < length; i++) { 96 for (int i = 0; i < length; i++) {
97 CHECK_EQ(from[i], to[i]); 97 CHECK_EQ(from[i], to[i]);
98 } 98 }
99 CHECK_EQ(0xFF, to[-1]); 99 CHECK_EQ(0xFF, to[-1]);
100 CHECK_EQ(0xFF, to[length]); 100 CHECK_EQ(0xFF, to[length]);
101 } 101 }
102 102
103 103
104 104
105 TEST(MemCopy) { 105 TEST(MemCopy) {
106 OS::Setup(); 106 OS::Setup();
107 const int N = kMinComplexMemCopy + 128; 107 const int N = OS::kMinComplexMemCopy + 128;
108 Vector<byte> buffer1 = Vector<byte>::New(N); 108 Vector<byte> buffer1 = Vector<byte>::New(N);
109 Vector<byte> buffer2 = Vector<byte>::New(N); 109 Vector<byte> buffer2 = Vector<byte>::New(N);
110 110
111 for (int i = 0; i < N; i++) { 111 for (int i = 0; i < N; i++) {
112 buffer1[i] = static_cast<byte>(i & 0x7F); 112 buffer1[i] = static_cast<byte>(i & 0x7F);
113 } 113 }
114 114
115 // Same alignment. 115 // Same alignment.
116 for (int i = 0; i < 32; i++) { 116 for (int i = 0; i < 32; i++) {
117 TestMemCopy(buffer1, buffer2, i, i, i * 2); 117 TestMemCopy(buffer1, buffer2, i, i, i * 2);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 int offset = 0; 186 int offset = 0;
187 for (int loop = 0; loop < kLoops; loop++) { 187 for (int loop = 0; loop < kLoops; loop++) {
188 int seq_length = loop % kMaxSequenceSize; 188 int seq_length = loop % kMaxSequenceSize;
189 for (int j = 0; j < seq_length; j++) { 189 for (int j = 0; j < seq_length; j++) {
190 CHECK_EQ(j, result[offset]); 190 CHECK_EQ(j, result[offset]);
191 offset++; 191 offset++;
192 } 192 }
193 } 193 }
194 result.Dispose(); 194 result.Dispose();
195 } 195 }
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698