1- /* auto-generated on Fri 22 Feb 2019 19:16:31 EST . Do not edit! */
2- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/portability.h */
1+ /* auto-generated on Tue 26 Feb 13:29:52 AEDT 2019 . Do not edit! */
2+ /* begin file /home/geoff/git /simdjson/include/simdjson/portability.h */
33#ifndef SIMDJSON_PORTABILITY_H
44#define SIMDJSON_PORTABILITY_H
55
@@ -127,8 +127,8 @@ static inline void aligned_free(void *memblock) {
127127}
128128
129129#endif /* end of include PORTABILITY_H */
130- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/portability.h */
131- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/common_defs.h */
130+ /* end file /home/geoff/git /simdjson/include/simdjson/portability.h */
131+ /* begin file /home/geoff/git /simdjson/include/simdjson/common_defs.h */
132132#ifndef SIMDJSON_COMMON_DEFS_H
133133#define SIMDJSON_COMMON_DEFS_H
134134
@@ -157,7 +157,7 @@ static inline void aligned_free(void *memblock) {
157157
158158
159159#define really_inline inline
160- #define never_inline inline
160+ #define never_inline __declspec(noinline)
161161
162162#define UNUSED
163163#define WARN_UNUSED
@@ -187,8 +187,8 @@ static inline void aligned_free(void *memblock) {
187187#endif // MSC_VER
188188
189189#endif // COMMON_DEFS_H
190- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/common_defs.h */
191- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/jsoncharutils.h */
190+ /* end file /home/geoff/git /simdjson/include/simdjson/common_defs.h */
191+ /* begin file /home/geoff/git /simdjson/include/simdjson/jsoncharutils.h */
192192#ifndef SIMDJSON_JSONCHARUTILS_H
193193#define SIMDJSON_JSONCHARUTILS_H
194194
@@ -240,7 +240,7 @@ really_inline uint32_t is_structural_or_whitespace(uint8_t c) {
240240 return structural_or_whitespace[c];
241241}
242242
243- const char digittoval[256] = {
243+ const signed char digittoval[256] = {
244244 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
245245 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
246246 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
@@ -256,25 +256,18 @@ const char digittoval[256] = {
256256 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
257257 -1, -1, -1, -1, -1, -1, -1, -1, -1};
258258
259- // return true if we have a valid hex between 0000 and FFFF
260- /*inline bool hex_to_u32(const uint8_t *src, uint32_t *res) {
261- uint8_t v1 = src[0];
262- uint8_t v2 = src[1];
263- uint8_t v3 = src[2];
264- uint8_t v4 = src[3];
265- *res = digittoval[v1] << 12 | digittoval[v2] << 8 | digittoval[v3] << 4 |
266- digittoval[v4];
267- return (int32_t)(*res) >= 0;
268- }*/
269-
270- // returns a value with the highest bit set if it is not valid
259+ // returns a value with the high 16 bits set if not valid
260+ // otherwise returns the conversion of the 4 hex digits at src into the bottom 16 bits of the 32-bit
261+ // return register
271262static inline uint32_t hex_to_u32_nocheck(const uint8_t *src) {// strictly speaking, static inline is a C-ism
272- uint8_t v1 = src[0];
273- uint8_t v2 = src[1];
274- uint8_t v3 = src[2];
275- uint8_t v4 = src[3];
276- return digittoval[v1] << 12 | digittoval[v2] << 8 | digittoval[v3] << 4 |
277- digittoval[v4];
263+ // all these will sign-extend the chars looked up, placing 1-bits into the high 28 bits of every
264+ // invalid value. After the shifts, this will *still* result in the outcome that the high 16 bits of any
265+ // value with any invalid char will be all 1's. We check for this in the caller.
266+ int32_t v1 = digittoval[src[0]];
267+ int32_t v2 = digittoval[src[1]];
268+ int32_t v3 = digittoval[src[2]];
269+ int32_t v4 = digittoval[src[3]];
270+ return static_cast<uint32_t>(v1 << 12 | v2 << 8 | v3 << 4 | v4);
278271}
279272
280273// given a code point cp, writes to c
@@ -317,8 +310,8 @@ inline size_t codepoint_to_utf8(uint32_t cp, uint8_t *c) {
317310}
318311
319312#endif
320- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/jsoncharutils.h */
321- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonformatutils.h */
313+ /* end file /home/geoff/git /simdjson/include/simdjson/jsoncharutils.h */
314+ /* begin file /home/geoff/git /simdjson/include/simdjson/jsonformatutils.h */
322315#ifndef SIMDJSON_JSONFORMATUTILS_H
323316#define SIMDJSON_JSONFORMATUTILS_H
324317
@@ -415,8 +408,8 @@ static inline void print_with_escapes(const char *src, std::ostream &os) {
415408}
416409
417410#endif
418- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonformatutils.h */
419- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonioutil.h */
411+ /* end file /home/geoff/git /simdjson/include/simdjson/jsonformatutils.h */
412+ /* begin file /home/geoff/git /simdjson/include/simdjson/jsonioutil.h */
420413#ifndef SIMDJSON_JSONIOUTIL_H
421414#define SIMDJSON_JSONIOUTIL_H
422415
@@ -456,8 +449,8 @@ std::string_view get_corpus(std::string filename);
456449
457450
458451#endif
459- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonioutil.h */
460- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/simdprune_tables.h */
452+ /* end file /home/geoff/git /simdjson/include/simdjson/jsonioutil.h */
453+ /* begin file /home/geoff/git /simdjson/include/simdjson/simdprune_tables.h */
461454#ifndef SIMDJSON_SIMDPRUNE_TABLES_H
462455#define SIMDJSON_SIMDPRUNE_TABLES_H
463456
@@ -35536,8 +35529,8 @@ static const uint32_t mask256_epi32[] = {
3553635529#endif //__AVX2__
3553735530
3553835531#endif
35539- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/simdprune_tables.h */
35540- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/simdutf8check.h */
35532+ /* end file /home/geoff/git /simdjson/include/simdjson/simdprune_tables.h */
35533+ /* begin file /home/geoff/git /simdjson/include/simdjson/simdutf8check.h */
3554135534
3554235535#ifndef SIMDJSON_SIMDUTF8CHECK_H
3554335536#define SIMDJSON_SIMDUTF8CHECK_H
@@ -35732,8 +35725,8 @@ avxcheckUTF8Bytes(__m256i current_bytes,
3573235725#warning "We require AVX2 support!"
3573335726#endif // __AVX2__
3573435727#endif
35735- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/simdutf8check.h */
35736- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonminifier.h */
35728+ /* end file /home/geoff/git /simdjson/include/simdjson/simdutf8check.h */
35729+ /* begin file /home/geoff/git /simdjson/include/simdjson/jsonminifier.h */
3573735730#ifndef SIMDJSON_JSONMINIFIER_H
3573835731#define SIMDJSON_JSONMINIFIER_H
3573935732
@@ -35756,14 +35749,13 @@ static inline size_t jsonminify(const std::string_view & p, char *out) {
3575635749}
3575735750
3575835751#endif
35759- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonminifier.h */
35760- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/parsedjson.h */
35752+ /* end file /home/geoff/git /simdjson/include/simdjson/jsonminifier.h */
35753+ /* begin file /home/geoff/git /simdjson/include/simdjson/parsedjson.h */
3576135754#ifndef SIMDJSON_PARSEDJSON_H
3576235755#define SIMDJSON_PARSEDJSON_H
3576335756
35764- #include <math.h>
35765- #include <inttypes.h>
35766- #include <string.h>
35757+ #include <cmath>
35758+ #include <cstring>
3576735759#include <iomanip>
3576835760#include <iostream>
3576935761
@@ -35984,11 +35976,8 @@ struct ParsedJson {
3598435976 bool isvalid;
3598535977
3598635978private :
35987-
35988- // we don't want the default constructor to be called
35989- ParsedJson(const ParsedJson & p); // we don't want the default constructor to be called
35990- // we don't want the assignment to be called
35991- ParsedJson & operator=(const ParsedJson&o);
35979+ ParsedJson(const ParsedJson & p) = delete;
35980+ ParsedJson & operator=(const ParsedJson&o) = delete;
3599235981};
3599335982
3599435983
@@ -36009,8 +35998,8 @@ inline void dumpbits32_always(uint32_t v, const std::string &msg) {
3600935998
3601035999
3601136000#endif
36012- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/parsedjson.h */
36013- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/stage1_find_marks.h */
36001+ /* end file /home/geoff/git /simdjson/include/simdjson/parsedjson.h */
36002+ /* begin file /home/geoff/git /simdjson/include/simdjson/stage1_find_marks.h */
3601436003#ifndef SIMDJSON_STAGE1_FIND_MARKS_H
3601536004#define SIMDJSON_STAGE1_FIND_MARKS_H
3601636005
@@ -36024,8 +36013,8 @@ static inline bool find_structural_bits(const char *buf, size_t len, ParsedJson
3602436013}
3602536014
3602636015#endif
36027- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/stage1_find_marks.h */
36028- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/stringparsing.h */
36016+ /* end file /home/geoff/git /simdjson/include/simdjson/stage1_find_marks.h */
36017+ /* begin file /home/geoff/git /simdjson/include/simdjson/stringparsing.h */
3602936018#ifndef SIMDJSON_STRINGPARSING_H
3603036019#define SIMDJSON_STRINGPARSING_H
3603136020
@@ -36066,6 +36055,9 @@ static const uint8_t escape_map[256] = {
3606636055// We work in little-endian then swap at write time
3606736056WARN_UNUSED
3606836057really_inline bool handle_unicode_codepoint(const uint8_t **src_ptr, uint8_t **dst_ptr) {
36058+ // hex_to_u32_nocheck fills high 16 bits of the return value with 1s if the
36059+ // conversion isn't valid; we defer the check for this to inside the
36060+ // multilingual plane check
3606936061 uint32_t code_point = hex_to_u32_nocheck(*src_ptr + 2);
3607036062 *src_ptr += 6;
3607136063 // check for low surrogate for characters outside the Basic
@@ -36075,6 +36067,16 @@ really_inline bool handle_unicode_codepoint(const uint8_t **src_ptr, uint8_t **d
3607536067 return false;
3607636068 }
3607736069 uint32_t code_point_2 = hex_to_u32_nocheck(*src_ptr + 2);
36070+
36071+ // if the first code point is invalid we will get here, as we will go past
36072+ // the check for being outside the Basic Multilingual plane. If we don't
36073+ // find a \u immediately afterwards we fail out anyhow, but if we do,
36074+ // this check catches both the case of the first code point being invalid
36075+ // or the second code point being invalid.
36076+ if ((code_point | code_point_2) >> 16) {
36077+ return false;
36078+ }
36079+
3607836080 code_point =
3607936081 (((code_point - 0xd800) << 10) | (code_point_2 - 0xdc00)) + 0x10000;
3608036082 *src_ptr += 6;
@@ -36203,8 +36205,8 @@ really_inline bool parse_string(const uint8_t *buf, UNUSED size_t len,
3620336205
3620436206
3620536207#endif
36206- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/stringparsing.h */
36207- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/numberparsing.h */
36208+ /* end file /home/geoff/git /simdjson/include/simdjson/stringparsing.h */
36209+ /* begin file /home/geoff/git /simdjson/include/simdjson/numberparsing.h */
3620836210#ifndef SIMDJSON_NUMBERPARSING_H
3620936211#define SIMDJSON_NUMBERPARSING_H
3621036212
@@ -36721,8 +36723,8 @@ static really_inline bool parse_number(const uint8_t *const buf,
3672136723}
3672236724
3672336725#endif
36724- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/numberparsing.h */
36725- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/stage2_build_tape.h */
36726+ /* end file /home/geoff/git /simdjson/include/simdjson/numberparsing.h */
36727+ /* begin file /home/geoff/git /simdjson/include/simdjson/stage2_build_tape.h */
3672636728#ifndef SIMDJSON_STAGE34_UNIFIED_H
3672736729#define SIMDJSON_STAGE34_UNIFIED_H
3672836730
@@ -36739,8 +36741,8 @@ static inline bool unified_machine(const char *buf, size_t len, ParsedJson &pj)
3673936741}
3674036742
3674136743#endif
36742- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/stage2_build_tape.h */
36743- /* begin file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonparser.h */
36744+ /* end file /home/geoff/git /simdjson/include/simdjson/stage2_build_tape.h */
36745+ /* begin file /home/geoff/git /simdjson/include/simdjson/jsonparser.h */
3674436746#ifndef SIMDJSON_JSONPARSER_H
3674536747#define SIMDJSON_JSONPARSER_H
3674636748
@@ -36820,4 +36822,4 @@ inline ParsedJson build_parsed_json(const std::string_view &s, bool reallocifnee
3682036822}
3682136823
3682236824#endif
36823- /* end file /Users/lemire/CVS/github /simdjson/include/simdjson/jsonparser.h */
36825+ /* end file /home/geoff/git /simdjson/include/simdjson/jsonparser.h */
0 commit comments