mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Check if any tugs are alive when compressing/expanding repeats
This commit is contained in:
parent
8f8ba2d591
commit
e717525194
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -1803,6 +1803,12 @@ struct Factory {
|
||||
assert(cyclic != NO_STATE);
|
||||
maskSetBit(limex->repeatCyclicMask, cyclic);
|
||||
}
|
||||
/* also include tugs in repeat cyclic mask */
|
||||
for (NFAVertex v : args.tugs) {
|
||||
u32 v_state = args.state_ids.at(v);
|
||||
assert(v_state != NO_STATE);
|
||||
maskSetBit(limex->repeatCyclicMask, v_state);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -151,7 +151,7 @@ struct LimExNFA##size { \
|
||||
* followers */ \
|
||||
u_##size compressMask; /**< switch off before compress */ \
|
||||
u_##size exceptionMask; \
|
||||
u_##size repeatCyclicMask; \
|
||||
u_##size repeatCyclicMask; /**< also includes tug states */ \
|
||||
u_##size zombieMask; /**< zombie if in any of the set states */ \
|
||||
u_##size shift[MAX_SHIFT_COUNT]; \
|
||||
u32 shiftCount; /**< number of shift masks used */ \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -393,19 +393,16 @@ void COMPRESS_REPEATS_FN(const IMPL_NFA_T *limex, void *dest, void *src,
|
||||
DEBUG_PRINTF("repeat %u\n", i);
|
||||
const struct NFARepeatInfo *info = GET_NFA_REPEAT_INFO_FN(limex, i);
|
||||
|
||||
if (!TESTBIT_STATE(s, info->cyclicState)) {
|
||||
const ENG_STATE_T *tug_mask =
|
||||
(const ENG_STATE_T *)((const char *)info + info->tugMaskOffset);
|
||||
/* repeat may still be inspected if its tug state is on */
|
||||
if (!TESTBIT_STATE(s, info->cyclicState)
|
||||
&& ISZERO_STATE(AND_STATE(s, LOAD_FROM_ENG(tug_mask)))) {
|
||||
DEBUG_PRINTF("is dead\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
const struct RepeatInfo *repeat = getRepeatInfo(info);
|
||||
if (repeatHasMatch(repeat, &ctrl[i], state_base + info->stateOffset,
|
||||
offset) == REPEAT_STALE) {
|
||||
DEBUG_PRINTF("is stale, clearing state\n");
|
||||
CLEARBIT_STATE(&s, info->cyclicState);
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("packing state (packedCtrlOffset=%u)\n",
|
||||
info->packedCtrlOffset);
|
||||
repeatPack(state_base + info->packedCtrlOffset, repeat, &ctrl[i],
|
||||
@ -448,8 +445,11 @@ void EXPAND_REPEATS_FN(const IMPL_NFA_T *limex, void *dest, const void *src,
|
||||
for (u32 i = 0; i < limex->repeatCount; i++) {
|
||||
DEBUG_PRINTF("repeat %u\n", i);
|
||||
const struct NFARepeatInfo *info = GET_NFA_REPEAT_INFO_FN(limex, i);
|
||||
const ENG_STATE_T *tug_mask =
|
||||
(const ENG_STATE_T *)((const char *)info + info->tugMaskOffset);
|
||||
|
||||
if (!TESTBIT_STATE(cyclics, info->cyclicState)) {
|
||||
if (!TESTBIT_STATE(cyclics, info->cyclicState)
|
||||
&& ISZERO_STATE(AND_STATE(cyclics, LOAD_FROM_ENG(tug_mask)))) {
|
||||
DEBUG_PRINTF("is dead\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -177,6 +177,10 @@ u64a repeatLastTopRange(const union RepeatControl *ctrl, const void *state) {
|
||||
|
||||
u64a repeatLastTopBitmap(const union RepeatControl *ctrl) {
|
||||
const struct RepeatBitmapControl *xs = &ctrl->bitmap;
|
||||
if (!xs->bitmap) {
|
||||
/* last top was too long ago */
|
||||
return 0;
|
||||
}
|
||||
return xs->offset + 63 - clz64(xs->bitmap);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user