Function multiversioning for n_string2
This commit is contained in:
@@ -396,27 +396,26 @@ inline PRESERVE_NONE WeaselJsonStatus n_string(Parser3 *self, char *buf,
|
|||||||
MUSTTAIL return Parser3::keepGoing(self, buf, bufEnd);
|
MUSTTAIL return Parser3::keepGoing(self, buf, bufEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PRESERVE_NONE WeaselJsonStatus n_string2(Parser3 *self, char *buf,
|
template <class V>
|
||||||
|
PRESERVE_NONE WeaselJsonStatus n_string2_impl(Parser3 *self, char *buf,
|
||||||
char *bufEnd) {
|
char *bufEnd) {
|
||||||
const auto before = buf;
|
const auto before = buf;
|
||||||
|
|
||||||
// Advance buf to the first "non-normal" character
|
// Advance buf to the first "non-normal" character
|
||||||
for (;;) {
|
for (;;) {
|
||||||
constexpr int kStride = 64;
|
if (bufEnd - buf < V::lanes) [[unlikely]] {
|
||||||
if (bufEnd - buf < kStride) [[unlikely]] {
|
|
||||||
while (buf != bufEnd &&
|
while (buf != bufEnd &&
|
||||||
tables.stringByteMeaning[uint8_t(*buf)] == Tables::NORMAL) {
|
tables.stringByteMeaning[uint8_t(*buf)] == Tables::NORMAL) {
|
||||||
++buf;
|
++buf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
using V = simd<int8_t, kStride>;
|
|
||||||
auto v = V{(int8_t *)buf};
|
auto v = V{(int8_t *)buf};
|
||||||
int normal =
|
int normal =
|
||||||
(v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20))
|
(v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20))
|
||||||
.count_leading_nonzero_lanes();
|
.count_leading_nonzero_lanes();
|
||||||
buf += normal;
|
buf += normal;
|
||||||
if (normal < kStride) {
|
if (normal < V::lanes) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,6 +484,24 @@ inline PRESERVE_NONE WeaselJsonStatus n_string2(Parser3 *self, char *buf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template WeaselJsonStatus
|
||||||
|
n_string2_impl<simd<int8_t, 64, sse::Simd_x86_SSE>>(Parser3 *, char *, char *);
|
||||||
|
|
||||||
|
template __attribute__((target("avx2"))) WeaselJsonStatus
|
||||||
|
n_string2_impl<simd<int8_t, 64, sse::Simd_x86_AVX2>>(Parser3 *, char *, char *);
|
||||||
|
|
||||||
|
__attribute__((target("default"))) inline PRESERVE_NONE WeaselJsonStatus
|
||||||
|
n_string2(Parser3 *self, char *buf, char *bufEnd) {
|
||||||
|
MUSTTAIL return n_string2_impl<simd<int8_t, 64, sse::Simd_x86_SSE>>(self, buf,
|
||||||
|
bufEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((target("avx2"))) inline PRESERVE_NONE WeaselJsonStatus
|
||||||
|
n_string2(Parser3 *self, char *buf, char *bufEnd) {
|
||||||
|
MUSTTAIL return n_string2_impl<simd<int8_t, 64, sse::Simd_x86_AVX2>>(
|
||||||
|
self, buf, bufEnd);
|
||||||
|
}
|
||||||
|
|
||||||
inline PRESERVE_NONE WeaselJsonStatus n_string_following_escape(Parser3 *self,
|
inline PRESERVE_NONE WeaselJsonStatus n_string_following_escape(Parser3 *self,
|
||||||
char *buf,
|
char *buf,
|
||||||
char *bufEnd) {
|
char *bufEnd) {
|
||||||
|
|||||||
Reference in New Issue
Block a user