Use internal memcpy when initializing code objects.

R=jkummerow@chromium.org
BUG=chromium:196330

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14011 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2013-03-20 16:53:31 +00:00
parent ff3e79807e
commit 5d5ca10d24
2 changed files with 29 additions and 5 deletions

View File

@ -8817,15 +8817,15 @@ void Code::CopyFrom(const CodeDesc& desc) {
CHECK(relocation_info()->IsByteArray());
CHECK(reinterpret_cast<intptr_t>(instruction_start()) ==
reinterpret_cast<intptr_t>(this) + Code::kHeaderSize - kHeapObjectTag);
memmove(instruction_start(), desc.buffer, desc.instr_size);
CopyBytes<byte>(instruction_start(), desc.buffer, desc.instr_size);
// copy reloc info
// TODO(mstarzinger): Remove once we found the bug.
CHECK(IsCode());
CHECK(relocation_info()->IsByteArray());
memmove(relocation_start(),
desc.buffer + desc.buffer_size - desc.reloc_size,
desc.reloc_size);
CopyBytes<byte>(relocation_start(),
desc.buffer + desc.buffer_size - desc.reloc_size,
desc.reloc_size);
// unbox handles and relocate
intptr_t delta = instruction_start() - desc.buffer;

View File

@ -122,7 +122,7 @@ inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms,
// Memory
// Copies data from |src| to |dst|. The data spans MUST not overlap.
// Copies data from |src| to |dst|. The data spans must not overlap.
template <typename T>
inline void CopyWords(T* dst, T* src, int num_words) {
STATIC_ASSERT(sizeof(T) == kPointerSize);
@ -145,6 +145,30 @@ inline void CopyWords(T* dst, T* src, int num_words) {
}
// Copies data from |src| to |dst|. The data spans must not overlap.
template <typename T>
inline void CopyBytes(T* dst, T* src, int num_bytes) {
STATIC_ASSERT(sizeof(T) == 1);
ASSERT(Min(dst, src) + num_bytes <= Max(dst, src));
ASSERT(num_bytes >= 0);
if (num_bytes == 0) return;
// Use block copying memcpy if the segment we're copying is
// enough to justify the extra call/setup overhead.
static const int kBlockCopyLimit = OS::kMinComplexMemCopy;
if (num_bytes >= kBlockCopyLimit) {
OS::MemCopy(dst, src, num_bytes);
} else {
int remaining = num_bytes;
do {
remaining--;
*dst++ = *src++;
} while (remaining > 0);
}
}
template <typename T, typename U>
inline void MemsetPointer(T** dest, U* value, int counter) {
#ifdef DEBUG