From a23868fb44e3c2a378c36288807b920b4cf1cfbf Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Tue, 2 Apr 2013 13:29:26 +0000 Subject: [PATCH] Fix CopyBytes to accept size_t for num_bytes BUG= Review URL: https://codereview.chromium.org/13470008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14114 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/deoptimizer.cc | 3 ++- src/heap.cc | 4 ++-- src/objects.cc | 5 +++-- src/v8utils.h | 7 +++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index ef0d9e5..601faf7 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -2183,7 +2183,8 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, ASSERT(static_cast(Deoptimizer::GetMaxDeoptTableSize()) >= desc.instr_size); chunk->CommitArea(desc.instr_size); - CopyBytes(chunk->area_start(), desc.buffer, desc.instr_size); + CopyBytes(chunk->area_start(), desc.buffer, + static_cast(desc.instr_size)); CPU::FlushICache(chunk->area_start(), desc.instr_size); if (type == EAGER) { diff --git a/src/heap.cc b/src/heap.cc index 984f58d..fafcb64 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -3884,7 +3884,7 @@ MaybeObject* Heap::CopyCode(Code* code, Vector reloc_info) { Address new_addr = reinterpret_cast(result)->address(); // Copy header and instructions. - CopyBytes(new_addr, old_addr, static_cast(relocation_offset)); + CopyBytes(new_addr, old_addr, relocation_offset); Code* new_code = Code::cast(result); new_code->set_relocation_info(ByteArray::cast(reloc_info_array)); @@ -3892,7 +3892,7 @@ MaybeObject* Heap::CopyCode(Code* code, Vector reloc_info) { // Copy patched rinfo. CopyBytes(new_code->relocation_start(), reloc_info.start(), - reloc_info.length()); + static_cast(reloc_info.length())); // Relocate the copy. ASSERT(!isolate_->code_range()->exists() || diff --git a/src/objects.cc b/src/objects.cc index 332e9f7..a3163eb 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -8849,12 +8849,13 @@ void Code::CopyFrom(const CodeDesc& desc) { ASSERT(Marking::Color(this) == Marking::WHITE_OBJECT); // copy code - CopyBytes(instruction_start(), desc.buffer, desc.instr_size); + CopyBytes(instruction_start(), desc.buffer, + static_cast(desc.instr_size)); // copy reloc info CopyBytes(relocation_start(), desc.buffer + desc.buffer_size - desc.reloc_size, - desc.reloc_size); + static_cast(desc.reloc_size)); // unbox handles and relocate intptr_t delta = instruction_start() - desc.buffer; diff --git a/src/v8utils.h b/src/v8utils.h index 606d8e7..b5c8f08 100644 --- a/src/v8utils.h +++ b/src/v8utils.h @@ -151,20 +151,19 @@ inline void CopyWords(T* dst, T* src, int num_words) { // Copies data from |src| to |dst|. The data spans must not overlap. template -inline void CopyBytes(T* dst, T* src, int num_bytes) { +inline void CopyBytes(T* dst, T* src, size_t 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 OS::MemCopy 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) { + if (num_bytes >= static_cast(kBlockCopyLimit)) { OS::MemCopy(dst, src, num_bytes); } else { - int remaining = num_bytes; + size_t remaining = num_bytes; do { remaining--; *dst++ = *src++; -- 2.7.4