| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
| 6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
| 7 | 7 |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 reinterpret_cast<const uint16_t*>(src), | 1280 reinterpret_cast<const uint16_t*>(src), |
| 1281 chars); | 1281 chars); |
| 1282 } | 1282 } |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 template <typename sourcechar, typename sinkchar> | 1286 template <typename sourcechar, typename sinkchar> |
| 1287 void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) { | 1287 void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) { |
| 1288 sinkchar* limit = dest + chars; | 1288 sinkchar* limit = dest + chars; |
| 1289 #ifdef V8_HOST_CAN_READ_UNALIGNED | 1289 #ifdef V8_HOST_CAN_READ_UNALIGNED |
| 1290 if (sizeof(*dest) == sizeof(*src)) { | 1290 if ((sizeof(*dest) == sizeof(*src)) && |
| 1291 if (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest))) { | 1291 (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest)))) { |
| 1292 MemCopy(dest, src, chars * sizeof(*dest)); | 1292 MemCopy(dest, src, chars * sizeof(*dest)); |
| 1293 return; | 1293 return; |
| 1294 } | |
| 1295 // Number of characters in a uintptr_t. | |
| 1296 static const int kStepSize = sizeof(uintptr_t) / sizeof(*dest); // NOLINT | |
| 1297 DCHECK(dest + kStepSize > dest); // Check for overflow. | |
| 1298 while (dest + kStepSize <= limit) { | |
| 1299 *reinterpret_cast<uintptr_t*>(dest) = | |
| 1300 *reinterpret_cast<const uintptr_t*>(src); | |
| 1301 dest += kStepSize; | |
| 1302 src += kStepSize; | |
| 1303 } | |
| 1304 } | 1294 } |
| 1305 #endif | 1295 #endif |
| 1306 while (dest < limit) { | 1296 while (dest < limit) { |
| 1307 *dest++ = static_cast<sinkchar>(*src++); | 1297 *dest++ = static_cast<sinkchar>(*src++); |
| 1308 } | 1298 } |
| 1309 } | 1299 } |
| 1310 | 1300 |
| 1311 | 1301 |
| 1312 #if defined(V8_HOST_ARCH_ARM) | 1302 #if defined(V8_HOST_ARCH_ARM) |
| 1313 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) { | 1303 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 // Takes the address of the limit variable in order to find out where | 1467 // Takes the address of the limit variable in order to find out where |
| 1478 // the top of stack is right now. | 1468 // the top of stack is right now. |
| 1479 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1469 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
| 1480 return limit; | 1470 return limit; |
| 1481 } | 1471 } |
| 1482 | 1472 |
| 1483 } // namespace internal | 1473 } // namespace internal |
| 1484 } // namespace v8 | 1474 } // namespace v8 |
| 1485 | 1475 |
| 1486 #endif // V8_UTILS_H_ | 1476 #endif // V8_UTILS_H_ |
| OLD | NEW |