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 7395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7406 unsigned* remaining, | 7406 unsigned* remaining, |
7407 unsigned* offset); | 7407 unsigned* offset); |
7408 | 7408 |
7409 // Helper function for flattening strings. | 7409 // Helper function for flattening strings. |
7410 template <typename sinkchar> | 7410 template <typename sinkchar> |
7411 static void WriteToFlat(String* source, | 7411 static void WriteToFlat(String* source, |
7412 sinkchar* sink, | 7412 sinkchar* sink, |
7413 int from, | 7413 int from, |
7414 int to); | 7414 int to); |
7415 | 7415 |
7416 static inline bool IsAscii(const char* chars, int length) { | 7416 static inline const char* NonAsciiStart(const char* chars, int length) { |
Yang
2012/10/18 14:46:23
Please add a comment on what the return value is (
Toon Verwaest
2012/10/18 15:06:56
Done.
| |
7417 const char* limit = chars + length; | 7417 const char* limit = chars + length; |
7418 #ifdef V8_HOST_CAN_READ_UNALIGNED | 7418 #ifdef V8_HOST_CAN_READ_UNALIGNED |
7419 ASSERT(kMaxAsciiCharCode == 0x7F); | 7419 ASSERT(kMaxAsciiCharCode == 0x7F); |
7420 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80; | 7420 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80; |
7421 while (chars + sizeof(uintptr_t) <= limit) { | 7421 while (chars + sizeof(uintptr_t) <= limit) { |
7422 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) { | 7422 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) { |
7423 return false; | 7423 return chars; |
7424 } | 7424 } |
7425 chars += sizeof(uintptr_t); | 7425 chars += sizeof(uintptr_t); |
7426 } | 7426 } |
7427 #endif | 7427 #endif |
7428 while (chars < limit) { | 7428 while (chars < limit) { |
7429 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return false; | 7429 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return chars; |
7430 ++chars; | 7430 ++chars; |
7431 } | 7431 } |
7432 return true; | 7432 return chars; |
7433 } | |
7434 | |
7435 static inline bool IsAscii(const char* chars, int length) { | |
7436 const char* limit = chars + length; | |
7437 return NonAsciiStart(chars, length) >= limit; | |
7438 } | |
7439 | |
7440 static inline const uc16* NonAsciiStart(const uc16* chars, int length) { | |
7441 const uc16* limit = chars + length; | |
7442 while (chars < limit) { | |
7443 if (*chars > kMaxAsciiCharCodeU) return chars; | |
7444 ++chars; | |
7445 } | |
7446 return chars; | |
7433 } | 7447 } |
7434 | 7448 |
7435 static inline bool IsAscii(const uc16* chars, int length) { | 7449 static inline bool IsAscii(const uc16* chars, int length) { |
7436 const uc16* limit = chars + length; | 7450 const uc16* limit = chars + length; |
7437 while (chars < limit) { | 7451 return NonAsciiStart(chars, length) >= limit; |
7438 if (*chars > kMaxAsciiCharCodeU) return false; | |
7439 ++chars; | |
7440 } | |
7441 return true; | |
7442 } | 7452 } |
7443 | 7453 |
7444 protected: | 7454 protected: |
7445 class ReadBlockBuffer { | 7455 class ReadBlockBuffer { |
7446 public: | 7456 public: |
7447 ReadBlockBuffer(unibrow::byte* util_buffer_, | 7457 ReadBlockBuffer(unibrow::byte* util_buffer_, |
7448 unsigned cursor_, | 7458 unsigned cursor_, |
7449 unsigned capacity_, | 7459 unsigned capacity_, |
7450 unsigned remaining_) : | 7460 unsigned remaining_) : |
7451 util_buffer(util_buffer_), | 7461 util_buffer(util_buffer_), |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8938 } else { | 8948 } else { |
8939 value &= ~(1 << bit_position); | 8949 value &= ~(1 << bit_position); |
8940 } | 8950 } |
8941 return value; | 8951 return value; |
8942 } | 8952 } |
8943 }; | 8953 }; |
8944 | 8954 |
8945 } } // namespace v8::internal | 8955 } } // namespace v8::internal |
8946 | 8956 |
8947 #endif // V8_OBJECTS_H_ | 8957 #endif // V8_OBJECTS_H_ |
OLD | NEW |