Use internal memcpy for CopyWords and when copying code.

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

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14020 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5fcc52fc
...@@ -2130,7 +2130,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, ...@@ -2130,7 +2130,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
ASSERT(static_cast<int>(Deoptimizer::GetMaxDeoptTableSize()) >= ASSERT(static_cast<int>(Deoptimizer::GetMaxDeoptTableSize()) >=
desc.instr_size); desc.instr_size);
chunk->CommitArea(desc.instr_size); chunk->CommitArea(desc.instr_size);
memcpy(chunk->area_start(), desc.buffer, desc.instr_size); CopyBytes(chunk->area_start(), desc.buffer, desc.instr_size);
CPU::FlushICache(chunk->area_start(), desc.instr_size); CPU::FlushICache(chunk->area_start(), desc.instr_size);
if (type == EAGER) { if (type == EAGER) {
......
...@@ -3888,13 +3888,15 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) { ...@@ -3888,13 +3888,15 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
// Copy header and instructions. // Copy header and instructions.
memcpy(new_addr, old_addr, relocation_offset); CopyBytes(new_addr, old_addr, relocation_offset);
Code* new_code = Code::cast(result); Code* new_code = Code::cast(result);
new_code->set_relocation_info(ByteArray::cast(reloc_info_array)); new_code->set_relocation_info(ByteArray::cast(reloc_info_array));
// Copy patched rinfo. // Copy patched rinfo.
memcpy(new_code->relocation_start(), reloc_info.start(), reloc_info.length()); CopyBytes(new_code->relocation_start(),
reloc_info.start(),
reloc_info.length());
// Relocate the copy. // Relocate the copy.
ASSERT(!isolate_->code_range()->exists() || ASSERT(!isolate_->code_range()->exists() ||
......
...@@ -111,6 +111,7 @@ int WriteAsCFile(const char* filename, const char* varname, ...@@ -111,6 +111,7 @@ int WriteAsCFile(const char* filename, const char* varname,
const char* str, int size, bool verbose = true); const char* str, int size, bool verbose = true);
// ----------------------------------------------------------------------------
// Data structures // Data structures
template <typename T> template <typename T>
...@@ -120,6 +121,8 @@ inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms, ...@@ -120,6 +121,8 @@ inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms,
reinterpret_cast<v8::internal::Handle<Object>*>(elms), length); reinterpret_cast<v8::internal::Handle<Object>*>(elms), length);
} }
// ----------------------------------------------------------------------------
// Memory // 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.
...@@ -129,12 +132,13 @@ inline void CopyWords(T* dst, T* src, int num_words) { ...@@ -129,12 +132,13 @@ inline void CopyWords(T* dst, T* src, int num_words) {
ASSERT(Min(dst, src) + num_words <= Max(dst, src)); ASSERT(Min(dst, src) + num_words <= Max(dst, src));
ASSERT(num_words > 0); ASSERT(num_words > 0);
// Use block copying memcpy if the segment we're copying is // Use block copying OS::MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead. // enough to justify the extra call/setup overhead.
static const int kBlockCopyLimit = 16; static const int kBlockCopyLimit = 16;
STATIC_ASSERT(kBlockCopyLimit * kPointerSize >= OS::kMinComplexMemCopy);
if (num_words >= kBlockCopyLimit) { if (num_words >= kBlockCopyLimit) {
memcpy(dst, src, num_words * kPointerSize); OS::MemCopy(dst, src, num_words * kPointerSize);
} else { } else {
int remaining = num_words; int remaining = num_words;
do { do {
...@@ -153,7 +157,7 @@ inline void CopyBytes(T* dst, T* src, int num_bytes) { ...@@ -153,7 +157,7 @@ inline void CopyBytes(T* dst, T* src, int num_bytes) {
ASSERT(num_bytes >= 0); ASSERT(num_bytes >= 0);
if (num_bytes == 0) return; if (num_bytes == 0) return;
// Use block copying memcpy if the segment we're copying is // Use block copying OS::MemCopy if the segment we're copying is
// enough to justify the extra call/setup overhead. // enough to justify the extra call/setup overhead.
static const int kBlockCopyLimit = OS::kMinComplexMemCopy; static const int kBlockCopyLimit = OS::kMinComplexMemCopy;
......
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