mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
de8df0a05f
* Allow -f
* Support parse -s (force sse)
* Simplify flatten_bits
- Add directly to base instead of storing variable
- Don't modify base_ptr after beginning of function
- Eliminate base variable and increment base_ptr instead
* De-unroll the flatten_bits loops
* Decrease dependencies in stage 1
- Do all finalize_structurals work before computing the quote mask; mask
out the quote mask later
- Join find_whitespace_and_structurals and finalize_structurals into
single find_structurals call, to reduce variable leakage
- Rework pseudo_pred algorithm to refer to "primitive" for clarity and some
dependency reduction
- Rename quote_mask to in_string to describe what we're trying to
achieve ("mask" could mean many things)
- Break up find_quote_mask_and_bits into find_quote_mask and
invalid_string_bytes to reduce data leakage (i.e. don't expose quote bits
or odd_ends at all to find_structural_bits)
- Genericize overflow methods "follows" and "follows_odd_sequence" for
descriptiveness and possible lifting into a generic simd parsing library
* Mark branches as likely/unlikely
* Reorder and unroll+interleave stage 1 loop
* Nest the cnt > 16 branch inside cnt > 8
77 lines
1.9 KiB
C
77 lines
1.9 KiB
C
#ifndef SIMDJSON_COMMON_DEFS_H
|
|
#define SIMDJSON_COMMON_DEFS_H
|
|
|
|
#include "simdjson/portability.h"
|
|
|
|
#include <cassert>
|
|
|
|
// we support documents up to 4GB
|
|
#define SIMDJSON_MAXSIZE_BYTES 0xFFFFFFFF
|
|
|
|
// the input buf should be readable up to buf + SIMDJSON_PADDING
|
|
#ifdef __AVX2__
|
|
#define SIMDJSON_PADDING sizeof(__m256i)
|
|
#else
|
|
// this is a stopgap; there should be a better description of the
|
|
// main loop and its behavior that abstracts over this
|
|
#define SIMDJSON_PADDING 32
|
|
#endif
|
|
|
|
#if defined(__GNUC__)
|
|
// Marks a block with a name so that MCA analysis can see it.
|
|
#define BEGIN_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-BEGIN " #name);
|
|
#define END_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-END " #name);
|
|
#define DEBUG_BLOCK(name, block) BEGIN_DEBUG_BLOCK(name); block; END_DEBUG_BLOCK(name);
|
|
#else
|
|
#define BEGIN_DEBUG_BLOCK(name)
|
|
#define END_DEBUG_BLOCK(name)
|
|
#define DEBUG_BLOCK(name, block)
|
|
#endif
|
|
|
|
#ifndef _MSC_VER
|
|
// Implemented using Labels as Values which works in GCC and CLANG (and maybe
|
|
// also in Intel's compiler), but won't work in MSVC.
|
|
#define SIMDJSON_USE_COMPUTED_GOTO
|
|
#endif
|
|
|
|
// Align to N-byte boundary
|
|
#define ROUNDUP_N(a, n) (((a) + ((n)-1)) & ~((n)-1))
|
|
#define ROUNDDOWN_N(a, n) ((a) & ~((n)-1))
|
|
|
|
#define ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n)-1)) == 0)
|
|
|
|
#ifdef _MSC_VER
|
|
#define really_inline __forceinline
|
|
#define never_inline __declspec(noinline)
|
|
|
|
#define UNUSED
|
|
#define WARN_UNUSED
|
|
|
|
#ifndef likely
|
|
#define likely(x) x
|
|
#endif
|
|
#ifndef unlikely
|
|
#define unlikely(x) x
|
|
#endif
|
|
|
|
|
|
#else
|
|
|
|
|
|
#define really_inline inline __attribute__((always_inline, unused))
|
|
#define never_inline inline __attribute__((noinline, unused))
|
|
|
|
#define UNUSED __attribute__((unused))
|
|
#define WARN_UNUSED __attribute__((warn_unused_result))
|
|
|
|
#ifndef likely
|
|
#define likely(x) __builtin_expect(!!(x), 1)
|
|
#endif
|
|
#ifndef unlikely
|
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
|
#endif
|
|
|
|
#endif // MSC_VER
|
|
|
|
#endif // SIMDJSON_COMMON_DEFS_H
|