mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
raise the limit of strings in double shufti
This commit is contained in:
parent
c0a5b037a1
commit
ed3ef5b997
@ -207,17 +207,14 @@ void buildAccelDouble(const AccelInfo &info, AccelAux *aux) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outs1 + outs2 <= 8) {
|
if (outs1 < outs2 && outs1 <= 2) { // Heuristic from UE-438.
|
||||||
if (outs1 < outs2 && outs1 <= 2) { // Heuristic from UE-438.
|
DEBUG_PRINTF("building double-shufti for %zu one-byte and %zu"
|
||||||
DEBUG_PRINTF("building double-shufti for %zu one-byte and %zu"
|
" two-byte literals\n", outs1, outs2);
|
||||||
" two-byte literals\n", outs1, outs2);
|
aux->accel_type = ACCEL_DSHUFTI;
|
||||||
aux->accel_type = ACCEL_DSHUFTI;
|
aux->dshufti.offset = offset;
|
||||||
aux->dshufti.offset = offset;
|
if (shuftiBuildDoubleMasks(info.double_stop1, info.double_stop2,
|
||||||
shuftiBuildDoubleMasks(info.double_stop1, info.double_stop2,
|
&aux->dshufti.lo1, &aux->dshufti.hi1,
|
||||||
&aux->dshufti.lo1,
|
&aux->dshufti.lo2, &aux->dshufti.hi2)) {
|
||||||
&aux->dshufti.hi1,
|
|
||||||
&aux->dshufti.lo2,
|
|
||||||
&aux->dshufti.hi2);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,6 @@ mstate_aux *getAux(NFA *n, dstate_id_t i) {
|
|||||||
static
|
static
|
||||||
bool double_byte_ok(const escape_info &info) {
|
bool double_byte_ok(const escape_info &info) {
|
||||||
return !info.outs2_broken
|
return !info.outs2_broken
|
||||||
&& info.outs2_single.count() + info.outs2.size() <= 8
|
|
||||||
&& info.outs2_single.count() < info.outs2.size()
|
&& info.outs2_single.count() < info.outs2.size()
|
||||||
&& info.outs2_single.count() <= 2 && !info.outs2.empty();
|
&& info.outs2_single.count() <= 2 && !info.outs2.empty();
|
||||||
}
|
}
|
||||||
@ -256,14 +255,12 @@ void mcclellan_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (double_byte_ok(info)) {
|
if (double_byte_ok(info)
|
||||||
|
&& shuftiBuildDoubleMasks(info.outs2_single, info.outs2,
|
||||||
|
&accel->dshufti.lo1, &accel->dshufti.hi1,
|
||||||
|
&accel->dshufti.lo2, &accel->dshufti.hi2)) {
|
||||||
accel->accel_type = ACCEL_DSHUFTI;
|
accel->accel_type = ACCEL_DSHUFTI;
|
||||||
accel->dshufti.offset = verify_u8(info.outs2_offset);
|
accel->dshufti.offset = verify_u8(info.outs2_offset);
|
||||||
shuftiBuildDoubleMasks(info.outs2_single, info.outs2,
|
|
||||||
&accel->dshufti.lo1,
|
|
||||||
&accel->dshufti.hi1,
|
|
||||||
&accel->dshufti.lo2,
|
|
||||||
&accel->dshufti.hi2);
|
|
||||||
DEBUG_PRINTF("state %hu is double shufti\n", this_idx);
|
DEBUG_PRINTF("state %hu is double shufti\n", this_idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,6 @@ map<dstate_id_t, escape_info> populateAccelerationInfo(const raw_dfa &rdfa,
|
|||||||
static
|
static
|
||||||
bool double_byte_ok(const escape_info &info) {
|
bool double_byte_ok(const escape_info &info) {
|
||||||
return !info.outs2_broken
|
return !info.outs2_broken
|
||||||
&& info.outs2_single.count() + info.outs2.size() <= 8
|
|
||||||
&& info.outs2_single.count() < info.outs2.size()
|
&& info.outs2_single.count() < info.outs2.size()
|
||||||
&& info.outs2_single.count() <= 2 && !info.outs2.empty();
|
&& info.outs2_single.count() <= 2 && !info.outs2.empty();
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ AccelScheme make_double_accel(AccelScheme as, CharReach cr_1,
|
|||||||
return as;
|
return as;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (two_count > 8) {
|
if (two_count > DOUBLE_SHUFTI_LIMIT) {
|
||||||
if (cr_2.count() < cr_1.count()) {
|
if (cr_2.count() < cr_1.count()) {
|
||||||
as.double_cr |= cr_2;
|
as.double_cr |= cr_2;
|
||||||
offset = offset_in + 1;
|
offset = offset_in + 1;
|
||||||
@ -513,7 +513,7 @@ AccelScheme findBestAccelScheme(vector<vector<CharReach> > paths,
|
|||||||
best.offset = offset;
|
best.offset = offset;
|
||||||
|
|
||||||
/* merge best single and best double */
|
/* merge best single and best double */
|
||||||
if (!da.double_byte.empty() && da.double_byte.size() <= 8
|
if (!da.double_byte.empty() && da.double_byte.size() <= DOUBLE_SHUFTI_LIMIT
|
||||||
&& da.double_cr.count() < best.cr.count()) {
|
&& da.double_cr.count() < best.cr.count()) {
|
||||||
best.double_byte = da.double_byte;
|
best.double_byte = da.double_byte;
|
||||||
best.double_cr = da.double_cr;
|
best.double_cr = da.double_cr;
|
||||||
@ -857,7 +857,8 @@ depth_done:
|
|||||||
// literals)
|
// literals)
|
||||||
if (depth > 1) {
|
if (depth > 1) {
|
||||||
for (unsigned int i = 0; i < (depth - 1); i++) {
|
for (unsigned int i = 0; i < (depth - 1); i++) {
|
||||||
if (depthReach[i].count()*depthReach[i+1].count() <= 8) {
|
if (depthReach[i].count() * depthReach[i+1].count()
|
||||||
|
<= DOUBLE_SHUFTI_LIMIT) {
|
||||||
DEBUG_PRINTF("two-byte shufti, depth %u\n", i);
|
DEBUG_PRINTF("two-byte shufti, depth %u\n", i);
|
||||||
*as = AccelScheme(CharReach::dot(), i);
|
*as = AccelScheme(CharReach::dot(), i);
|
||||||
return true;
|
return true;
|
||||||
|
@ -63,6 +63,8 @@ void findAccelFriends(const NGHolder &g, NFAVertex v,
|
|||||||
u32 offset,
|
u32 offset,
|
||||||
ue2::flat_set<NFAVertex> *friends);
|
ue2::flat_set<NFAVertex> *friends);
|
||||||
|
|
||||||
|
#define DOUBLE_SHUFTI_LIMIT 20
|
||||||
|
|
||||||
struct AccelScheme {
|
struct AccelScheme {
|
||||||
AccelScheme(const CharReach &cr_in, u32 offset_in)
|
AccelScheme(const CharReach &cr_in, u32 offset_in)
|
||||||
: cr(cr_in), offset(offset_in) {
|
: cr(cr_in), offset(offset_in) {
|
||||||
@ -78,10 +80,10 @@ struct AccelScheme {
|
|||||||
size_t a_dcount = double_cr.count();
|
size_t a_dcount = double_cr.count();
|
||||||
size_t b_dcount = b.double_cr.count();
|
size_t b_dcount = b.double_cr.count();
|
||||||
|
|
||||||
bool feasible_double_a
|
bool feasible_double_a = !a.double_byte.empty()
|
||||||
= !a.double_byte.empty() && a.double_byte.size() <= 8;
|
&& a.double_byte.size() <= DOUBLE_SHUFTI_LIMIT;
|
||||||
bool feasible_double_b
|
bool feasible_double_b = !b.double_byte.empty()
|
||||||
= !b.double_byte.empty() && b.double_byte.size() <= 8;
|
&& b.double_byte.size() <= DOUBLE_SHUFTI_LIMIT;
|
||||||
|
|
||||||
if (feasible_double_a != feasible_double_b) {
|
if (feasible_double_a != feasible_double_b) {
|
||||||
return feasible_double_a > feasible_double_b;
|
return feasible_double_a > feasible_double_b;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user