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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 | 260 |
261 template <typename sourcechar, typename sinkchar> | 261 template <typename sourcechar, typename sinkchar> |
262 INLINE(static void CopyCharsUnsigned(sinkchar* dest, | 262 INLINE(static void CopyCharsUnsigned(sinkchar* dest, |
263 const sourcechar* src, | 263 const sourcechar* src, |
264 int chars)); | 264 int chars)); |
265 #if defined(V8_HOST_ARCH_ARM) | 265 #if defined(V8_HOST_ARCH_ARM) |
266 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars)); | 266 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars)); |
267 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src, int chars)); | 267 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src, int chars)); |
268 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars)); | 268 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars)); |
| 269 #elif defined(V8_HOST_ARCH_MIPS) |
| 270 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars)); |
| 271 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars)); |
269 #endif | 272 #endif |
270 | 273 |
271 // Copy from ASCII/16bit chars to ASCII/16bit chars. | 274 // Copy from ASCII/16bit chars to ASCII/16bit chars. |
272 template <typename sourcechar, typename sinkchar> | 275 template <typename sourcechar, typename sinkchar> |
273 INLINE(void CopyChars(sinkchar* dest, const sourcechar* src, int chars)); | 276 INLINE(void CopyChars(sinkchar* dest, const sourcechar* src, int chars)); |
274 | 277 |
275 template<typename sourcechar, typename sinkchar> | 278 template<typename sourcechar, typename sinkchar> |
276 void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { | 279 void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { |
277 ASSERT(sizeof(sourcechar) <= 2); | 280 ASSERT(sizeof(sourcechar) <= 2); |
278 ASSERT(sizeof(sinkchar) <= 2); | 281 ASSERT(sizeof(sinkchar) <= 2); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 memcpy(dest, src, 12); | 417 memcpy(dest, src, 12); |
415 break; | 418 break; |
416 case 7: | 419 case 7: |
417 memcpy(dest, src, 14); | 420 memcpy(dest, src, 14); |
418 break; | 421 break; |
419 default: | 422 default: |
420 OS::MemCopy(dest, src, chars * sizeof(*dest)); | 423 OS::MemCopy(dest, src, chars * sizeof(*dest)); |
421 break; | 424 break; |
422 } | 425 } |
423 } | 426 } |
| 427 |
| 428 |
| 429 #elif defined(V8_HOST_ARCH_MIPS) |
| 430 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, int chars) { |
| 431 if (chars < OS::kMinComplexMemCopy) { |
| 432 memcpy(dest, src, chars); |
| 433 } else { |
| 434 OS::MemCopy(dest, src, chars); |
| 435 } |
| 436 } |
| 437 |
| 438 void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars) { |
| 439 if (chars < OS::kMinComplexMemCopy) { |
| 440 memcpy(dest, src, chars * sizeof(*dest)); |
| 441 } else { |
| 442 OS::MemCopy(dest, src, chars * sizeof(*dest)); |
| 443 } |
| 444 } |
424 #endif | 445 #endif |
425 | 446 |
426 | 447 |
427 class StringBuilder : public SimpleStringBuilder { | 448 class StringBuilder : public SimpleStringBuilder { |
428 public: | 449 public: |
429 explicit StringBuilder(int size) : SimpleStringBuilder(size) { } | 450 explicit StringBuilder(int size) : SimpleStringBuilder(size) { } |
430 StringBuilder(char* buffer, int size) : SimpleStringBuilder(buffer, size) { } | 451 StringBuilder(char* buffer, int size) : SimpleStringBuilder(buffer, size) { } |
431 | 452 |
432 // Add formatted contents to the builder just like printf(). | 453 // Add formatted contents to the builder just like printf(). |
433 void AddFormatted(const char* format, ...); | 454 void AddFormatted(const char* format, ...); |
434 | 455 |
435 // Add formatted contents like printf based on a va_list. | 456 // Add formatted contents like printf based on a va_list. |
436 void AddFormattedList(const char* format, va_list list); | 457 void AddFormattedList(const char* format, va_list list); |
437 private: | 458 private: |
438 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 459 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
439 }; | 460 }; |
440 | 461 |
441 } } // namespace v8::internal | 462 } } // namespace v8::internal |
442 | 463 |
443 #endif // V8_V8UTILS_H_ | 464 #endif // V8_V8UTILS_H_ |
OLD | NEW |