mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Add simdjson.cpp for unified use (#515)
This commit is contained in:
Executable → Regular
+28
-19
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on Mon Mar 2 14:10:52 PST 2020. Do not edit! */
|
||||
/* auto-generated on Mon Mar 2 15:35:47 PST 2020. Do not edit! */
|
||||
#include "simdjson.h"
|
||||
|
||||
/* used for http://dmalloc.com/ Dmalloc - Debug Malloc Library */
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
/* begin file src/simdjson.cpp */
|
||||
/* begin file src/document.cpp */
|
||||
|
||||
namespace simdjson {
|
||||
@@ -31,8 +32,7 @@ bool document::set_capacity(size_t capacity) {
|
||||
return string_buf && tape;
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
bool document::print_json(std::ostream &os, size_t max_depth) const {
|
||||
bool document::print_json(std::ostream &os, size_t max_depth) const noexcept {
|
||||
uint32_t string_length;
|
||||
size_t tape_idx = 0;
|
||||
uint64_t tape_val = tape[tape_idx];
|
||||
@@ -138,8 +138,7 @@ bool document::print_json(std::ostream &os, size_t max_depth) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
bool document::dump_raw_tape(std::ostream &os) const {
|
||||
bool document::dump_raw_tape(std::ostream &os) const noexcept {
|
||||
uint32_t string_length;
|
||||
size_t tape_idx = 0;
|
||||
uint64_t tape_val = tape[tape_idx];
|
||||
@@ -325,6 +324,9 @@ const std::map<int, const std::string> error_strings = {
|
||||
{UNSUPPORTED_ARCHITECTURE, "simdjson does not have an implementation"
|
||||
" supported by this CPU architecture (perhaps"
|
||||
" it's a non-SIMD CPU?)."},
|
||||
{INCORRECT_TYPE, "The JSON element does not have the requested type."},
|
||||
{NUMBER_OUT_OF_RANGE, "The JSON number is too large or too small to fit within the requested type."},
|
||||
{NO_SUCH_FIELD, "The JSON field referenced does not exist in this object."},
|
||||
{UNEXPECTED_ERROR, "Unexpected error, consider reporting this problem as"
|
||||
" you may have found a bug in simdjson"},
|
||||
};
|
||||
@@ -2330,7 +2332,7 @@ really_inline uint64_t follows(const uint64_t match, uint64_t &overflow) {
|
||||
really_inline uint64_t follows(const uint64_t match, const uint64_t filler, uint64_t &overflow) {
|
||||
uint64_t follows_match = follows(match, overflow);
|
||||
uint64_t result;
|
||||
overflow |= add_overflow(follows_match, filler, &result);
|
||||
overflow |= uint64_t(add_overflow(follows_match, filler, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2639,7 +2641,6 @@ namespace simdjson::haswell::simd {
|
||||
really_inline Child operator&(const Child other) const { return _mm256_and_si256(*this, other); }
|
||||
really_inline Child operator^(const Child other) const { return _mm256_xor_si256(*this, other); }
|
||||
really_inline Child bit_andnot(const Child other) const { return _mm256_andnot_si256(other, *this); }
|
||||
really_inline Child operator~() const { return *this ^ 0xFFu; }
|
||||
really_inline Child& operator|=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast | other; return *this_cast; }
|
||||
really_inline Child& operator&=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast & other; return *this_cast; }
|
||||
really_inline Child& operator^=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast ^ other; return *this_cast; }
|
||||
@@ -2679,6 +2680,7 @@ namespace simdjson::haswell::simd {
|
||||
|
||||
really_inline int to_bitmask() const { return _mm256_movemask_epi8(*this); }
|
||||
really_inline bool any() const { return !_mm256_testz_si256(*this, *this); }
|
||||
really_inline simd8<bool> operator~() const { return *this ^ true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -2713,6 +2715,9 @@ namespace simdjson::haswell::simd {
|
||||
really_inline simd8<T>& operator+=(const simd8<T> other) { *this = *this + other; return *(simd8<T>*)this; }
|
||||
really_inline simd8<T>& operator-=(const simd8<T> other) { *this = *this - other; return *(simd8<T>*)this; }
|
||||
|
||||
// Override to distinguish from bool version
|
||||
really_inline simd8<T> operator~() const { return *this ^ 0xFFu; }
|
||||
|
||||
// Perform a lookup assuming the value is between 0 and 16 (undefined behavior for out of range values)
|
||||
template<typename L>
|
||||
really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
|
||||
@@ -3675,7 +3680,7 @@ really_inline uint64_t follows(const uint64_t match, uint64_t &overflow) {
|
||||
really_inline uint64_t follows(const uint64_t match, const uint64_t filler, uint64_t &overflow) {
|
||||
uint64_t follows_match = follows(match, overflow);
|
||||
uint64_t result;
|
||||
overflow |= add_overflow(follows_match, filler, &result);
|
||||
overflow |= uint64_t(add_overflow(follows_match, filler, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3982,7 +3987,6 @@ namespace simdjson::westmere::simd {
|
||||
really_inline Child operator&(const Child other) const { return _mm_and_si128(*this, other); }
|
||||
really_inline Child operator^(const Child other) const { return _mm_xor_si128(*this, other); }
|
||||
really_inline Child bit_andnot(const Child other) const { return _mm_andnot_si128(other, *this); }
|
||||
really_inline Child operator~() const { return *this ^ 0xFFu; }
|
||||
really_inline Child& operator|=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast | other; return *this_cast; }
|
||||
really_inline Child& operator&=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast & other; return *this_cast; }
|
||||
really_inline Child& operator^=(const Child other) { auto this_cast = (Child*)this; *this_cast = *this_cast ^ other; return *this_cast; }
|
||||
@@ -4022,6 +4026,7 @@ namespace simdjson::westmere::simd {
|
||||
|
||||
really_inline int to_bitmask() const { return _mm_movemask_epi8(*this); }
|
||||
really_inline bool any() const { return !_mm_testz_si128(*this, *this); }
|
||||
really_inline simd8<bool> operator~() const { return *this ^ true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -4048,6 +4053,9 @@ namespace simdjson::westmere::simd {
|
||||
// Store to array
|
||||
really_inline void store(T dst[16]) const { return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this); }
|
||||
|
||||
// Override to distinguish from bool version
|
||||
really_inline simd8<T> operator~() const { return *this ^ 0xFFu; }
|
||||
|
||||
// Addition/subtraction are the same for signed and unsigned
|
||||
really_inline simd8<T> operator+(const simd8<T> other) const { return _mm_add_epi8(*this, other); }
|
||||
really_inline simd8<T> operator-(const simd8<T> other) const { return _mm_sub_epi8(*this, other); }
|
||||
@@ -5032,7 +5040,7 @@ really_inline uint64_t follows(const uint64_t match, uint64_t &overflow) {
|
||||
really_inline uint64_t follows(const uint64_t match, const uint64_t filler, uint64_t &overflow) {
|
||||
uint64_t follows_match = follows(match, overflow);
|
||||
uint64_t result;
|
||||
overflow |= add_overflow(follows_match, filler, &result);
|
||||
overflow |= uint64_t(add_overflow(follows_match, filler, &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5914,9 +5922,9 @@ never_inline bool parse_large_integer(const uint8_t *const buf,
|
||||
// content and append a space before calling this function.
|
||||
//
|
||||
// Our objective is accurate parsing (ULP of 0 or 1) at high speed.
|
||||
really_inline bool parse_number(const uint8_t *const buf,
|
||||
const uint32_t offset,
|
||||
bool found_minus,
|
||||
really_inline bool parse_number(UNUSED const uint8_t *const buf,
|
||||
UNUSED const uint32_t offset,
|
||||
UNUSED bool found_minus,
|
||||
document::parser &parser) {
|
||||
#ifdef SIMDJSON_SKIPNUMBERPARSING // for performance analysis, it is sometimes
|
||||
// useful to skip parsing
|
||||
@@ -7281,9 +7289,9 @@ never_inline bool parse_large_integer(const uint8_t *const buf,
|
||||
// content and append a space before calling this function.
|
||||
//
|
||||
// Our objective is accurate parsing (ULP of 0 or 1) at high speed.
|
||||
really_inline bool parse_number(const uint8_t *const buf,
|
||||
const uint32_t offset,
|
||||
bool found_minus,
|
||||
really_inline bool parse_number(UNUSED const uint8_t *const buf,
|
||||
UNUSED const uint32_t offset,
|
||||
UNUSED bool found_minus,
|
||||
document::parser &parser) {
|
||||
#ifdef SIMDJSON_SKIPNUMBERPARSING // for performance analysis, it is sometimes
|
||||
// useful to skip parsing
|
||||
@@ -8658,9 +8666,9 @@ never_inline bool parse_large_integer(const uint8_t *const buf,
|
||||
// content and append a space before calling this function.
|
||||
//
|
||||
// Our objective is accurate parsing (ULP of 0 or 1) at high speed.
|
||||
really_inline bool parse_number(const uint8_t *const buf,
|
||||
const uint32_t offset,
|
||||
bool found_minus,
|
||||
really_inline bool parse_number(UNUSED const uint8_t *const buf,
|
||||
UNUSED const uint32_t offset,
|
||||
UNUSED bool found_minus,
|
||||
document::parser &parser) {
|
||||
#ifdef SIMDJSON_SKIPNUMBERPARSING // for performance analysis, it is sometimes
|
||||
// useful to skip parsing
|
||||
@@ -9429,3 +9437,4 @@ UNTARGET_REGION
|
||||
#endif // SIMDJSON_WESTMERE_STAGE2_BUILD_TAPE_H
|
||||
/* end file src/generic/stage2_streaming_build_tape.h */
|
||||
/* end file src/generic/stage2_streaming_build_tape.h */
|
||||
/* end file src/generic/stage2_streaming_build_tape.h */
|
||||
|
||||
Reference in New Issue
Block a user