Fix CopyBytes to accept size_t for num_bytes
authordslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 2 Apr 2013 13:29:26 +0000 (13:29 +0000)
committerdslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 2 Apr 2013 13:29:26 +0000 (13:29 +0000)
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
src/heap.cc
src/objects.cc
src/v8utils.h

index ef0d9e5..601faf7 100644 (file)
@@ -2183,7 +2183,8 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
   ASSERT(static_cast<int>(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<size_t>(desc.instr_size));
   CPU::FlushICache(chunk->area_start(), desc.instr_size);
 
   if (type == EAGER) {
index 984f58d..fafcb64 100644 (file)
@@ -3884,7 +3884,7 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
   Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
 
   // Copy header and instructions.
-  CopyBytes(new_addr, old_addr, static_cast<int>(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<byte> reloc_info) {
   // Copy patched rinfo.
   CopyBytes(new_code->relocation_start(),
             reloc_info.start(),
-            reloc_info.length());
+            static_cast<size_t>(reloc_info.length()));
 
   // Relocate the copy.
   ASSERT(!isolate_->code_range()->exists() ||
index 332e9f7..a3163eb 100644 (file)
@@ -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<size_t>(desc.instr_size));
 
   // copy reloc info
   CopyBytes(relocation_start(),
             desc.buffer + desc.buffer_size - desc.reloc_size,
-            desc.reloc_size);
+            static_cast<size_t>(desc.reloc_size));
 
   // unbox handles and relocate
   intptr_t delta = instruction_start() - desc.buffer;
index 606d8e7..b5c8f08 100644 (file)
@@ -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 <typename T>
-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<size_t>(kBlockCopyLimit)) {
     OS::MemCopy(dst, src, num_bytes);
   } else {
-    int remaining = num_bytes;
+    size_t remaining = num_bytes;
     do {
       remaining--;
       *dst++ = *src++;