Opting for a more common intrinsic.

This commit is contained in:
Daniel Lemire 2018-11-09 21:41:15 -05:00
parent 3c7a17cbc1
commit 17f5d0517d
3 changed files with 9 additions and 3 deletions

View File

@ -10,7 +10,7 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
//#define MAX_JSON_BYTES 0xFFFFFF
const u32 MAX_DEPTH = 256; const u32 MAX_DEPTH = 256;
const u32 DEPTH_SAFETY_MARGIN = 32; // should be power-of-2 as we check this 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_ENTRIES = 127 * 1024;
const size_t MAX_TAPE = MAX_DEPTH * MAX_TAPE_ENTRIES; const size_t MAX_TAPE = MAX_DEPTH * MAX_TAPE_ENTRIES;
/////////////
// TODO: move this to be more like a real class // 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 { struct ParsedJson {
public: public:
size_t bytecapacity; // indicates how many bits are meant to be supported by size_t bytecapacity; // indicates how many bits are meant to be supported by

View File

@ -109,7 +109,7 @@ really_inline bool parse_string(const u8 *buf, UNUSED size_t len,
#endif // CHECKUNESCAPED #endif // CHECKUNESCAPED
u32 quote_dist = _mm_tzcnt_64(quote_bits); 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 // store to dest unconditionally - we can overwrite the bits we don't like
// later // later
_mm256_storeu_si256((m256 *)(dst), v); _mm256_storeu_si256((m256 *)(dst), v);

View File

@ -21,7 +21,7 @@
#endif #endif
#define SET_BIT(i) \ #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); s = s & (s - 1);
#define SET_BIT1 SET_BIT(0) #define SET_BIT1 SET_BIT(0)