From 17f5d0517d212cdd32287a4d2f3f1ef4b74bb625 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 9 Nov 2018 21:41:15 -0500 Subject: [PATCH] Opting for a more common intrinsic. --- include/jsonparser/simdjson_internal.h | 8 +++++++- include/jsonparser/stringparsing.h | 2 +- src/stage2_flatten.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/jsonparser/simdjson_internal.h b/include/jsonparser/simdjson_internal.h index 7a9826a3..84e6b6cf 100644 --- a/include/jsonparser/simdjson_internal.h +++ b/include/jsonparser/simdjson_internal.h @@ -10,7 +10,7 @@ #include #include -//#define MAX_JSON_BYTES 0xFFFFFF + const u32 MAX_DEPTH = 256; const u32 DEPTH_SAFETY_MARGIN = 32; // should be power-of-2 as we check this @@ -20,7 +20,13 @@ const u32 REDLINE_DEPTH = MAX_DEPTH - DEPTH_SAFETY_MARGIN; const size_t MAX_TAPE_ENTRIES = 127 * 1024; const size_t MAX_TAPE = MAX_DEPTH * MAX_TAPE_ENTRIES; +///////////// // TODO: move this to be more like a real class +// currently, you need to create it like so... +// ParsedJson *pj_ptr = allocate_ParsedJson(numberofbytes); // allocate memory for parsing up to numberofbytes +// and we clear it like so deallocate_ParsedJson(pj_ptr); +// That's obviously not very C++-ish. It should be trivial to add a constructor and a destructor. +//////////// struct ParsedJson { public: size_t bytecapacity; // indicates how many bits are meant to be supported by diff --git a/include/jsonparser/stringparsing.h b/include/jsonparser/stringparsing.h index 9c9e1d35..fec86338 100644 --- a/include/jsonparser/stringparsing.h +++ b/include/jsonparser/stringparsing.h @@ -109,7 +109,7 @@ really_inline bool parse_string(const u8 *buf, UNUSED size_t len, #endif // CHECKUNESCAPED u32 quote_dist = _mm_tzcnt_64(quote_bits); - u32 bs_dist = _mm_tzcnt_64(bs_bits); + u32 bs_dist = __tzcnt_u64(bs_bits); // store to dest unconditionally - we can overwrite the bits we don't like // later _mm256_storeu_si256((m256 *)(dst), v); diff --git a/src/stage2_flatten.cpp b/src/stage2_flatten.cpp index a995cdf1..f22dd7b6 100644 --- a/src/stage2_flatten.cpp +++ b/src/stage2_flatten.cpp @@ -21,7 +21,7 @@ #endif #define SET_BIT(i) \ - base_ptr[base + i] = (u32)idx + _mm_tzcnt_64(s); \ + base_ptr[base + i] = (u32)idx + __tzcnt_u64(s); \ s = s & (s - 1); #define SET_BIT1 SET_BIT(0)