Include <simdjson> directly, move document_parser_callbacks to top level

This commit is contained in:
John Keiser 2020-03-04 09:04:59 -08:00
parent 1c922d3b73
commit 5ff941ae3d
37 changed files with 101 additions and 114 deletions

View File

@ -62,7 +62,7 @@ SRCHEADERS_GENERIC=src/generic/numberparsing.h src/generic/stage1_find_marks.h s
SRCHEADERS_ARM64= src/arm64/bitmanipulation.h src/arm64/bitmask.h src/arm64/intrinsics.h src/arm64/numberparsing.h src/arm64/simd.h src/arm64/stage1_find_marks.h src/arm64/stage2_build_tape.h src/arm64/stringparsing.h
SRCHEADERS_HASWELL= src/haswell/bitmanipulation.h src/haswell/bitmask.h src/haswell/intrinsics.h src/haswell/numberparsing.h src/haswell/simd.h src/haswell/stage1_find_marks.h src/haswell/stage2_build_tape.h src/haswell/stringparsing.h
SRCHEADERS_WESTMERE=src/westmere/bitmanipulation.h src/westmere/bitmask.h src/westmere/intrinsics.h src/westmere/numberparsing.h src/westmere/simd.h src/westmere/stage1_find_marks.h src/westmere/stage2_build_tape.h src/westmere/stringparsing.h
SRCHEADERS_SRC=src/isadetection.h src/jsoncharutils.h src/simdprune_tables.h src/error.cpp src/jsonioutil.cpp src/implementation.cpp src/stage1_find_marks.cpp src/stage2_build_tape.cpp src/inline/document_parser_callbacks.h
SRCHEADERS_SRC=src/isadetection.h src/jsoncharutils.h src/simdprune_tables.h src/error.cpp src/jsonioutil.cpp src/implementation.cpp src/stage1_find_marks.cpp src/stage2_build_tape.cpp src/document_parser_callbacks.h
SRCHEADERS=$(SRCHEADERS_SRC) $(SRCHEADERS_GENERIC) $(SRCHEADERS_ARM64) $(SRCHEADERS_HASWELL) $(SRCHEADERS_WESTMERE)
INCLUDEHEADERS=include/simdjson.h include/simdjson/common_defs.h include/simdjson/internal/jsonformatutils.h include/simdjson/jsonioutil.h include/simdjson/jsonminifier.h include/simdjson/jsonparser.h include/simdjson/padded_string.h include/simdjson/document.h include/simdjson/inline/document.h include/simdjson/document_iterator.h include/simdjson/inline/document_iterator.h include/simdjson/implementation.h include/simdjson/parsedjson.h include/simdjson/jsonstream.h include/simdjson/inline/jsonstream.h include/simdjson/portability.h include/simdjson/error.h include/simdjson/simdjson.h include/simdjson/simdjson_version.h

View File

@ -62,7 +62,7 @@ set(SIMDJSON_SRC_HEADERS
haswell/stage1_find_marks.h
haswell/stage2_build_tape.h
haswell/stringparsing.h
inline/document_parser_callbacks.h
document_parser_callbacks.h
westmere/bitmanipulation.h
westmere/implementation.h
westmere/intrinsics.h

View File

@ -1,8 +1,7 @@
#ifndef SIMDJSON_ARM64_BITMANIPULATION_H
#define SIMDJSON_ARM64_BITMANIPULATION_H
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64
@ -15,9 +14,10 @@ namespace simdjson::arm64 {
// but the algorithms do not end up using the returned value.
// Sadly, sanitizers are not smart enough to figure it out.
__attribute__((no_sanitize("undefined"))) // this is deliberate
#endif
#endif // _MSC_VER
/* result might be undefined when input_num is zero */
really_inline int trailing_zeroes(uint64_t input_num) {
#ifdef _MSC_VER
unsigned long ret;
// Search the mask data from least significant bit (LSB)
@ -26,8 +26,9 @@ really_inline int trailing_zeroes(uint64_t input_num) {
return (int)ret;
#else
return __builtin_ctzll(input_num);
#endif// _MSC_VER
}
#endif // _MSC_VER
} // namespace simdjson::arm64
/* result might be undefined when input_num is zero */
really_inline uint64_t clear_lowest_bit(uint64_t input_num) {
@ -54,8 +55,7 @@ really_inline int hamming(uint64_t input_num) {
return vaddv_u8(vcnt_u8((uint8x8_t)input_num));
}
really_inline bool add_overflow(uint64_t value1, uint64_t value2,
uint64_t *result) {
really_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
#ifdef _MSC_VER
// todo: this might fail under visual studio for ARM
return _addcarry_u64(0, value1, value2,
@ -70,20 +70,19 @@ really_inline bool add_overflow(uint64_t value1, uint64_t value2,
#pragma intrinsic(_umul128) // todo: this might fail under visual studio for ARM
#endif
really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
uint64_t *result) {
really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
#ifdef _MSC_VER
// todo: this might fail under visual studio for ARM
uint64_t high;
*result = _umul128(value1, value2, &high);
return high;
#else
return __builtin_umulll_overflow(value1, value2,
(unsigned long long *)result);
return __builtin_umulll_overflow(value1, value2, (unsigned long long *)result);
#endif
}
}// namespace simdjson::arm64
} // namespace simdjson::arm64
#endif //IS_ARM64
#endif // SIMDJSON_ARM64_BITMANIPULATION_H
#endif // IS_ARM64
#endif // SIMDJSON_ARM64_BITMANIPULATION_H

View File

@ -1,11 +1,10 @@
#ifndef SIMDJSON_ARM64_BITMASK_H
#define SIMDJSON_ARM64_BITMASK_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64
#include "simdjson/common_defs.h"
#include "arm64/intrinsics.h"
namespace simdjson::arm64 {

View File

@ -1,11 +1,10 @@
#ifndef __SIMDJSON_ARM64_IMPLEMENTATION_H
#define __SIMDJSON_ARM64_IMPLEMENTATION_H
#ifndef SIMDJSON_ARM64_IMPLEMENTATION_H
#define SIMDJSON_ARM64_IMPLEMENTATION_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64
#include "simdjson/implementation.h"
#include "isadetection.h"
namespace simdjson::arm64 {
@ -23,4 +22,4 @@ public:
#endif // IS_ARM64
#endif // __SIMDJSON_ARM64_IMPLEMENTATION_H
#endif // SIMDJSON_ARM64_IMPLEMENTATION_H

View File

@ -1,9 +1,13 @@
#ifndef SIMDJSON_ARM64_INTRINSICS_H
#define SIMDJSON_ARM64_INTRINSICS_H
#include <simdjson.h>
#ifdef IS_ARM64
// This should be the correct header whether
// you use visual studio or other compilers.
#include <arm_neon.h>
#endif // IS_ARM64
#endif // SIMDJSON_ARM64_INTRINSICS_H

View File

@ -1,14 +1,13 @@
#ifndef SIMDJSON_ARM64_NUMBERPARSING_H
#define SIMDJSON_ARM64_NUMBERPARSING_H
#include <simdjson.h>
#ifdef IS_ARM64
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include "jsoncharutils.h"
#include "arm64/intrinsics.h"
#include "arm64/bitmanipulation.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>

View File

@ -1,12 +1,10 @@
#ifndef SIMDJSON_ARM64_SIMD_H
#define SIMDJSON_ARM64_SIMD_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64
#include "simdjson/common_defs.h"
#include "simdjson/simdjson.h"
#include "arm64/intrinsics.h"
namespace simdjson::arm64::simd {

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_ARM64_STAGE1_FIND_MARKS_H
#define SIMDJSON_ARM64_STAGE1_FIND_MARKS_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_ARM64_STAGE2_BUILD_TAPE_H
#define SIMDJSON_ARM64_STAGE2_BUILD_TAPE_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64

View File

@ -1,14 +1,12 @@
#ifndef SIMDJSON_ARM64_STRINGPARSING_H
#define SIMDJSON_ARM64_STRINGPARSING_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_ARM64
#include "arm64/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "arm64/simd.h"
#include "arm64/intrinsics.h"
#include "arm64/bitmanipulation.h"
@ -47,4 +45,5 @@ really_inline parse_string_helper find_bs_bits_and_quote_bits(const uint8_t *src
// namespace simdjson::amd64
#endif // IS_ARM64
#endif
#endif // SIMDJSON_ARM64_STRINGPARSING_H

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_DOCUMENT_PARSER_CALLBACKS_H
#define SIMDJSON_DOCUMENT_PARSER_CALLBACKS_H
#include "simdjson/document.h"
#include <simdjson.h>
namespace simdjson {

View File

@ -1,4 +1,4 @@
#include "simdjson/error.h"
#include <simdjson.h>
#include <map>
namespace simdjson {

View File

@ -1,9 +1,10 @@
#ifndef SIMDJSON_HASWELL_BITMANIPULATION_H
#define SIMDJSON_HASWELL_BITMANIPULATION_H
#include "simdjson/common_defs.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "haswell/intrinsics.h"
TARGET_HASWELL
@ -74,5 +75,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
}
}// namespace simdjson::haswell
UNTARGET_REGION
#endif
#endif // SIMDJSON_HASWELL_BITMANIPULATION_H
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_BITMANIPULATION_H

View File

@ -1,11 +1,10 @@
#ifndef SIMDJSON_HASWELL_BITMASK_H
#define SIMDJSON_HASWELL_BITMASK_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "haswell/intrinsics.h"
TARGET_HASWELL
@ -28,4 +27,5 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
UNTARGET_REGION
#endif // IS_X86_64
#endif
#endif // SIMDJSON_HASWELL_BITMASK_H

View File

@ -1,11 +1,10 @@
#ifndef __SIMDJSON_HASWELL_IMPLEMENTATION_H
#define __SIMDJSON_HASWELL_IMPLEMENTATION_H
#ifndef SIMDJSON_HASWELL_IMPLEMENTATION_H
#define SIMDJSON_HASWELL_IMPLEMENTATION_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/implementation.h"
#include "isadetection.h"
namespace simdjson::haswell {
@ -27,4 +26,4 @@ public:
#endif // IS_X86_64
#endif // __SIMDJSON_HASWELL_IMPLEMENTATION_H
#endif // SIMDJSON_HASWELL_IMPLEMENTATION_H

View File

@ -1,12 +1,16 @@
#ifndef SIMDJSON_HASWELL_INTRINSICS_H
#define SIMDJSON_HASWELL_INTRINSICS_H
#include <simdjson.h>
#ifdef IS_X86_64
#ifdef _MSC_VER
#include <intrin.h> // visual studio
#else
#include <x86intrin.h> // elsewhere
#endif // _MSC_VER
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_INTRINSICS_H
#endif // _MSC_VER
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_INTRINSICS_H

View File

@ -1,18 +1,16 @@
#ifndef SIMDJSON_HASWELL_NUMBERPARSING_H
#define SIMDJSON_HASWELL_NUMBERPARSING_H
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include "jsoncharutils.h"
#include "haswell/intrinsics.h"
#include "haswell/bitmanipulation.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>
#ifdef JSON_TEST_NUMBERS // for unit testing
void found_invalid_number(const uint8_t *buf);
void found_integer(int64_t result, const uint8_t *buf);
@ -47,10 +45,6 @@ static inline uint32_t parse_eight_digits_unrolled(const char *chars) {
} // namespace simdjson::haswell
UNTARGET_REGION
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_NUMBERPARSING_H
#endif // SIMDJSON_HASWELL_NUMBERPARSING_H

View File

@ -1,11 +1,10 @@
#ifndef SIMDJSON_HASWELL_SIMD_H
#define SIMDJSON_HASWELL_SIMD_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "haswell/intrinsics.h"
TARGET_HASWELL
@ -313,4 +312,5 @@ namespace simdjson::haswell::simd {
UNTARGET_REGION
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_SIMD_H

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_HASWELL_STAGE1_FIND_MARKS_H
#define SIMDJSON_HASWELL_STAGE1_FIND_MARKS_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
@ -56,4 +56,5 @@ WARN_UNUSED error_code implementation::stage1(const uint8_t *buf, size_t len, do
UNTARGET_REGION
#endif // IS_X86_64
#endif // SIMDJSON_HASWELL_STAGE1_FIND_MARKS_H

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_HASWELL_STAGE2_BUILD_TAPE_H
#define SIMDJSON_HASWELL_STAGE2_BUILD_TAPE_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64

View File

@ -1,14 +1,12 @@
#ifndef SIMDJSON_HASWELL_STRINGPARSING_H
#define SIMDJSON_HASWELL_STRINGPARSING_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "haswell/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "haswell/simd.h"
#include "haswell/intrinsics.h"
#include "haswell/bitmanipulation.h"
@ -44,4 +42,4 @@ UNTARGET_REGION
#endif // IS_X86_64
#endif
#endif // SIMDJSON_HASWELL_STRINGPARSING_H

View File

@ -1,6 +1,4 @@
#include "simdjson/portability.h"
#include "isadetection.h"
#include "simdjson/implementation.h"
#include <simdjson.h>
#include <initializer_list>
// Static array of known implementations. We're hoping these get baked into the executable

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_JSONCHARUTILS_H
#define SIMDJSON_JSONCHARUTILS_H
#include "simdjson/common_defs.h"
#include <simdjson.h>
namespace simdjson {
// structural chars here are

View File

@ -1,4 +1,4 @@
#include "simdjson/jsonioutil.h"
#include <simdjson.h>
#include <cstdlib>
#include <cstring>
#include <climits>

View File

@ -1,4 +1,4 @@
#include "simdjson/portability.h"
#include <simdjson.h>
#include <cstdint>
#ifndef SIMDJSON_ISSUE384RESOLVED // to avoid tripping users

View File

@ -1,3 +1,4 @@
#include <simdjson.h>
#include "error.cpp"
#include "implementation.cpp"
#include "jsonioutil.cpp"

View File

@ -1,11 +1,8 @@
#include <simdjson.h>
#include <cassert>
#include <cstring>
#include "simdjson/portability.h"
#include "simdjson/common_defs.h"
#include "jsoncharutils.h"
#include "simdjson/inline/document.h"
#include "inline/document_parser_callbacks.h"
#include "document_parser_callbacks.h"
using namespace simdjson;

View File

@ -1,9 +1,10 @@
#ifndef SIMDJSON_WESTMERE_BITMANIPULATION_H
#define SIMDJSON_WESTMERE_BITMANIPULATION_H
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "westmere/intrinsics.h"
TARGET_WESTMERE
@ -86,5 +87,6 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
}// namespace simdjson::westmere
UNTARGET_REGION
#endif
#endif // SIMDJSON_WESTMERE_BITMANIPULATION_H
#endif // IS_X86_64
#endif // SIMDJSON_WESTMERE_BITMANIPULATION_H

View File

@ -1,11 +1,10 @@
#ifndef SIMDJSON_WESTMERE_BITMASK_H
#define SIMDJSON_WESTMERE_BITMASK_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "westmere/intrinsics.h"
TARGET_WESTMERE
@ -28,4 +27,5 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
UNTARGET_REGION
#endif // IS_X86_64
#endif
#endif // SIMDJSON_WESTMERE_BITMASK_H

View File

@ -1,7 +1,7 @@
#ifndef __SIMDJSON_WESTMERE_IMPLEMENTATION_H
#define __SIMDJSON_WESTMERE_IMPLEMENTATION_H
#ifndef SIMDJSON_WESTMERE_IMPLEMENTATION_H
#define SIMDJSON_WESTMERE_IMPLEMENTATION_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
@ -23,4 +23,4 @@ public:
#endif // IS_X86_64
#endif // __SIMDJSON_WESTMERE_IMPLEMENTATION_H
#endif // SIMDJSON_WESTMERE_IMPLEMENTATION_H

View File

@ -6,6 +6,7 @@
#include <intrin.h> // visual studio
#else
#include <x86intrin.h> // elsewhere
#endif // _MSC_VER
#endif // IS_X86_64
#endif // SIMDJSON_WESTMERE_INTRINSICS_H
#endif // _MSC_VER
#endif // IS_X86_64
#endif // SIMDJSON_WESTMERE_INTRINSICS_H

View File

@ -1,17 +1,13 @@
#ifndef SIMDJSON_WESTMERE_NUMBERPARSING_H
#define SIMDJSON_WESTMERE_NUMBERPARSING_H
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include "westmere/intrinsics.h"
#include "simdjson/common_defs.h"
#include "simdjson/portability.h"
#include "jsoncharutils.h"
#include "westmere/intrinsics.h"
#include "westmere/bitmanipulation.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include <cmath>
#include <limits>

View File

@ -1,12 +1,10 @@
#ifndef SIMDJSON_WESTMERE_SIMD_H
#define SIMDJSON_WESTMERE_SIMD_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "simdjson/common_defs.h"
#include "simdjson/simdjson.h"
#include "westmere/intrinsics.h"
TARGET_WESTMERE

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_WESTMERE_STAGE1_FIND_MARKS_H
#define SIMDJSON_WESTMERE_STAGE1_FIND_MARKS_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64

View File

@ -1,7 +1,7 @@
#ifndef SIMDJSON_WESTMERE_STAGE2_BUILD_TAPE_H
#define SIMDJSON_WESTMERE_STAGE2_BUILD_TAPE_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64

View File

@ -1,14 +1,12 @@
#ifndef SIMDJSON_WESTMERE_STRINGPARSING_H
#define SIMDJSON_WESTMERE_STRINGPARSING_H
#include "simdjson/portability.h"
#include <simdjson.h>
#ifdef IS_X86_64
#include "westmere/simd.h"
#include "simdjson/common_defs.h"
#include "simdjson/inline/document.h"
#include "jsoncharutils.h"
#include "westmere/simd.h"
#include "westmere/intrinsics.h"
#include "westmere/bitmanipulation.h"
@ -46,4 +44,4 @@ UNTARGET_REGION
#endif // IS_X86_64
#endif
#endif // SIMDJSON_WESTMERE_STRINGPARSING_H