Commit cd826b5c authored by antonm@chromium.org's avatar antonm@chromium.org

Refactor word copying logic.

Review URL: http://codereview.chromium.org/1530005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4310 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9e76d99f
......@@ -268,9 +268,9 @@ static void CopyElements(AssertNoAllocation* no_gc,
int src_index,
int len) {
ASSERT(dst != src); // Use MoveElements instead.
memcpy(dst->data_start() + dst_index,
src->data_start() + src_index,
len * kPointerSize);
CopyWords(dst->data_start() + dst_index,
src->data_start() + src_index,
len);
WriteBarrierMode mode = dst->GetWriteBarrierMode(*no_gc);
if (mode == UPDATE_WRITE_BARRIER) {
Heap::RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len);
......
......@@ -236,20 +236,7 @@ AllocationSpace Heap::TargetSpaceId(InstanceType type) {
void Heap::CopyBlock(Object** dst, Object** src, int byte_size) {
ASSERT(IsAligned(byte_size, kPointerSize));
// Use block copying memcpy if the segment we're copying is
// enough to justify the extra call/setup overhead.
static const int kBlockCopyLimit = 16 * kPointerSize;
if (byte_size >= kBlockCopyLimit) {
memcpy(dst, src, byte_size);
} else {
int remaining = byte_size / kPointerSize;
do {
remaining--;
*dst++ = *src++;
} while (remaining > 0);
}
CopyWords(dst, src, byte_size / kPointerSize);
}
......
......@@ -597,6 +597,25 @@ static inline void MemsetPointer(T** dest, T* value, int counter) {
}
// Copies data from |src| to |dst|. The data spans MUST not overlap.
inline void CopyWords(Object** dst, Object** src, int num_words) {
ASSERT(Min(dst, src) + num_words <= Max(dst, src));
// Use block copying memcpy if the segment we're copying is
// enough to justify the extra call/setup overhead.
static const int kBlockCopyLimit = 16;
if (num_words >= kBlockCopyLimit) {
memcpy(dst, src, num_words * kPointerSize);
} else {
int remaining = num_words;
do {
remaining--;
*dst++ = *src++;
} while (remaining > 0);
}
}
// Calculate 10^exponent.
int TenToThe(int exponent);
......
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