Skip to content

Commit 77c59e7

Browse files
committed
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
1 parent 156fe7b commit 77c59e7

File tree

8 files changed

+221
-193
lines changed

8 files changed

+221
-193
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/jsoncheck
1515
/jsonpointer
1616
/jsonstats
17+
/integer_tests
1718
/libsimdjson.so*
1819
/minify
1920
/numberparsingcheck

src/arm64/simd_input.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ struct simd_input<Architecture::ARM64> {
5757
}
5858

5959
template <typename F>
60-
really_inline void each(F const& each_chunk)
61-
{
60+
really_inline void each(F const& each_chunk) const {
6261
each_chunk(this->chunks[0]);
6362
each_chunk(this->chunks[1]);
6463
each_chunk(this->chunks[2]);
6564
each_chunk(this->chunks[3]);
6665
}
6766

6867
template <typename F>
69-
really_inline simd_input<Architecture::ARM64> map(F const& map_chunk) {
68+
really_inline simd_input<Architecture::ARM64> map(F const& map_chunk) const {
7069
return simd_input<Architecture::ARM64>(
7170
map_chunk(this->chunks[0]),
7271
map_chunk(this->chunks[1]),
@@ -76,7 +75,7 @@ struct simd_input<Architecture::ARM64> {
7675
}
7776

7877
template <typename F>
79-
really_inline simd_input<Architecture::ARM64> map(simd_input<Architecture::ARM64> b, F const& map_chunk) {
78+
really_inline simd_input<Architecture::ARM64> map(simd_input<Architecture::ARM64> b, F const& map_chunk) const {
8079
return simd_input<Architecture::ARM64>(
8180
map_chunk(this->chunks[0], b.chunks[0]),
8281
map_chunk(this->chunks[1], b.chunks[1]),
@@ -86,24 +85,31 @@ struct simd_input<Architecture::ARM64> {
8685
}
8786

8887
template <typename F>
89-
really_inline uint8x16_t reduce(F const& reduce_pair) {
88+
really_inline uint8x16_t reduce(F const& reduce_pair) const {
9089
uint8x16_t r01 = reduce_pair(this->chunks[0], this->chunks[1]);
9190
uint8x16_t r23 = reduce_pair(this->chunks[2], this->chunks[3]);
9291
return reduce_pair(r01, r23);
9392
}
9493

95-
really_inline uint64_t to_bitmask() {
94+
really_inline uint64_t to_bitmask() const {
9695
return neon_movemask_bulk(this->chunks[0], this->chunks[1], this->chunks[2], this->chunks[3]);
9796
}
9897

99-
really_inline uint64_t eq(uint8_t m) {
98+
really_inline simd_input<Architecture::ARM64> bit_or(const uint8_t m) const {
99+
const uint8x16_t mask = vmovq_n_u8(m);
100+
return this->map( [&](auto a) {
101+
return vorrq_u8(a, mask);
102+
});
103+
}
104+
105+
really_inline uint64_t eq(const uint8_t m) const {
100106
const uint8x16_t mask = vmovq_n_u8(m);
101107
return this->map( [&](auto a) {
102108
return vceqq_u8(a, mask);
103109
}).to_bitmask();
104110
}
105111

106-
really_inline uint64_t lteq(uint8_t m) {
112+
really_inline uint64_t lteq(const uint8_t m) const {
107113
const uint8x16_t mask = vmovq_n_u8(m);
108114
return this->map( [&](auto a) {
109115
return vcleq_u8(a, mask);

src/arm64/stage1_find_marks.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace simdjson::arm64 {
1414

15-
really_inline uint64_t compute_quote_mask(uint64_t quote_bits) {
15+
really_inline uint64_t compute_quote_mask(const uint64_t quote_bits) {
1616

1717
#ifdef __ARM_FEATURE_CRYPTO // some ARM processors lack this extension
1818
return vmull_p64(-1ULL, quote_bits);
@@ -21,9 +21,9 @@ really_inline uint64_t compute_quote_mask(uint64_t quote_bits) {
2121
#endif
2222
}
2323

24-
really_inline void find_whitespace_and_structurals(
25-
simd_input<ARCHITECTURE> in, uint64_t &whitespace,
26-
uint64_t &structurals) {
24+
really_inline void find_whitespace_and_operators(
25+
const simd_input<ARCHITECTURE> in,
26+
uint64_t &whitespace, uint64_t &op) {
2727
const uint8x16_t low_nibble_mask =
2828
(uint8x16_t){16, 0, 0, 0, 0, 0, 0, 0, 0, 8, 12, 1, 2, 9, 0, 0};
2929
const uint8x16_t high_nibble_mask =
@@ -38,9 +38,9 @@ really_inline void find_whitespace_and_structurals(
3838
return vandq_u8(shuf_lo, shuf_hi);
3939
});
4040

41-
const uint8x16_t structural_shufti_mask = vmovq_n_u8(0x7);
42-
structurals = v.map([&](auto _v) {
43-
return vtstq_u8(_v, structural_shufti_mask);
41+
const uint8x16_t operator_shufti_mask = vmovq_n_u8(0x7);
42+
op = v.map([&](auto _v) {
43+
return vtstq_u8(_v, operator_shufti_mask);
4444
}).to_bitmask();
4545

4646
const uint8x16_t whitespace_shufti_mask = vmovq_n_u8(0x18);

0 commit comments

Comments
 (0)