Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: src/v8utils.h

Issue 13470008: Fix CopyBytes to accept size_t for num_bytes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/heap.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 do { 144 do {
145 remaining--; 145 remaining--;
146 *dst++ = *src++; 146 *dst++ = *src++;
147 } while (remaining > 0); 147 } while (remaining > 0);
148 } 148 }
149 } 149 }
150 150
151 151
152 // Copies data from |src| to |dst|. The data spans must not overlap. 152 // Copies data from |src| to |dst|. The data spans must not overlap.
153 template <typename T> 153 template <typename T>
154 inline void CopyBytes(T* dst, T* src, int num_bytes) { 154 inline void CopyBytes(T* dst, T* src, size_t num_bytes) {
155 STATIC_ASSERT(sizeof(T) == 1); 155 STATIC_ASSERT(sizeof(T) == 1);
156 ASSERT(Min(dst, src) + num_bytes <= Max(dst, src)); 156 ASSERT(Min(dst, src) + num_bytes <= Max(dst, src));
157 ASSERT(num_bytes >= 0);
158 if (num_bytes == 0) return; 157 if (num_bytes == 0) return;
159 158
160 // Use block copying OS::MemCopy if the segment we're copying is 159 // Use block copying OS::MemCopy if the segment we're copying is
161 // enough to justify the extra call/setup overhead. 160 // enough to justify the extra call/setup overhead.
162 static const int kBlockCopyLimit = OS::kMinComplexMemCopy; 161 static const int kBlockCopyLimit = OS::kMinComplexMemCopy;
163 162
164 if (num_bytes >= kBlockCopyLimit) { 163 if (num_bytes >= static_cast<size_t>(kBlockCopyLimit)) {
165 OS::MemCopy(dst, src, num_bytes); 164 OS::MemCopy(dst, src, num_bytes);
166 } else { 165 } else {
167 int remaining = num_bytes; 166 size_t remaining = num_bytes;
168 do { 167 do {
169 remaining--; 168 remaining--;
170 *dst++ = *src++; 169 *dst++ = *src++;
171 } while (remaining > 0); 170 } while (remaining > 0);
172 } 171 }
173 } 172 }
174 173
175 174
176 template <typename T, typename U> 175 template <typename T, typename U>
177 inline void MemsetPointer(T** dest, U* value, int counter) { 176 inline void MemsetPointer(T** dest, U* value, int counter) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 301
303 // Add formatted contents like printf based on a va_list. 302 // Add formatted contents like printf based on a va_list.
304 void AddFormattedList(const char* format, va_list list); 303 void AddFormattedList(const char* format, va_list list);
305 private: 304 private:
306 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); 305 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
307 }; 306 };
308 307
309 } } // namespace v8::internal 308 } } // namespace v8::internal
310 309
311 #endif // V8_V8UTILS_H_ 310 #endif // V8_V8UTILS_H_
OLDNEW
« src/heap.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698