OLD | NEW |
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) { | 242 void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) { |
243 sinkchar* limit = dest + chars; | 243 sinkchar* limit = dest + chars; |
244 #ifdef V8_HOST_CAN_READ_UNALIGNED | 244 #ifdef V8_HOST_CAN_READ_UNALIGNED |
245 if (sizeof(*dest) == sizeof(*src)) { | 245 if (sizeof(*dest) == sizeof(*src)) { |
246 if (chars >= static_cast<int>(OS::kMinComplexMemCopy / sizeof(*dest))) { | 246 if (chars >= static_cast<int>(OS::kMinComplexMemCopy / sizeof(*dest))) { |
247 OS::MemCopy(dest, src, chars * sizeof(*dest)); | 247 OS::MemCopy(dest, src, chars * sizeof(*dest)); |
248 return; | 248 return; |
249 } | 249 } |
250 // Number of characters in a uintptr_t. | 250 // Number of characters in a uintptr_t. |
251 static const int kStepSize = sizeof(uintptr_t) / sizeof(*dest); // NOLINT | 251 static const int kStepSize = sizeof(uintptr_t) / sizeof(*dest); // NOLINT |
252 while (dest <= limit - kStepSize) { | 252 ASSERT(dest + kStepSize > dest); // Check for overflow. |
| 253 while (dest + kStepSize <= limit) { |
253 *reinterpret_cast<uintptr_t*>(dest) = | 254 *reinterpret_cast<uintptr_t*>(dest) = |
254 *reinterpret_cast<const uintptr_t*>(src); | 255 *reinterpret_cast<const uintptr_t*>(src); |
255 dest += kStepSize; | 256 dest += kStepSize; |
256 src += kStepSize; | 257 src += kStepSize; |
257 } | 258 } |
258 } | 259 } |
259 #endif | 260 #endif |
260 while (dest < limit) { | 261 while (dest < limit) { |
261 *dest++ = static_cast<sinkchar>(*src++); | 262 *dest++ = static_cast<sinkchar>(*src++); |
262 } | 263 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 305 |
305 // Add formatted contents like printf based on a va_list. | 306 // Add formatted contents like printf based on a va_list. |
306 void AddFormattedList(const char* format, va_list list); | 307 void AddFormattedList(const char* format, va_list list); |
307 private: | 308 private: |
308 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 309 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
309 }; | 310 }; |
310 | 311 |
311 } } // namespace v8::internal | 312 } } // namespace v8::internal |
312 | 313 |
313 #endif // V8_V8UTILS_H_ | 314 #endif // V8_V8UTILS_H_ |
OLD | NEW |