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);
|
||||
}
|
||||
|
||||
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) {
|
||||
const auto before = buf;
|
||||
|
||||
// Advance buf to the first "non-normal" character
|
||||
for (;;) {
|
||||
constexpr int kStride = 64;
|
||||
if (bufEnd - buf < kStride) [[unlikely]] {
|
||||
if (bufEnd - buf < V::lanes) [[unlikely]] {
|
||||
while (buf != bufEnd &&
|
||||
tables.stringByteMeaning[uint8_t(*buf)] == Tables::NORMAL) {
|
||||
++buf;
|
||||
}
|
||||
break;
|
||||
}
|
||||
using V = simd<int8_t, kStride>;
|
||||
auto v = V{(int8_t *)buf};
|
||||
int normal =
|
||||
(v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20))
|
||||
.count_leading_nonzero_lanes();
|
||||
buf += normal;
|
||||
if (normal < kStride) {
|
||||
if (normal < V::lanes) {
|
||||
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,
|
||||
char *buf,
|
||||
char *bufEnd) {
|
||||
|
||||
Reference in New Issue
Block a user