|
1 | | -/* auto-generated on Tue Jul 7 13:32:36 EDT 2020. Do not edit! */ |
| 1 | +/* auto-generated on Tue Jul 7 15:13:17 EDT 2020. Do not edit! */ |
2 | 2 | /* begin file src/simdjson.cpp */ |
3 | 3 | #include "simdjson.h" |
4 | 4 |
|
@@ -2808,7 +2808,7 @@ really_inline json_character_block json_character_block::classify(const simd::si |
2808 | 2808 | } |
2809 | 2809 |
|
2810 | 2810 | really_inline bool is_ascii(const simd8x64<uint8_t>& input) { |
2811 | | - simd8<uint8_t> bits = (input.chunks[0] | input.chunks[1]) | (input.chunks[2] | input.chunks[3]); |
| 2811 | + simd8<uint8_t> bits = input.reduce_or(); |
2812 | 2812 | return bits.max() < 0b10000000u; |
2813 | 2813 | } |
2814 | 2814 |
|
@@ -3552,18 +3552,25 @@ namespace utf8_validation { |
3552 | 3552 | } |
3553 | 3553 |
|
3554 | 3554 | really_inline void check_next_input(const simd8x64<uint8_t>& input) { |
3555 | | - if (likely(is_ascii(input))) { |
| 3555 | + if (unlikely(!is_ascii(input))) { |
| 3556 | + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. |
| 3557 | + static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) || (simd8x64<uint8_t>::NUM_CHUNKS == 4)); |
| 3558 | + if(simd8x64<uint8_t>::NUM_CHUNKS == 2) { |
| 3559 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 3560 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 3561 | + } else if(simd8x64<uint8_t>::NUM_CHUNKS == 4) { |
| 3562 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 3563 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 3564 | + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); |
| 3565 | + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); |
| 3566 | + } |
| 3567 | + this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
| 3568 | + this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
| 3569 | + } else { |
3556 | 3570 | // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't |
3557 | 3571 | // possibly finish them. |
3558 | 3572 | this->error |= this->prev_incomplete; |
3559 | | - } else { |
3560 | | - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
3561 | | - for (int i=1; i<simd8x64<uint8_t>::NUM_CHUNKS; i++) { |
3562 | | - this->check_utf8_bytes(input.chunks[i], input.chunks[i-1]); |
3563 | | - } |
3564 | | - this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
3565 | | - this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
3566 | | - } |
| 3573 | + } |
3567 | 3574 | } |
3568 | 3575 |
|
3569 | 3576 | really_inline error_code errors() { |
@@ -7997,6 +8004,7 @@ namespace simd { |
7997 | 8004 | really_inline simd8<bool> bits_not_set(simd8<uint8_t> bits) const { return (*this & bits).bits_not_set(); } |
7998 | 8005 | really_inline simd8<bool> any_bits_set() const { return ~this->bits_not_set(); } |
7999 | 8006 | really_inline simd8<bool> any_bits_set(simd8<uint8_t> bits) const { return ~this->bits_not_set(bits); } |
| 8007 | + really_inline bool is_ascii() const { return _mm256_movemask_epi8(*this) == 0; } |
8000 | 8008 | really_inline bool bits_not_set_anywhere() const { return _mm256_testz_si256(*this, *this); } |
8001 | 8009 | really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } |
8002 | 8010 | really_inline bool bits_not_set_anywhere(simd8<uint8_t> bits) const { return _mm256_testz_si256(*this, bits); } |
@@ -8122,8 +8130,7 @@ really_inline json_character_block json_character_block::classify(const simd::si |
8122 | 8130 | } |
8123 | 8131 |
|
8124 | 8132 | really_inline bool is_ascii(const simd8x64<uint8_t>& input) { |
8125 | | - simd8<uint8_t> bits = input.reduce_or();; |
8126 | | - return !bits.any_bits_set_anywhere(0b10000000u); |
| 8133 | + return input.reduce_or().is_ascii(); |
8127 | 8134 | } |
8128 | 8135 |
|
8129 | 8136 | really_inline simd8<bool> must_be_continuation(const simd8<uint8_t>& prev1, const simd8<uint8_t>& prev2, const simd8<uint8_t>& prev3) { |
@@ -8862,18 +8869,25 @@ namespace utf8_validation { |
8862 | 8869 | } |
8863 | 8870 |
|
8864 | 8871 | really_inline void check_next_input(const simd8x64<uint8_t>& input) { |
8865 | | - if (likely(is_ascii(input))) { |
| 8872 | + if (unlikely(!is_ascii(input))) { |
| 8873 | + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. |
| 8874 | + static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) || (simd8x64<uint8_t>::NUM_CHUNKS == 4)); |
| 8875 | + if(simd8x64<uint8_t>::NUM_CHUNKS == 2) { |
| 8876 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 8877 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 8878 | + } else if(simd8x64<uint8_t>::NUM_CHUNKS == 4) { |
| 8879 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 8880 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 8881 | + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); |
| 8882 | + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); |
| 8883 | + } |
| 8884 | + this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
| 8885 | + this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
| 8886 | + } else { |
8866 | 8887 | // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't |
8867 | 8888 | // possibly finish them. |
8868 | 8889 | this->error |= this->prev_incomplete; |
8869 | | - } else { |
8870 | | - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
8871 | | - for (int i=1; i<simd8x64<uint8_t>::NUM_CHUNKS; i++) { |
8872 | | - this->check_utf8_bytes(input.chunks[i], input.chunks[i-1]); |
8873 | | - } |
8874 | | - this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
8875 | | - this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
8876 | | - } |
| 8890 | + } |
8877 | 8891 | } |
8878 | 8892 |
|
8879 | 8893 | really_inline error_code errors() { |
@@ -11176,6 +11190,7 @@ namespace simd { |
11176 | 11190 | really_inline simd8<bool> bits_not_set(simd8<uint8_t> bits) const { return (*this & bits).bits_not_set(); } |
11177 | 11191 | really_inline simd8<bool> any_bits_set() const { return ~this->bits_not_set(); } |
11178 | 11192 | really_inline simd8<bool> any_bits_set(simd8<uint8_t> bits) const { return ~this->bits_not_set(bits); } |
| 11193 | + really_inline bool is_ascii() const { return _mm_movemask_epi8(*this) == 0; } |
11179 | 11194 | really_inline bool bits_not_set_anywhere() const { return _mm_testz_si128(*this, *this); } |
11180 | 11195 | really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } |
11181 | 11196 | really_inline bool bits_not_set_anywhere(simd8<uint8_t> bits) const { return _mm_testz_si128(*this, bits); } |
@@ -11317,8 +11332,7 @@ really_inline json_character_block json_character_block::classify(const simd::si |
11317 | 11332 | } |
11318 | 11333 |
|
11319 | 11334 | really_inline bool is_ascii(const simd8x64<uint8_t>& input) { |
11320 | | - simd8<uint8_t> bits = input.reduce_or(); |
11321 | | - return !bits.any_bits_set_anywhere(0b10000000u); |
| 11335 | + return input.reduce_or().is_ascii(); |
11322 | 11336 | } |
11323 | 11337 |
|
11324 | 11338 | really_inline simd8<bool> must_be_continuation(const simd8<uint8_t>& prev1, const simd8<uint8_t>& prev2, const simd8<uint8_t>& prev3) { |
@@ -12057,18 +12071,25 @@ namespace utf8_validation { |
12057 | 12071 | } |
12058 | 12072 |
|
12059 | 12073 | really_inline void check_next_input(const simd8x64<uint8_t>& input) { |
12060 | | - if (likely(is_ascii(input))) { |
| 12074 | + if (unlikely(!is_ascii(input))) { |
| 12075 | + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. |
| 12076 | + static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) || (simd8x64<uint8_t>::NUM_CHUNKS == 4)); |
| 12077 | + if(simd8x64<uint8_t>::NUM_CHUNKS == 2) { |
| 12078 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 12079 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 12080 | + } else if(simd8x64<uint8_t>::NUM_CHUNKS == 4) { |
| 12081 | + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
| 12082 | + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); |
| 12083 | + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); |
| 12084 | + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); |
| 12085 | + } |
| 12086 | + this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
| 12087 | + this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
| 12088 | + } else { |
12061 | 12089 | // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't |
12062 | 12090 | // possibly finish them. |
12063 | 12091 | this->error |= this->prev_incomplete; |
12064 | | - } else { |
12065 | | - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); |
12066 | | - for (int i=1; i<simd8x64<uint8_t>::NUM_CHUNKS; i++) { |
12067 | | - this->check_utf8_bytes(input.chunks[i], input.chunks[i-1]); |
12068 | | - } |
12069 | | - this->prev_incomplete = is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]); |
12070 | | - this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS-1]; |
12071 | | - } |
| 12092 | + } |
12072 | 12093 | } |
12073 | 12094 |
|
12074 | 12095 | really_inline error_code errors() { |
|
0 commit comments