Commit 15c9b853 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[cleanup] De-templatize CopyWords, drop MoveWords

CopyWords, as the name implies, copies raw words anyway, so there
is no need for type specialization.
MoveWords was dead code.

Bug: v8:8238
Change-Id: Ib497cfbabdcf8bac672ac74ef69f679b50ddfd6e
Reviewed-on: https://chromium-review.googlesource.com/c/1316609Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57226}
parent ad8169a0
......@@ -293,8 +293,7 @@ static void CopyDoubleToDoubleElements(FixedArrayBase* from_base,
to_address += kDoubleSize * to_start;
from_address += kDoubleSize * from_start;
int words_per_double = (kDoubleSize / kPointerSize);
CopyWords(reinterpret_cast<Address*>(to_address),
reinterpret_cast<Address*>(from_address),
CopyWords(to_address, from_address,
static_cast<size_t>(words_per_double * copy_size));
}
......
......@@ -503,8 +503,7 @@ bool Heap::ShouldBePromoted(Address old_address) {
}
void Heap::CopyBlock(Address dst, Address src, int byte_size) {
CopyWords(reinterpret_cast<Object**>(dst), reinterpret_cast<Object**>(src),
static_cast<size_t>(byte_size / kPointerSize));
CopyWords(dst, src, static_cast<size_t>(byte_size / kPointerSize));
}
template <Heap::FindMementoMode mode>
......
......@@ -1114,51 +1114,29 @@ int WriteAsCFile(const char* filename, const char* varname,
// Memory
// Copies words from |src| to |dst|. The data spans must not overlap.
template <typename T>
inline void CopyWords(T* dst, const T* src, size_t num_words) {
STATIC_ASSERT(sizeof(T) == kPointerSize);
DCHECK(Min(dst, const_cast<T*>(src)) + num_words <=
Max(dst, const_cast<T*>(src)));
// |src| and |dst| must be kPointerSize-aligned.
inline void CopyWords(Address dst, const Address src, size_t num_words) {
DCHECK(IsAligned(dst, kPointerSize));
DCHECK(IsAligned(src, kPointerSize));
DCHECK(Min(dst, src) + num_words * kPointerSize <= Max(dst, src));
DCHECK_GT(num_words, 0);
// Use block copying MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead.
static const size_t kBlockCopyLimit = 16;
Address* dst_ptr = reinterpret_cast<Address*>(dst);
Address* src_ptr = reinterpret_cast<Address*>(src);
if (num_words < kBlockCopyLimit) {
do {
num_words--;
*dst++ = *src++;
} while (num_words > 0);
} else {
MemCopy(dst, src, num_words * kPointerSize);
}
}
// Copies words from |src| to |dst|. No restrictions.
template <typename T>
inline void MoveWords(T* dst, const T* src, size_t num_words) {
STATIC_ASSERT(sizeof(T) == kPointerSize);
DCHECK_GT(num_words, 0);
// Use block copying MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead.
static const size_t kBlockCopyLimit = 16;
if (num_words < kBlockCopyLimit &&
((dst < src) || (dst >= (src + num_words * kPointerSize)))) {
T* end = dst + num_words;
do {
num_words--;
*dst++ = *src++;
*dst_ptr++ = *src_ptr++;
} while (num_words > 0);
} else {
MemMove(dst, src, num_words * kPointerSize);
MemCopy(dst_ptr, src_ptr, num_words * kPointerSize);
}
}
// Copies data from |src| to |dst|. The data spans must not overlap.
template <typename T>
inline void CopyBytes(T* dst, const T* src, size_t num_bytes) {
......
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