static really_really_inline
hwlm_error_t single_zscan(const struct noodTable *n,const u8 *d, const u8 *buf,
- Z_TYPE z, size_t len, const struct cb_info *cbi) {
- while (unlikely(z)) {
- Z_TYPE pos = JOIN(findAndClearLSB_, Z_BITS)(&z);
+ Z_TYPE *z, size_t len, const struct cb_info *cbi) {
+ while (unlikely(*z)) {
+ Z_TYPE pos = JOIN(findAndClearLSB_, Z_BITS)(z);
size_t matchPos = d - buf + pos;
DEBUG_PRINTF("match pos %zu\n", matchPos);
hwlmcb_rv_t rv = final(n, buf, len, 1, cbi, matchPos);
static really_really_inline
hwlm_error_t double_zscan(const struct noodTable *n,const u8 *d, const u8 *buf,
- Z_TYPE z, size_t len, const struct cb_info *cbi) {
- while (unlikely(z)) {
- Z_TYPE pos = JOIN(findAndClearLSB_, Z_BITS)(&z);
+ Z_TYPE *z, size_t len, const struct cb_info *cbi) {
+ while (unlikely(*z)) {
+ Z_TYPE pos = JOIN(findAndClearLSB_, Z_BITS)(z);
size_t matchPos = d - buf + pos - 1; \
DEBUG_PRINTF("match pos %zu\n", matchPos);
hwlmcb_rv_t rv = final(n, buf, len, 0, cbi, matchPos);
hwlm_error_t rv;
if (end - offset <= CHUNKSIZE) {
- rv = scanSingleUnaligned(n, buf, len, offset, caseMask, mask1,
+ return scanSingleUnaligned(n, buf, len, offset, caseMask, mask1,
cbi, offset, end);
- return rv;
}
uintptr_t data = (uintptr_t)buf;
uintptr_t s2Start = ROUNDUP_N(data + offset, CHUNKSIZE) - data;
- uintptr_t last = data + end;
- uintptr_t s2End = ROUNDDOWN_N(last, CHUNKSIZE) - data;
- uintptr_t s3Start = end - CHUNKSIZE;
if (offset != s2Start) {
// first scan out to the fast scan starting point
cbi, offset, s2Start);
RETURN_IF_TERMINATED(rv);
}
+ uintptr_t last = data + end;
+ uintptr_t s2End = ROUNDDOWN_N(last, CHUNKSIZE) - data;
if (likely(s2Start != s2End)) {
// scan as far as we can, bounded by the last point this key can
}
DEBUG_PRINTF("stage 3: %zu -> %zu\n", s2End, len);
- rv = scanSingleUnaligned(n, buf, len, s3Start, caseMask, mask1, cbi,
+ rv = scanSingleUnaligned(n, buf, len, s2End, caseMask, mask1, cbi,
s2End, len);
return rv;
// the first place the key can match
size_t offset = start + n->msk_len - n->key_offset;
-
hwlm_error_t rv;
if (end - offset <= CHUNKSIZE) {
uintptr_t data = (uintptr_t)buf;
uintptr_t s2Start = ROUNDUP_N(data + offset, CHUNKSIZE) - data;
uintptr_t s1End = s2Start + 1;
- uintptr_t last = data + end;
- uintptr_t s2End = ROUNDDOWN_N(last, CHUNKSIZE) - data;
- uintptr_t s3Start = end - CHUNKSIZE;
uintptr_t off = offset;
if (s2Start != off) {
RETURN_IF_TERMINATED(rv);
}
off = s1End;
+ uintptr_t last = data + end;
+ uintptr_t s2End = ROUNDDOWN_N(last, CHUNKSIZE) - data;
+ uintptr_t s3Start = end - CHUNKSIZE;
if (s2Start >= end) {
DEBUG_PRINTF("s2 == mL %zu\n", end);
u32 z = mask & movemask128(eq128(mask1, v));
DEBUG_PRINTF("mask 0x%08x z 0x%08x\n", mask, z);
- return single_zscan(n, d, buf, z, len, cbi);
+ return single_zscan(n, d, buf, &z, len, cbi);
}
static really_inline
// mask out where we can't match
u32 mask = ((1 << l) - 1) << buf_off;
- u32 z = mask & movemask128(and128(lshiftbyte_m128(eq128(mask1, v), 1),
- eq128(mask2, v)));
+ u32 z = mask & movemask128(and128(lshiftbyte_m128(eq128(mask1, v), 1), eq128(mask2, v)));
DEBUG_PRINTF("mask 0x%08x z 0x%08x\n", mask, z);
- return double_zscan(n, d, buf, z, len, cbi);
+ return double_zscan(n, d, buf, &z, len, cbi);
}
static really_inline
const u8 *d = buf + start, *e = buf + end;
assert(d < e);
+ const u8 *base = ROUNDDOWN_PTR(d, 64);
for (; d < e; d += 16) {
m128 v = and128(load128(d), caseMask);
u32 z = movemask128(eq128(mask1, v));
// On large packet buffers, this prefetch appears to get us about 2%.
- __builtin_prefetch(ROUNDDOWN_PTR(d + 128, 64));
+ __builtin_prefetch(base + 128);
DEBUG_PRINTF("z 0x%08x\n", z);
- hwlm_error_t result = single_zscan(n, d, buf, z, len, cbi);
+ hwlm_error_t result = single_zscan(n, d, buf, &z, len, cbi);
if (unlikely(result != HWLM_SUCCESS))
return result;
}
assert(d < e);
m128 lastz1 = zeroes128();
+ const u8 *base = ROUNDDOWN_PTR(d, 64);
for (; d < e; d += 16) {
m128 v = and128(load128(d), caseMask);
m128 z1 = eq128(mask1, v);
lastz1 = z1;
// On large packet buffers, this prefetch appears to get us about 2%.
- __builtin_prefetch(ROUNDDOWN_PTR(d + 128, 64));
+ __builtin_prefetch(base + 128);
DEBUG_PRINTF("z 0x%08x\n", z);
- hwlm_error_t result = double_zscan(n, d, buf, z, len, cbi);
+ hwlm_error_t result = double_zscan(n, d, buf, &z, len, cbi);
if (unlikely(result != HWLM_SUCCESS))
return result;