Commit 38e19810 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Remove unused function MoveBytes().

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/24584004

Patch from Bangfu Tao <bangfu.tao@samsung.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17411 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7856f372
......@@ -194,61 +194,6 @@ inline void CopyBytes(T* dst, const T* src, size_t num_bytes) {
}
// Copies data from |src| to |dst|. No restrictions.
template <typename T>
inline void MoveBytes(T* dst, const T* src, size_t num_bytes) {
STATIC_ASSERT(sizeof(T) == 1);
switch (num_bytes) {
case 0: return;
case 1:
*dst = *src;
return;
#ifdef V8_HOST_CAN_READ_UNALIGNED
case 2:
*reinterpret_cast<uint16_t*>(dst) = *reinterpret_cast<const uint16_t*>(src);
return;
case 3: {
uint16_t part1 = *reinterpret_cast<const uint16_t*>(src);
byte part2 = *(src + 2);
*reinterpret_cast<uint16_t*>(dst) = part1;
*(dst + 2) = part2;
return;
}
case 4:
*reinterpret_cast<uint32_t*>(dst) = *reinterpret_cast<const uint32_t*>(src);
return;
case 5:
case 6:
case 7:
case 8: {
uint32_t part1 = *reinterpret_cast<const uint32_t*>(src);
uint32_t part2 = *reinterpret_cast<const uint32_t*>(src + num_bytes - 4);
*reinterpret_cast<uint32_t*>(dst) = part1;
*reinterpret_cast<uint32_t*>(dst + num_bytes - 4) = part2;
return;
}
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16: {
double part1 = *reinterpret_cast<const double*>(src);
double part2 = *reinterpret_cast<const double*>(src + num_bytes - 8);
*reinterpret_cast<double*>(dst) = part1;
*reinterpret_cast<double*>(dst + num_bytes - 8) = part2;
return;
}
#endif
default:
OS::MemMove(dst, src, num_bytes);
return;
}
}
template <typename T, typename U>
inline void MemsetPointer(T** dest, U* value, int counter) {
#ifdef DEBUG
......
......@@ -103,35 +103,22 @@ static const int kAreaSize = 512;
void TestMemMove(byte* area1,
byte* area2,
byte* area3,
int src_offset,
int dest_offset,
int length) {
for (int i = 0; i < kAreaSize; i++) {
area1[i] = i & 0xFF;
area2[i] = i & 0xFF;
area3[i] = i & 0xFF;
}
OS::MemMove(area1 + dest_offset, area1 + src_offset, length);
MoveBytes(area2 + dest_offset, area2 + src_offset, length);
memmove(area3 + dest_offset, area3 + src_offset, length);
if (memcmp(area1, area3, kAreaSize) != 0) {
memmove(area2 + dest_offset, area2 + src_offset, length);
if (memcmp(area1, area2, kAreaSize) != 0) {
printf("OS::MemMove(): src_offset: %d, dest_offset: %d, length: %d\n",
src_offset, dest_offset, length);
for (int i = 0; i < kAreaSize; i++) {
if (area1[i] == area3[i]) continue;
if (area1[i] == area2[i]) continue;
printf("diff at offset %d (%p): is %d, should be %d\n",
i, reinterpret_cast<void*>(area1 + i), area1[i], area3[i]);
}
CHECK(false);
}
if (memcmp(area2, area3, kAreaSize) != 0) {
printf("MoveBytes(): src_offset: %d, dest_offset: %d, length: %d\n",
src_offset, dest_offset, length);
for (int i = 0; i < kAreaSize; i++) {
if (area2[i] == area3[i]) continue;
printf("diff at offset %d (%p): is %d, should be %d\n",
i, reinterpret_cast<void*>(area2 + i), area2[i], area3[i]);
i, reinterpret_cast<void*>(area1 + i), area1[i], area2[i]);
}
CHECK(false);
}
......@@ -142,7 +129,6 @@ TEST(MemMove) {
v8::V8::Initialize();
byte* area1 = new byte[kAreaSize];
byte* area2 = new byte[kAreaSize];
byte* area3 = new byte[kAreaSize];
static const int kMinOffset = 32;
static const int kMaxOffset = 64;
......@@ -152,13 +138,12 @@ TEST(MemMove) {
for (int src_offset = kMinOffset; src_offset <= kMaxOffset; src_offset++) {
for (int dst_offset = kMinOffset; dst_offset <= kMaxOffset; dst_offset++) {
for (int length = 0; length <= kMaxLength; length++) {
TestMemMove(area1, area2, area3, src_offset, dst_offset, length);
TestMemMove(area1, area2, src_offset, dst_offset, length);
}
}
}
delete[] area1;
delete[] area2;
delete[] area3;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment