mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Rose: remove alignment req for anchored DFA state
This commit is contained in:
parent
060defe6c4
commit
28f379d738
@ -1020,34 +1020,36 @@ void nfaExecMcClellan8_SimpStream(const struct NFA *nfa, char *state,
|
||||
const u8 *buf, char top, size_t start_off,
|
||||
size_t len, NfaCallback cb, void *ctxt) {
|
||||
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(nfa);
|
||||
if (top) {
|
||||
*(u8 *)state = m->start_anchored;
|
||||
}
|
||||
|
||||
u8 s = top ? m->start_anchored : *(u8 *)state;
|
||||
|
||||
if (m->flags & MCCLELLAN_FLAG_SINGLE) {
|
||||
mcclellanExec8_i(m, (u8 *)state, buf + start_off, len - start_off,
|
||||
mcclellanExec8_i(m, &s, buf + start_off, len - start_off,
|
||||
start_off, cb, ctxt, 1, NULL, CALLBACK_OUTPUT);
|
||||
} else {
|
||||
mcclellanExec8_i(m, (u8 *)state, buf + start_off, len - start_off,
|
||||
mcclellanExec8_i(m, &s, buf + start_off, len - start_off,
|
||||
start_off, cb, ctxt, 0, NULL, CALLBACK_OUTPUT);
|
||||
}
|
||||
|
||||
*(u8 *)state = s;
|
||||
}
|
||||
|
||||
void nfaExecMcClellan16_SimpStream(const struct NFA *nfa, char *state,
|
||||
const u8 *buf, char top, size_t start_off,
|
||||
size_t len, NfaCallback cb, void *ctxt) {
|
||||
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(nfa);
|
||||
if (top) {
|
||||
*(u16 *)state = m->start_anchored;
|
||||
}
|
||||
|
||||
u16 s = top ? m->start_anchored : unaligned_load_u16(state);
|
||||
|
||||
if (m->flags & MCCLELLAN_FLAG_SINGLE) {
|
||||
mcclellanExec16_i(m, (u16 *)state, buf + start_off, len - start_off,
|
||||
mcclellanExec16_i(m, &s, buf + start_off, len - start_off,
|
||||
start_off, cb, ctxt, 1, NULL, CALLBACK_OUTPUT);
|
||||
} else {
|
||||
mcclellanExec16_i(m, (u16 *)state, buf + start_off, len - start_off,
|
||||
mcclellanExec16_i(m, &s, buf + start_off, len - start_off,
|
||||
start_off, cb, ctxt, 0, NULL, CALLBACK_OUTPUT);
|
||||
}
|
||||
|
||||
unaligned_store_u16(state, s);
|
||||
}
|
||||
|
||||
char nfaExecMcClellan8_testEOD(const struct NFA *nfa, const char *state,
|
||||
|
@ -228,7 +228,7 @@ u32 anchoredStateSize(const anchored_matcher_info &atable) {
|
||||
}
|
||||
|
||||
const NFA *nfa = (const NFA *)((const char *)curr + sizeof(*curr));
|
||||
return curr->state_offset + nfa->scratchStateSize;
|
||||
return curr->state_offset + nfa->streamStateSize;
|
||||
}
|
||||
|
||||
bool anchoredIsMulti(const anchored_matcher_info &atable) {
|
||||
@ -849,15 +849,8 @@ buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize) {
|
||||
ami->next_offset = verify_u32(curr - prev_curr);
|
||||
}
|
||||
|
||||
// State must be aligned.
|
||||
u32 align_req = state_alignment(*nfa);
|
||||
assert(align_req <= 2); // only DFAs.
|
||||
while (state_offset % align_req) {
|
||||
state_offset++;
|
||||
}
|
||||
|
||||
ami->state_offset = state_offset;
|
||||
state_offset += nfa->scratchStateSize;
|
||||
state_offset += nfa->streamStateSize;
|
||||
ami->anchoredMinDistance = start_offset[i];
|
||||
}
|
||||
|
||||
|
@ -582,11 +582,6 @@ void fillStateOffsets(const RoseBuildImpl &tbi, u32 rolesWithStateCount,
|
||||
so->leftfixLagTable = curr_offset;
|
||||
curr_offset += laggedRoseCount;
|
||||
|
||||
// Anchored state is McClellan full state, and needs to be 2-byte aligned.
|
||||
// We potentially waste a byte here.
|
||||
if (curr_offset % 2) {
|
||||
curr_offset++;
|
||||
}
|
||||
so->anchorState = curr_offset;
|
||||
curr_offset += anchorStateSize;
|
||||
|
||||
|
@ -74,7 +74,7 @@ void runAnchoredTableStream(const struct RoseEngine *t, const void *atable,
|
||||
goto next_nfa;
|
||||
}
|
||||
} else {
|
||||
if (!*(u16 *)state) {
|
||||
if (!unaligned_load_u16(state)) {
|
||||
goto next_nfa;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user