Put anonymous namespace in front of everything

This commit is contained in:
John Keiser 2020-07-24 07:32:12 -07:00
parent 2f92a34bb7
commit 65148b123b
55 changed files with 188 additions and 41 deletions

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace arm64 {
namespace {
// We sometimes call trailing_zero on inputs that are zero,
// but the algorithms do not end up using the returned value.
@ -64,6 +65,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
#endif
}
} // namespace {
} // namespace arm64
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace arm64 {
namespace {
//
// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.

View File

@ -98,6 +98,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
return is_third_byte ^ is_fourth_byte;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson
@ -120,6 +121,7 @@ namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace stage1 {
namespace {
really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
// On ARM, we don't short-circuit this if there are no backslashes, because the branch gives us no
@ -128,6 +130,7 @@ really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
return find_escaped_branchless(backslash);
}
} // namespace {
} // namespace stage1
WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept {
@ -144,6 +147,23 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
return simdjson::arm64::stage1::generic_validate_utf8(buf,len);
}
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
error_code result = stage2::parse_structurals<false>(*this, _doc);
if (result) { return result; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return error = TAPE_ERROR;
}
return SUCCESS;
}
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::parse_structurals<true>(*this, _doc);
}
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
error_code err = stage1(_buf, _len, false);
if (err) { return err; }

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
size_t capacity,
@ -16,6 +17,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
return SUCCESS;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -6,6 +6,7 @@
namespace simdjson {
namespace arm64 {
namespace {
using namespace simdjson::dom;
@ -21,6 +22,7 @@ public:
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
};
} // namespace {
} // namespace arm64
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace arm64 {
namespace {
// we don't have SSE, so let us use a scalar function
// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
@ -14,6 +15,7 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
}
} // namespace {
} // namespace arm64
} // namespace simdjson

View File

@ -9,6 +9,7 @@
namespace simdjson {
namespace arm64 {
namespace {
namespace simd {
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
@ -494,6 +495,7 @@ really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x3, int8_
}; // struct simd8x64<T>
} // namespace simd
} // namespace {
} // namespace arm64
} // namespace simdjson

View File

@ -7,6 +7,7 @@
namespace simdjson {
namespace arm64 {
namespace {
using namespace simd;
@ -43,6 +44,7 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
};
}
} // namespace {
} // namespace arm64
} // namespace simdjson

View File

@ -6,6 +6,7 @@
namespace simdjson {
namespace fallback {
namespace {
#if defined(_MSC_VER) && !defined(_M_ARM64) && !defined(_M_X64)
static inline unsigned char _BitScanForward64(unsigned long* ret, uint64_t x) {
@ -71,6 +72,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
return value2 > 0 && value1 > std::numeric_limits<uint64_t>::max() / value2;
}
} // namespace {
} // namespace fallback
} // namespace simdjson

View File

@ -9,6 +9,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
class structural_scanner {
@ -307,6 +308,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
return true;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson
@ -320,6 +322,23 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
error_code result = stage2::parse_structurals<false>(*this, _doc);
if (result) { return result; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return error = TAPE_ERROR;
}
return SUCCESS;
}
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::parse_structurals<true>(*this, _doc);
}
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
error_code err = stage1(_buf, _len, false);
if (err) { return err; }

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
size_t capacity,
@ -16,6 +17,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
return SUCCESS;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -6,6 +6,7 @@
namespace simdjson {
namespace fallback {
namespace {
using namespace simdjson::dom;
@ -25,6 +26,7 @@ public:
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
};
} // namespace {
} // namespace fallback
} // namespace simdjson

View File

@ -10,6 +10,7 @@ void found_float(double result, const uint8_t *buf);
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
static really_inline uint32_t parse_eight_digits_unrolled(const char *chars) {
uint32_t result = 0;
for (int i=0;i<8;i++) {
@ -21,6 +22,7 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
return parse_eight_digits_unrolled((const char *)chars);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -5,6 +5,7 @@
namespace simdjson {
namespace fallback {
namespace {
// Holds backslashes and quotes locations.
struct backslash_and_quote {
@ -26,6 +27,7 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
return { src[0] };
}
} // namespace {
} // namespace fallback
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
// expectation: sizeof(scope_descriptor) = 64/8.
struct scope_descriptor {
@ -44,6 +45,7 @@ public:
WARN_UNUSED error_code set_max_depth(size_t max_depth) noexcept final;
};
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson
@ -52,6 +54,7 @@ public:
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
really_inline dom_parser_implementation::dom_parser_implementation() {}
@ -70,5 +73,6 @@ WARN_UNUSED error_code dom_parser_implementation::set_max_depth(size_t max_depth
return SUCCESS;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
namespace allocate {
@ -17,5 +18,6 @@ really_inline error_code set_capacity(internal::dom_parser_implementation &parse
} // namespace allocate
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
// Walks through a buffer in block-sized increments, loading the last part with spaces
template<size_t STEP_SIZE>
@ -85,5 +86,6 @@ really_inline void buf_block_reader<STEP_SIZE>::advance() {
idx += STEP_SIZE;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
/**
* This algorithm is used to quickly identify the last structural position that
@ -88,5 +89,6 @@ really_inline size_t trim_partial_utf8(const uint8_t *buf, size_t len) {
return len;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -5,6 +5,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
class json_minifier {
@ -77,5 +78,6 @@ error_code json_minifier::minify(const uint8_t *buf, size_t len, uint8_t *dst, s
}
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
/**
@ -104,5 +105,6 @@ really_inline error_code json_scanner::finish(bool streaming) {
}
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
struct json_string_block {
@ -139,5 +140,6 @@ really_inline error_code json_string_scanner::finish(bool streaming) {
}
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -11,6 +11,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
class bit_indexer {
@ -204,5 +205,6 @@ really_inline error_code json_structural_indexer::finish(dom_parser_implementati
}
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -180,5 +180,6 @@ struct utf8_checker {
}
}; // struct utf8_checker
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace utf8_validation {
//
// Detect Unicode errors.
@ -66,7 +68,6 @@ namespace SIMDJSON_IMPLEMENTATION {
//
using namespace simd;
namespace utf8_validation {
// For a detailed description of the lookup2 algorithm, see the file HACKING.md under "UTF-8 validation (lookup2)".
//
@ -216,7 +217,8 @@ namespace utf8_validation {
}
}; // struct utf8_checker
}
} // namespace {
} // namespace utf8_validation
using utf8_validation::utf8_checker;

View File

@ -1,5 +1,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace utf8_validation {
//
// Detect Unicode errors.
@ -66,7 +68,6 @@ namespace SIMDJSON_IMPLEMENTATION {
//
using namespace simd;
namespace utf8_validation {
// For a detailed description of the lookup2 algorithm, see the file HACKING.md under "UTF-8 validation (lookup2)".
//
@ -236,7 +237,8 @@ namespace utf8_validation {
}
}; // struct utf8_checker
}
} // namespace {
} // namespace utf8_validation
using utf8_validation::utf8_checker;

View File

@ -1,6 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace utf8_validation {
using namespace simd;
@ -174,6 +174,7 @@ using namespace simd;
}
}; // struct utf8_checker
} // namespace {
} // namespace utf8_validation
using utf8_validation::utf8_checker;

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace utf8_validation {
//
// Detect Unicode errors.
@ -66,10 +67,6 @@ namespace SIMDJSON_IMPLEMENTATION {
//
using namespace simd;
namespace utf8_validation {
} // namespace utf8_validation
struct utf8_checker {
// If this is nonzero, there has been a UTF-8 error.
simd8<uint8_t> error;
@ -301,5 +298,7 @@ struct utf8_checker {
}; // struct utf8_checker
} // namespace utf8_validation
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -182,5 +182,6 @@ struct utf8_checker {
}
}; // struct utf8_checker
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
/**
@ -27,5 +28,6 @@ bool generic_validate_utf8(const char * input, size_t length) {
}
} // namespace stage1
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -361,5 +361,6 @@ struct utf8_checker {
}
}; // struct utf8_checker
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
namespace allocate {
@ -18,5 +19,6 @@ really_inline error_code set_max_depth(dom_parser_implementation &parser, size_t
} // namespace allocate
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,9 +1,9 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
namespace atomparsing {
namespace{
// The string_to_uint32 is exclusively used to map literal strings to 32-bit values.
// We use memcpy instead of a pointer cast to avoid undefined behaviors since we cannot
// be certain that the character pointer will be properly aligned.
@ -22,7 +22,6 @@ really_inline uint32_t str4ncmp(const uint8_t *src, const char* atom) {
std::memcpy(&srcval, src, sizeof(uint32_t));
return srcval ^ string_to_uint32(atom);
}
} // anonymous namespace
WARN_UNUSED
really_inline bool is_valid_true_atom(const uint8_t *src) {
@ -62,5 +61,6 @@ really_inline bool is_valid_null_atom(const uint8_t *src, size_t len) {
} // namespace atomparsing
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
// return non-zero if not a structural or whitespace char
@ -115,5 +116,6 @@ really_inline value128 full_multiplication(uint64_t value1, uint64_t value2) {
}
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -2,7 +2,9 @@
// Set LOG_ENABLED = true to log what stage 2 is doing!
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace logger {
static constexpr const char * DASHES = "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
static constexpr const bool LOG_ENABLED = false;
@ -62,6 +64,8 @@ namespace logger {
printf("|\n");
}
}
} // namespace logger
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
namespace numberparsing {
@ -504,5 +505,6 @@ really_inline bool parse_number(const uint8_t *const src, W &writer) {
} // namespace numberparsing
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
namespace stringparsing {
@ -121,5 +122,6 @@ WARN_UNUSED really_inline uint8_t *parse_string(const uint8_t *src, uint8_t *dst
} // namespace stringparsing
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
class structural_iterator {
@ -46,5 +47,6 @@ public:
};
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -10,9 +10,8 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace stage2 {
namespace { // Make everything here private
namespace stage2 {
#ifdef SIMDJSON_USE_COMPUTED_GOTO
#define INIT_ADDRESSES() { &&array_begin, &&array_continue, &&error, &&finish, &&object_begin, &&object_continue }
@ -468,33 +467,7 @@ error:
return parser.error();
}
} // namespace {}
} // namespace stage2
/************
* The JSON is parsed to a tape, see the accompanying tape.md file
* for documentation.
***********/
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
error_code result = stage2::parse_structurals<false>(*this, _doc);
if (result) { return result; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return error = TAPE_ERROR;
}
return SUCCESS;
}
/************
* The JSON is parsed to a tape, see the accompanying tape.md file
* for documentation.
***********/
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::parse_structurals<true>(*this, _doc);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -1,5 +1,6 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage2 {
struct tape_writer {
@ -99,5 +100,6 @@ really_inline void tape_writer::write(uint64_t &tape_loc, uint64_t val, internal
}
} // namespace stage2
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
// We sometimes call trailing_zero on inputs that are zero,
// but the algorithms do not end up using the returned value.
@ -68,6 +69,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
#endif
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
//
// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
@ -17,6 +18,7 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
return _mm_cvtsi128_si64(result);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -8,6 +8,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
using namespace simd;
@ -64,6 +65,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
return simd8<int8_t>(is_third_byte | is_fourth_byte) > int8_t(0);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson
@ -83,7 +85,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
//
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
@ -92,6 +94,7 @@ really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
}
} // namespace stage1
} // namespace {
WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept {
return haswell::stage1::json_minifier::minify<128>(buf, len, dst, dst_len);
@ -107,6 +110,23 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
return simdjson::haswell::stage1::generic_validate_utf8(buf,len);
}
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
error_code result = stage2::parse_structurals<false>(*this, _doc);
if (result) { return result; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return error = TAPE_ERROR;
}
return SUCCESS;
}
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::parse_structurals<true>(*this, _doc);
}
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
error_code err = stage1(_buf, _len, false);
if (err) { return err; }

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
size_t capacity,
@ -16,6 +17,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
return SUCCESS;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -7,6 +7,7 @@
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_REGION
namespace simdjson {
namespace haswell {
namespace {
class implementation final : public simdjson::implementation {
public:
@ -24,6 +25,7 @@ public:
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
};
} // namespace {
} // namespace haswell
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
// this actually computes *16* values so we are being wasteful.
@ -22,6 +23,7 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
t4); // only captures the sum of the first 8 digits, drop the rest
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -5,6 +5,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace simd {
// Forward-declared so they can be used by splat and friends.
@ -346,6 +347,7 @@ namespace simd {
}
}; // struct simd8x64<T>
} // namespace {
} // namespace simd
} // namespace SIMDJSON_IMPLEMENTATION

View File

@ -7,6 +7,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
using namespace simd;
@ -38,6 +39,7 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
};
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
// We sometimes call trailing_zero on inputs that are zero,
// but the algorithms do not end up using the returned value.
@ -77,6 +78,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
#endif
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
//
// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
@ -17,6 +18,7 @@ really_inline uint64_t prefix_xor(const uint64_t bitmask) {
return _mm_cvtsi128_si64(result);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -8,6 +8,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
using namespace simd;
@ -69,6 +70,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
return simd8<int8_t>(is_third_byte | is_fourth_byte) > int8_t(0);
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson
@ -89,6 +91,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace stage1 {
really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
@ -97,6 +100,7 @@ really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
}
} // namespace stage1
} // namespace {
WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept {
return westmere::stage1::json_minifier::minify<64>(buf, len, dst, dst_len);
@ -112,6 +116,23 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
return simdjson::westmere::stage1::generic_validate_utf8(buf,len);
}
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
error_code result = stage2::parse_structurals<false>(*this, _doc);
if (result) { return result; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return error = TAPE_ERROR;
}
return SUCCESS;
}
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::parse_structurals<true>(*this, _doc);
}
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
error_code err = stage1(_buf, _len, false);
if (err) { return err; }

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
size_t capacity,
@ -16,6 +17,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
return SUCCESS;
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -8,6 +8,7 @@
// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_REGION
namespace simdjson {
namespace westmere {
namespace {
using namespace simdjson::dom;
@ -23,6 +24,7 @@ public:
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
};
} // namespace {
} // namespace westmere
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
// this actually computes *16* values so we are being wasteful.
@ -22,6 +23,7 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
t4); // only captures the sum of the first 8 digits, drop the rest
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -5,6 +5,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
namespace simd {
template<typename Child>
@ -327,6 +328,7 @@ namespace simd {
}; // struct simd8x64<T>
} // namespace simd
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson

View File

@ -3,6 +3,7 @@
namespace simdjson {
namespace SIMDJSON_IMPLEMENTATION {
namespace {
using namespace simd;
@ -36,6 +37,7 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
};
}
} // namespace {
} // namespace SIMDJSON_IMPLEMENTATION
} // namespace simdjson