Skip to content

Commit 4e944a9

Browse files
committed
Eliminate unused functions in fallback
1 parent c7fa9b5 commit 4e944a9

12 files changed

+37
-82
lines changed

src/arm64/bitmanipulation.h

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ really_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
5555
#endif
5656
}
5757

58+
#if 0 // Currently unused
5859
really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
5960
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
6061
*result = value1 * value2;
@@ -63,6 +64,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
6364
return __builtin_umulll_overflow(value1, value2, (unsigned long long *)result);
6465
#endif
6566
}
67+
#endif // Currently unused
6668

6769
} // namespace arm64
6870
} // namespace {

src/arm64/dom_parser_implementation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ really_inline bool is_ascii(const simd8x64<uint8_t>& input) {
8080
return bits.max() < 0b10000000u;
8181
}
8282

83-
really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
83+
UNUSED really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
8484
simd8<bool> is_second_byte = prev1 >= uint8_t(0b11000000u);
8585
simd8<bool> is_third_byte = prev2 >= uint8_t(0b11100000u);
8686
simd8<bool> is_fourth_byte = prev3 >= uint8_t(0b11110000u);

src/fallback/bitmanipulation.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ static unsigned char _BitScanReverse64(unsigned long* ret, uint64_t x) {
2424
}
2525
#endif
2626

27-
// We sometimes call trailing_zero on inputs that are zero,
28-
// but the algorithms do not end up using the returned value.
29-
// Sadly, sanitizers are not smart enough to figure it out.
27+
//
28+
// These are currently unused, but one day will be.
29+
//
30+
#if 0 // Currently unused
3031
NO_SANITIZE_UNDEFINED
3132
really_inline int trailing_zeroes(uint64_t input_num) {
3233
#ifdef _MSC_VER
@@ -44,6 +45,7 @@ really_inline int trailing_zeroes(uint64_t input_num) {
4445
really_inline uint64_t clear_lowest_bit(uint64_t input_num) {
4546
return input_num & (input_num-1);
4647
}
48+
#endif // Currently unused
4749

4850
/* result might be undefined when input_num is zero */
4951
really_inline int leading_zeroes(uint64_t input_num) {
@@ -60,6 +62,7 @@ really_inline int leading_zeroes(uint64_t input_num) {
6062
#endif// _MSC_VER
6163
}
6264

65+
#if 0 // Currently unused
6366
really_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
6467
*result = value1 + value2;
6568
return *result < value1;
@@ -70,6 +73,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
7073
// TODO there must be a faster way
7174
return value2 > 0 && value1 > std::numeric_limits<uint64_t>::max() / value2;
7275
}
76+
#endif // Currently unused
7377

7478
} // namespace fallback
7579
} // namespace {

src/generic/stage1/find_next_document_index.h

-21
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,5 @@ really_inline uint32_t find_next_document_index(dom_parser_implementation &parse
6767
return 0;
6868
}
6969

70-
// Skip the last character if it is partial
71-
really_inline size_t trim_partial_utf8(const uint8_t *buf, size_t len) {
72-
if (unlikely(len < 3)) {
73-
switch (len) {
74-
case 2:
75-
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
76-
if (buf[len-2] >= 0b11100000) { return len-2; } // 3- and 4-byte characters with only 2 bytes left
77-
return len;
78-
case 1:
79-
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
80-
return len;
81-
case 0:
82-
return len;
83-
}
84-
}
85-
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
86-
if (buf[len-2] >= 0b11100000) { return len-2; } // 3- and 4-byte characters with only 1 byte left
87-
if (buf[len-3] >= 0b11110000) { return len-3; } // 4-byte characters with only 3 bytes left
88-
return len;
89-
}
90-
9170
} // namespace SIMDJSON_IMPLEMENTATION
9271
} // namespace {

src/generic/stage1/json_scanner.h

-13
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,6 @@ really_inline uint64_t follows(const uint64_t match, uint64_t &overflow) {
7575
return result;
7676
}
7777

78-
//
79-
// Check if the current character follows a matching character, with possible "filler" between.
80-
// For example, this checks for empty curly braces, e.g.
81-
//
82-
// in.eq('}') & follows(in.eq('['), in.eq(' '), prev_empty_array) // { <whitespace>* }
83-
//
84-
really_inline uint64_t follows(const uint64_t match, const uint64_t filler, uint64_t &overflow) {
85-
uint64_t follows_match = follows(match, overflow);
86-
uint64_t result;
87-
overflow |= uint64_t(add_overflow(follows_match, filler, &result));
88-
return result;
89-
}
90-
9178
really_inline json_block json_scanner::next(const simd::simd8x64<uint8_t>& in) {
9279
json_string_block strings = string_scanner.next(in);
9380
json_character_block characters = json_character_block::classify(in);

src/generic/stage1/json_structural_indexer.h

+21
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ class json_structural_indexer {
9191

9292
really_inline json_structural_indexer::json_structural_indexer(uint32_t *structural_indexes) : indexer{structural_indexes} {}
9393

94+
// Skip the last character if it is partial
95+
really_inline size_t trim_partial_utf8(const uint8_t *buf, size_t len) {
96+
if (unlikely(len < 3)) {
97+
switch (len) {
98+
case 2:
99+
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
100+
if (buf[len-2] >= 0b11100000) { return len-2; } // 3- and 4-byte characters with only 2 bytes left
101+
return len;
102+
case 1:
103+
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
104+
return len;
105+
case 0:
106+
return len;
107+
}
108+
}
109+
if (buf[len-1] >= 0b11000000) { return len-1; } // 2-, 3- and 4-byte characters with only 1 byte left
110+
if (buf[len-2] >= 0b11100000) { return len-2; } // 3- and 4-byte characters with only 1 byte left
111+
if (buf[len-3] >= 0b11110000) { return len-3; } // 4-byte characters with only 3 bytes left
112+
return len;
113+
}
114+
94115
//
95116
// PERF NOTES:
96117
// We pipe 2 inputs through these stages:

src/generic/stage2/jsoncharutils.h

-10
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ namespace {
22
namespace SIMDJSON_IMPLEMENTATION {
33
namespace stage2 {
44

5-
// return non-zero if not a structural or whitespace char
6-
// zero otherwise
7-
really_inline uint32_t is_not_structural_or_whitespace_or_null(uint8_t c) {
8-
return structural_or_whitespace_or_null_negated[c];
9-
}
10-
115
// return non-zero if not a structural or whitespace char
126
// zero otherwise
137
really_inline uint32_t is_not_structural_or_whitespace(uint8_t c) {
148
return structural_or_whitespace_negated[c];
159
}
1610

17-
really_inline uint32_t is_structural_or_whitespace_or_null(uint8_t c) {
18-
return structural_or_whitespace_or_null[c];
19-
}
20-
2111
really_inline uint32_t is_structural_or_whitespace(uint8_t c) {
2212
return structural_or_whitespace[c];
2313
}

src/haswell/bitmanipulation.h

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ really_inline bool add_overflow(uint64_t value1, uint64_t value2,
5353
#endif
5454
}
5555

56+
#if 0 // Currently unused
5657
#if defined(SIMDJSON_REGULAR_VISUAL_STUDIO) || defined(SIMDJSON_IS_32BITS)
5758
#pragma intrinsic(_umul128)
5859
#endif
@@ -67,6 +68,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
6768
(unsigned long long *)result);
6869
#endif
6970
}
71+
#endif // Currently unused
7072

7173
} // namespace SIMDJSON_IMPLEMENTATION
7274
} // namespace {

src/haswell/dom_parser_implementation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ really_inline bool is_ascii(const simd8x64<uint8_t>& input) {
4949
return input.reduce_or().is_ascii();
5050
}
5151

52-
really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
52+
UNUSED really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
5353
simd8<uint8_t> is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0
5454
simd8<uint8_t> is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0
5555
simd8<uint8_t> is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0

src/jsoncharutils_tables.h

-32
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,6 @@ namespace simdjson {
1515
// we are also interested in the four whitespace characters
1616
// space 0x20, linefeed 0x0a, horizontal tab 0x09 and carriage return 0x0d
1717

18-
// these are the chars that can follow a true/false/null or number atom
19-
// and nothing else
20-
const uint32_t structural_or_whitespace_or_null_negated[256] = {
21-
0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
22-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
23-
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,
24-
25-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
26-
1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
27-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
28-
29-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
30-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
31-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
32-
33-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
34-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
35-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
36-
3718
const uint32_t structural_or_whitespace_negated[256] = {
3819
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
3920
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -51,19 +32,6 @@ const uint32_t structural_or_whitespace_negated[256] = {
5132
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5233
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
5334

54-
const uint32_t structural_or_whitespace_or_null[256] = {
55-
1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56-
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
57-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,
59-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60-
0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
64-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
65-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
66-
6735
const uint32_t structural_or_whitespace[256] = {
6836
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6937
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,

src/westmere/bitmanipulation.h

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ really_inline bool add_overflow(uint64_t value1, uint64_t value2,
6262
#endif
6363
}
6464

65+
#if 0 // Currently unused
6566
#if defined(SIMDJSON_REGULAR_VISUAL_STUDIO) || defined(SIMDJSON_IS_32BITS)
6667
#pragma intrinsic(_umul128)
6768
#endif
@@ -76,6 +77,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2,
7677
(unsigned long long *)result);
7778
#endif
7879
}
80+
#endif // Currently unused
7981

8082
} // namespace SIMDJSON_IMPLEMENTATION
8183
} // namespace {

src/westmere/dom_parser_implementation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ really_inline bool is_ascii(const simd8x64<uint8_t>& input) {
5454
return input.reduce_or().is_ascii();
5555
}
5656

57-
really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
57+
UNUSED really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
5858
simd8<uint8_t> is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0
5959
simd8<uint8_t> is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0
6060
simd8<uint8_t> is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0

0 commit comments

Comments
 (0)