mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Merge pull request #259 from gtsoul-tech/bug/cppcheckErrors
Bug/cppcheck errors (32,35) WIP
This commit is contained in:
commit
2921e50ecc
@ -63,12 +63,10 @@ static void run_benchmarks(int size, int loops, int max_matches,
|
|||||||
InitFunc &&init, BenchFunc &&func) {
|
InitFunc &&init, BenchFunc &&func) {
|
||||||
init(bench);
|
init(bench);
|
||||||
double total_sec = 0.0;
|
double total_sec = 0.0;
|
||||||
u64a total_size = 0;
|
|
||||||
double bw = 0.0;
|
|
||||||
double avg_bw = 0.0;
|
|
||||||
double max_bw = 0.0;
|
double max_bw = 0.0;
|
||||||
double avg_time = 0.0;
|
double avg_time = 0.0;
|
||||||
if (max_matches) {
|
if (max_matches) {
|
||||||
|
double avg_bw = 0.0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (int j = 0; j < max_matches - 1; j++) {
|
for (int j = 0; j < max_matches - 1; j++) {
|
||||||
bench.buf[pos] = 'b';
|
bench.buf[pos] = 'b';
|
||||||
@ -90,7 +88,7 @@ static void run_benchmarks(int size, int loops, int max_matches,
|
|||||||
total_sec += dt;
|
total_sec += dt;
|
||||||
/*convert microseconds to seconds*/
|
/*convert microseconds to seconds*/
|
||||||
/*calculate bandwidth*/
|
/*calculate bandwidth*/
|
||||||
bw = (actual_size / dt) * 1000000.0 / 1048576.0;
|
double bw = (actual_size / dt) * 1000000.0 / 1048576.0;
|
||||||
/*std::cout << "act_size = " << act_size << std::endl;
|
/*std::cout << "act_size = " << act_size << std::endl;
|
||||||
std::cout << "dt = " << dt << std::endl;
|
std::cout << "dt = " << dt << std::endl;
|
||||||
std::cout << "bw = " << bw << std::endl;*/
|
std::cout << "bw = " << bw << std::endl;*/
|
||||||
@ -107,6 +105,7 @@ static void run_benchmarks(int size, int loops, int max_matches,
|
|||||||
printf("%-18s, %-12d, %-10d, %-6d, %-10.3f, %-9.3f, %-8.3f, %-7.3f\n",
|
printf("%-18s, %-12d, %-10d, %-6d, %-10.3f, %-9.3f, %-8.3f, %-7.3f\n",
|
||||||
bench.label, max_matches, size ,loops, total_sec, avg_time, max_bw, avg_bw);
|
bench.label, max_matches, size ,loops, total_sec, avg_time, max_bw, avg_bw);
|
||||||
} else {
|
} else {
|
||||||
|
u64a total_size = 0;
|
||||||
auto start = std::chrono::steady_clock::now();
|
auto start = std::chrono::steady_clock::now();
|
||||||
for (int i = 0; i < loops; i++) {
|
for (int i = 0; i < loops; i++) {
|
||||||
const u8 *res = func(bench);
|
const u8 *res = func(bench);
|
||||||
|
@ -605,8 +605,9 @@ double eval_set(Benchmark &bench, Sigdata &sigs, unsigned int mode,
|
|||||||
scan_time = measure_stream_time(bench, repeatCount);
|
scan_time = measure_stream_time(bench, repeatCount);
|
||||||
}
|
}
|
||||||
size_t bytes = bench.bytes();
|
size_t bytes = bench.bytes();
|
||||||
size_t matches = bench.matches();
|
|
||||||
if (diagnose) {
|
if (diagnose) {
|
||||||
|
size_t matches = bench.matches();
|
||||||
std::ios::fmtflags f(cout.flags());
|
std::ios::fmtflags f(cout.flags());
|
||||||
cout << "Scan time " << std::fixed << std::setprecision(3) << scan_time
|
cout << "Scan time " << std::fixed << std::setprecision(3) << scan_time
|
||||||
<< " sec, Scanned " << bytes * repeatCount << " bytes, Throughput "
|
<< " sec, Scanned " << bytes * repeatCount << " bytes, Throughput "
|
||||||
|
@ -542,14 +542,13 @@ u32 crc32c_sb8_64_bit(u32 running_crc, const unsigned char* p_buf,
|
|||||||
|
|
||||||
// Main aligned loop, processes eight bytes at a time.
|
// Main aligned loop, processes eight bytes at a time.
|
||||||
|
|
||||||
u32 term1, term2;
|
|
||||||
for (size_t li = 0; li < running_length/8; li++) {
|
for (size_t li = 0; li < running_length/8; li++) {
|
||||||
u32 block = *(const u32 *)p_buf;
|
u32 block = *(const u32 *)p_buf;
|
||||||
crc ^= block;
|
crc ^= block;
|
||||||
p_buf += 4;
|
p_buf += 4;
|
||||||
term1 = crc_tableil8_o88[crc & 0x000000FF] ^
|
u32 term1 = crc_tableil8_o88[crc & 0x000000FF] ^
|
||||||
crc_tableil8_o80[(crc >> 8) & 0x000000FF];
|
crc_tableil8_o80[(crc >> 8) & 0x000000FF];
|
||||||
term2 = crc >> 16;
|
u32 term2 = crc >> 16;
|
||||||
crc = term1 ^
|
crc = term1 ^
|
||||||
crc_tableil8_o72[term2 & 0x000000FF] ^
|
crc_tableil8_o72[term2 & 0x000000FF] ^
|
||||||
crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
|
crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
|
||||||
|
@ -489,7 +489,6 @@ char castleMatchLoop(const struct Castle *c, const u64a begin, const u64a end,
|
|||||||
// full_state (scratch).
|
// full_state (scratch).
|
||||||
|
|
||||||
u64a offset = end; // min offset of next match
|
u64a offset = end; // min offset of next match
|
||||||
u32 activeIdx = 0;
|
|
||||||
mmbit_clear(matching, c->numRepeats);
|
mmbit_clear(matching, c->numRepeats);
|
||||||
if (c->exclusive) {
|
if (c->exclusive) {
|
||||||
u8 *active = (u8 *)stream_state;
|
u8 *active = (u8 *)stream_state;
|
||||||
@ -497,7 +496,7 @@ char castleMatchLoop(const struct Castle *c, const u64a begin, const u64a end,
|
|||||||
for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
|
for (u32 i = mmbit_iterate(groups, c->numGroups, MMB_INVALID);
|
||||||
i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
|
i != MMB_INVALID; i = mmbit_iterate(groups, c->numGroups, i)) {
|
||||||
u8 *cur = active + i * c->activeIdxSize;
|
u8 *cur = active + i * c->activeIdxSize;
|
||||||
activeIdx = partial_load_u32(cur, c->activeIdxSize);
|
u32 activeIdx = partial_load_u32(cur, c->activeIdxSize);
|
||||||
u64a match = subCastleNextMatch(c, full_state, stream_state,
|
u64a match = subCastleNextMatch(c, full_state, stream_state,
|
||||||
loc, activeIdx);
|
loc, activeIdx);
|
||||||
set_matching(c, match, groups, matching, c->numGroups, i,
|
set_matching(c, match, groups, matching, c->numGroups, i,
|
||||||
|
@ -94,9 +94,6 @@ u32 repeatRecurTable(struct RepeatStateInfo *info, const depth &repeatMax,
|
|||||||
static
|
static
|
||||||
u32 findOptimalPatchSize(struct RepeatStateInfo *info, const depth &repeatMax,
|
u32 findOptimalPatchSize(struct RepeatStateInfo *info, const depth &repeatMax,
|
||||||
const u32 minPeriod, u32 rv) {
|
const u32 minPeriod, u32 rv) {
|
||||||
u32 cnt = 0;
|
|
||||||
u32 patch_bits = 0;
|
|
||||||
u32 total_size = 0;
|
|
||||||
u32 min = ~0U;
|
u32 min = ~0U;
|
||||||
u32 patch_len = 0;
|
u32 patch_len = 0;
|
||||||
|
|
||||||
@ -105,11 +102,11 @@ u32 findOptimalPatchSize(struct RepeatStateInfo *info, const depth &repeatMax,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = minPeriod; i <= rv; i++) {
|
for (u32 i = minPeriod; i <= rv; i++) {
|
||||||
cnt = ((u32)repeatMax + (i - 1)) / i + 1;
|
u32 cnt = ((u32)repeatMax + (i - 1)) / i + 1;
|
||||||
|
|
||||||
// no bit packing version
|
// no bit packing version
|
||||||
patch_bits = calcPackedBits(info->table[i]);
|
u32 patch_bits = calcPackedBits(info->table[i]);
|
||||||
total_size = (patch_bits + 7U) / 8U * cnt;
|
u32 total_size = (patch_bits + 7U) / 8U * cnt;
|
||||||
|
|
||||||
if (total_size < min) {
|
if (total_size < min) {
|
||||||
patch_len = i;
|
patch_len = i;
|
||||||
|
@ -513,12 +513,12 @@ static
|
|||||||
bool doHaig(const NGHolder &g, som_type som,
|
bool doHaig(const NGHolder &g, som_type som,
|
||||||
const vector<vector<CharReach>> &triggers, bool unordered_som,
|
const vector<vector<CharReach>> &triggers, bool unordered_som,
|
||||||
raw_som_dfa *rdfa) {
|
raw_som_dfa *rdfa) {
|
||||||
u32 state_limit = HAIG_FINAL_DFA_STATE_LIMIT; /* haig never backs down from
|
|
||||||
a fight */
|
|
||||||
using StateSet = typename Auto::StateSet;
|
using StateSet = typename Auto::StateSet;
|
||||||
vector<StateSet> nfa_state_map;
|
vector<StateSet> nfa_state_map;
|
||||||
Auto n(g, som, triggers, unordered_som);
|
Auto n(g, som, triggers, unordered_som);
|
||||||
try {
|
try {
|
||||||
|
u32 state_limit = HAIG_FINAL_DFA_STATE_LIMIT; /* haig never backs down from
|
||||||
|
a fight */
|
||||||
if (!determinise(n, rdfa->states, state_limit, &nfa_state_map)) {
|
if (!determinise(n, rdfa->states, state_limit, &nfa_state_map)) {
|
||||||
DEBUG_PRINTF("state limit exceeded\n");
|
DEBUG_PRINTF("state limit exceeded\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -636,12 +636,12 @@ bool reversePathReachSubset(const NFAEdge &e, const NFAVertex &dom,
|
|||||||
|
|
||||||
NFAVertex start = source(e, g);
|
NFAVertex start = source(e, g);
|
||||||
using RevGraph = boost::reverse_graph<NGHolder, const NGHolder &>;
|
using RevGraph = boost::reverse_graph<NGHolder, const NGHolder &>;
|
||||||
map<RevGraph::vertex_descriptor, boost::default_color_type> vertexColor;
|
|
||||||
|
|
||||||
// Walk the graph backwards from v, examining each node. We fail (return
|
// Walk the graph backwards from v, examining each node. We fail (return
|
||||||
// false) if we encounter a node with reach NOT a subset of domReach, and
|
// false) if we encounter a node with reach NOT a subset of domReach, and
|
||||||
// we stop searching at dom.
|
// we stop searching at dom.
|
||||||
try {
|
try {
|
||||||
|
map<RevGraph::vertex_descriptor, boost::default_color_type> vertexColor;
|
||||||
depth_first_visit(RevGraph(g), start,
|
depth_first_visit(RevGraph(g), start,
|
||||||
ReachSubsetVisitor(domReach),
|
ReachSubsetVisitor(domReach),
|
||||||
make_assoc_property_map(vertexColor),
|
make_assoc_property_map(vertexColor),
|
||||||
@ -664,12 +664,12 @@ bool forwardPathReachSubset(const NFAEdge &e, const NFAVertex &dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NFAVertex start = target(e, g);
|
NFAVertex start = target(e, g);
|
||||||
map<NFAVertex, boost::default_color_type> vertexColor;
|
|
||||||
|
|
||||||
// Walk the graph forward from v, examining each node. We fail (return
|
// Walk the graph forward from v, examining each node. We fail (return
|
||||||
// false) if we encounter a node with reach NOT a subset of domReach, and
|
// false) if we encounter a node with reach NOT a subset of domReach, and
|
||||||
// we stop searching at dom.
|
// we stop searching at dom.
|
||||||
try {
|
try {
|
||||||
|
map<NFAVertex, boost::default_color_type> vertexColor;
|
||||||
depth_first_visit(g, start, ReachSubsetVisitor(domReach),
|
depth_first_visit(g, start, ReachSubsetVisitor(domReach),
|
||||||
make_assoc_property_map(vertexColor),
|
make_assoc_property_map(vertexColor),
|
||||||
VertexIs<NGHolder, NFAVertex>(dom));
|
VertexIs<NGHolder, NFAVertex>(dom));
|
||||||
|
@ -348,10 +348,9 @@ void getSimpleRoseLiterals(const NGHolder &g, bool seeking_anchored,
|
|||||||
|
|
||||||
map<NFAVertex, u64a> scores;
|
map<NFAVertex, u64a> scores;
|
||||||
map<NFAVertex, unique_ptr<VertLitInfo>> lit_info;
|
map<NFAVertex, unique_ptr<VertLitInfo>> lit_info;
|
||||||
set<ue2_literal> s;
|
|
||||||
|
|
||||||
for (auto v : a_dom) {
|
for (auto v : a_dom) {
|
||||||
s = getLiteralSet(g, v, true); /* RHS will take responsibility for any
|
set<ue2_literal> s = getLiteralSet(g, v, true); /* RHS will take responsibility for any
|
||||||
revisits to the target vertex */
|
revisits to the target vertex */
|
||||||
|
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
@ -2868,7 +2867,6 @@ static
|
|||||||
bool splitForImplementability(RoseInGraph &vg, NGHolder &h,
|
bool splitForImplementability(RoseInGraph &vg, NGHolder &h,
|
||||||
const vector<RoseInEdge> &edges,
|
const vector<RoseInEdge> &edges,
|
||||||
const CompileContext &cc) {
|
const CompileContext &cc) {
|
||||||
vector<pair<ue2_literal, u32>> succ_lits;
|
|
||||||
DEBUG_PRINTF("trying to split %s with %zu vertices on %zu edges\n",
|
DEBUG_PRINTF("trying to split %s with %zu vertices on %zu edges\n",
|
||||||
to_string(h.kind).c_str(), num_vertices(h), edges.size());
|
to_string(h.kind).c_str(), num_vertices(h), edges.size());
|
||||||
|
|
||||||
@ -2877,6 +2875,7 @@ bool splitForImplementability(RoseInGraph &vg, NGHolder &h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!generates_callbacks(h)) {
|
if (!generates_callbacks(h)) {
|
||||||
|
vector<pair<ue2_literal, u32>> succ_lits;
|
||||||
for (const auto &e : edges) {
|
for (const auto &e : edges) {
|
||||||
const auto &lit = vg[target(e, vg)].s;
|
const auto &lit = vg[target(e, vg)].s;
|
||||||
u32 delay = vg[e].graph_lag;
|
u32 delay = vg[e].graph_lag;
|
||||||
@ -2889,8 +2888,8 @@ bool splitForImplementability(RoseInGraph &vg, NGHolder &h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<VertLitInfo> split;
|
unique_ptr<VertLitInfo> split;
|
||||||
bool last_chance = true;
|
|
||||||
if (h.kind == NFA_PREFIX) {
|
if (h.kind == NFA_PREFIX) {
|
||||||
|
bool last_chance = true;
|
||||||
auto depths = calcDepths(h);
|
auto depths = calcDepths(h);
|
||||||
|
|
||||||
split = findBestPrefixSplit(h, depths, vg, edges, last_chance, cc);
|
split = findBestPrefixSplit(h, depths, vg, edges, last_chance, cc);
|
||||||
|
@ -109,20 +109,20 @@ void ComponentAlternation::append(unique_ptr<Component> component) {
|
|||||||
vector<PositionInfo> ComponentAlternation::first() const {
|
vector<PositionInfo> ComponentAlternation::first() const {
|
||||||
// firsts come from all our subcomponents in position order. This will
|
// firsts come from all our subcomponents in position order. This will
|
||||||
// maintain left-to-right priority order.
|
// maintain left-to-right priority order.
|
||||||
vector<PositionInfo> firsts, subfirsts;
|
vector<PositionInfo> firsts;
|
||||||
|
|
||||||
for (const auto &c : children) {
|
for (const auto &c : children) {
|
||||||
subfirsts = c->first();
|
vector<PositionInfo> subfirsts = c->first();
|
||||||
firsts.insert(firsts.end(), subfirsts.begin(), subfirsts.end());
|
firsts.insert(firsts.end(), subfirsts.begin(), subfirsts.end());
|
||||||
}
|
}
|
||||||
return firsts;
|
return firsts;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<PositionInfo> ComponentAlternation::last() const {
|
vector<PositionInfo> ComponentAlternation::last() const {
|
||||||
vector<PositionInfo> lasts, sublasts;
|
vector<PositionInfo> lasts;
|
||||||
|
|
||||||
for (const auto &c : children) {
|
for (const auto &c : children) {
|
||||||
sublasts = c->last();
|
vector<PositionInfo> sublasts = c->last();
|
||||||
lasts.insert(lasts.end(), sublasts.begin(), sublasts.end());
|
lasts.insert(lasts.end(), sublasts.begin(), sublasts.end());
|
||||||
}
|
}
|
||||||
return lasts;
|
return lasts;
|
||||||
|
@ -157,10 +157,10 @@ void ComponentSequence::finalize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<PositionInfo> ComponentSequence::first() const {
|
vector<PositionInfo> ComponentSequence::first() const {
|
||||||
vector<PositionInfo> firsts, subfirsts;
|
vector<PositionInfo> firsts;
|
||||||
|
|
||||||
for (const auto &c : children) {
|
for (const auto &c : children) {
|
||||||
subfirsts = c->first();
|
vector<PositionInfo> subfirsts = c->first();
|
||||||
replaceEpsilons(firsts, subfirsts);
|
replaceEpsilons(firsts, subfirsts);
|
||||||
if (!c->empty()) {
|
if (!c->empty()) {
|
||||||
break;
|
break;
|
||||||
@ -229,12 +229,12 @@ void applyEpsilonVisits(vector<PositionInfo> &lasts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<PositionInfo> ComponentSequence::last() const {
|
vector<PositionInfo> ComponentSequence::last() const {
|
||||||
vector<PositionInfo> lasts, sublasts;
|
vector<PositionInfo> lasts;
|
||||||
vector<eps_info> visits(1);
|
vector<eps_info> visits(1);
|
||||||
|
|
||||||
auto i = children.rbegin(), e = children.rend();
|
auto i = children.rbegin(), e = children.rend();
|
||||||
for (; i != e; ++i) {
|
for (; i != e; ++i) {
|
||||||
sublasts = (*i)->last();
|
vector<PositionInfo> sublasts = (*i)->last();
|
||||||
applyEpsilonVisits(sublasts, visits);
|
applyEpsilonVisits(sublasts, visits);
|
||||||
lasts.insert(lasts.end(), sublasts.begin(), sublasts.end());
|
lasts.insert(lasts.end(), sublasts.begin(), sublasts.end());
|
||||||
if ((*i)->empty()) {
|
if ((*i)->empty()) {
|
||||||
|
@ -260,14 +260,14 @@ void ParsedLogical::parseLogicalCombination(unsigned id, const char *logical,
|
|||||||
u32 ekey, u64a min_offset,
|
u32 ekey, u64a min_offset,
|
||||||
u64a max_offset) {
|
u64a max_offset) {
|
||||||
u32 ckey = getCombKey(id);
|
u32 ckey = getCombKey(id);
|
||||||
vector<LogicalOperator> op_stack;
|
|
||||||
vector<u32> subid_stack;
|
vector<u32> subid_stack;
|
||||||
u32 lkey_start = INVALID_LKEY; // logical operation's lkey
|
u32 lkey_start = INVALID_LKEY; // logical operation's lkey
|
||||||
u32 paren = 0; // parentheses
|
|
||||||
u32 digit = (u32)-1; // digit start offset, invalid offset is -1
|
u32 digit = (u32)-1; // digit start offset, invalid offset is -1
|
||||||
u32 subid = (u32)-1;
|
u32 subid = (u32)-1;
|
||||||
u32 i;
|
u32 i;
|
||||||
try {
|
try {
|
||||||
|
vector<LogicalOperator> op_stack;
|
||||||
|
u32 paren = 0; // parentheses
|
||||||
for (i = 0; logical[i]; i++) {
|
for (i = 0; logical[i]; i++) {
|
||||||
if (isdigit(logical[i])) {
|
if (isdigit(logical[i])) {
|
||||||
if (digit == (u32)-1) { // new digit start
|
if (digit == (u32)-1) { // new digit start
|
||||||
|
@ -393,8 +393,9 @@ bool validateTransientMask(const vector<CharReach> &mask, bool anchored,
|
|||||||
none_of(begin(lits), end(lits), mixed_sensitivity));
|
none_of(begin(lits), end(lits), mixed_sensitivity));
|
||||||
|
|
||||||
// Build the HWLM literal mask.
|
// Build the HWLM literal mask.
|
||||||
vector<u8> msk, cmp;
|
vector<u8> msk;
|
||||||
if (grey.roseHamsterMasks) {
|
if (grey.roseHamsterMasks) {
|
||||||
|
vector<u8> cmp;
|
||||||
buildLiteralMask(mask, msk, cmp, delay);
|
buildLiteralMask(mask, msk, cmp, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2251,10 +2251,9 @@ vector<u32> buildSuffixEkeyLists(const RoseBuildImpl &build, build_context &bc,
|
|||||||
|
|
||||||
/* for each outfix also build elists */
|
/* for each outfix also build elists */
|
||||||
for (const auto &outfix : build.outfixes) {
|
for (const auto &outfix : build.outfixes) {
|
||||||
u32 qi = outfix.get_queue();
|
|
||||||
set<u32> ekeys = reportsToEkeys(all_reports(outfix), build.rm);
|
set<u32> ekeys = reportsToEkeys(all_reports(outfix), build.rm);
|
||||||
|
|
||||||
if (!ekeys.empty()) {
|
if (!ekeys.empty()) {
|
||||||
|
u32 qi = outfix.get_queue();
|
||||||
qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()};
|
qi_to_ekeys[qi] = {ekeys.begin(), ekeys.end()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1004,9 +1004,9 @@ bool hasOrphanedTops(const RoseBuildImpl &build) {
|
|||||||
|
|
||||||
for (auto v : vertices_range(g)) {
|
for (auto v : vertices_range(g)) {
|
||||||
if (g[v].left) {
|
if (g[v].left) {
|
||||||
set<u32> &tops = leftfixes[g[v].left];
|
|
||||||
if (!build.isRootSuccessor(v)) {
|
if (!build.isRootSuccessor(v)) {
|
||||||
// Tops for infixes come from the in-edges.
|
// Tops for infixes come from the in-edges.
|
||||||
|
set<u32> &tops = leftfixes[g[v].left];
|
||||||
for (const auto &e : in_edges_range(v, g)) {
|
for (const auto &e : in_edges_range(v, g)) {
|
||||||
tops.insert(g[e].rose_top);
|
tops.insert(g[e].rose_top);
|
||||||
}
|
}
|
||||||
|
@ -155,13 +155,13 @@ u32 compress32_impl_c(u32 x, u32 m) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 mk, mp, mv, t;
|
u32 mk, mv;
|
||||||
|
|
||||||
x &= m; // clear irrelevant bits
|
x &= m; // clear irrelevant bits
|
||||||
|
|
||||||
mk = ~m << 1; // we will count 0's to right
|
mk = ~m << 1; // we will count 0's to right
|
||||||
for (u32 i = 0; i < 5; i++) {
|
for (u32 i = 0; i < 5; i++) {
|
||||||
mp = mk ^ (mk << 1);
|
u32 mp = mk ^ (mk << 1);
|
||||||
mp ^= mp << 2;
|
mp ^= mp << 2;
|
||||||
mp ^= mp << 4;
|
mp ^= mp << 4;
|
||||||
mp ^= mp << 8;
|
mp ^= mp << 8;
|
||||||
@ -169,7 +169,7 @@ u32 compress32_impl_c(u32 x, u32 m) {
|
|||||||
|
|
||||||
mv = mp & m; // bits to move
|
mv = mp & m; // bits to move
|
||||||
m = (m ^ mv) | (mv >> (1 << i)); // compress m
|
m = (m ^ mv) | (mv >> (1 << i)); // compress m
|
||||||
t = x & mv;
|
u32 t = x & mv;
|
||||||
x = (x ^ t) | (t >> (1 << i)); // compress x
|
x = (x ^ t) | (t >> (1 << i)); // compress x
|
||||||
mk = mk & ~mp;
|
mk = mk & ~mp;
|
||||||
}
|
}
|
||||||
@ -239,14 +239,14 @@ u32 expand32_impl_c(u32 x, u32 m) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 m0, mk, mp, mv, t;
|
u32 m0, mk, mv;
|
||||||
u32 array[5];
|
u32 array[5];
|
||||||
|
|
||||||
m0 = m; // save original mask
|
m0 = m; // save original mask
|
||||||
mk = ~m << 1; // we will count 0's to right
|
mk = ~m << 1; // we will count 0's to right
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
mp = mk ^ (mk << 1); // parallel suffix
|
u32 mp = mk ^ (mk << 1); // parallel suffix
|
||||||
mp = mp ^ (mp << 2);
|
mp = mp ^ (mp << 2);
|
||||||
mp = mp ^ (mp << 4);
|
mp = mp ^ (mp << 4);
|
||||||
mp = mp ^ (mp << 8);
|
mp = mp ^ (mp << 8);
|
||||||
@ -259,7 +259,7 @@ u32 expand32_impl_c(u32 x, u32 m) {
|
|||||||
|
|
||||||
for (int i = 4; i >= 0; i--) {
|
for (int i = 4; i >= 0; i--) {
|
||||||
mv = array[i];
|
mv = array[i];
|
||||||
t = x << (1 << i);
|
u32 t = x << (1 << i);
|
||||||
x = (x & ~mv) | (t & mv);
|
x = (x & ~mv) | (t & mv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ u64a pdep64_impl_c(u64a x, u64a _m) {
|
|||||||
u64a result = 0x0UL;
|
u64a result = 0x0UL;
|
||||||
const u64a mask = 0x8000000000000000UL;
|
const u64a mask = 0x8000000000000000UL;
|
||||||
u64a m = _m;
|
u64a m = _m;
|
||||||
u64a c, t;
|
|
||||||
u64a p;
|
u64a p;
|
||||||
|
|
||||||
/* The pop-count of the mask gives the number of the bits from
|
/* The pop-count of the mask gives the number of the bits from
|
||||||
@ -421,8 +421,8 @@ u64a pdep64_impl_c(u64a x, u64a _m) {
|
|||||||
each mask bit as it is processed. */
|
each mask bit as it is processed. */
|
||||||
while (m != 0)
|
while (m != 0)
|
||||||
{
|
{
|
||||||
c = __builtin_clzl (m);
|
u64a c = __builtin_clzl (m);
|
||||||
t = x << (p - c);
|
u64a t = x << (p - c);
|
||||||
m ^= (mask >> c);
|
m ^= (mask >> c);
|
||||||
result |= (t & (mask >> c));
|
result |= (t & (mask >> c));
|
||||||
p++;
|
p++;
|
||||||
|
@ -178,9 +178,9 @@ size_t describeClassInt(ostream &os, const CharReach &incr, size_t maxLength,
|
|||||||
|
|
||||||
// Render charclass as a series of ranges
|
// Render charclass as a series of ranges
|
||||||
size_t c_start = cr.find_first();
|
size_t c_start = cr.find_first();
|
||||||
size_t c = c_start, c_last = 0;
|
size_t c = c_start;
|
||||||
while (c != CharReach::npos) {
|
while (c != CharReach::npos) {
|
||||||
c_last = c;
|
size_t c_last = c;
|
||||||
c = cr.find_next(c);
|
c = cr.find_next(c);
|
||||||
if (c != c_last + 1 || c_last == 0xff) {
|
if (c != c_last + 1 || c_last == 0xff) {
|
||||||
describeRange(os, c_start, c_last, out_type);
|
describeRange(os, c_start, c_last, out_type);
|
||||||
|
@ -66,32 +66,32 @@ public:
|
|||||||
explicit EngineChimera(ch_database_t *db, CompileCHStats cs);
|
explicit EngineChimera(ch_database_t *db, CompileCHStats cs);
|
||||||
~EngineChimera();
|
~EngineChimera();
|
||||||
|
|
||||||
std::unique_ptr<EngineContext> makeContext() const;
|
std::unique_ptr<EngineContext> makeContext() const override;
|
||||||
|
|
||||||
void scan(const char *data, unsigned int len, unsigned int id,
|
void scan(const char *data, unsigned int len, unsigned int id,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
void scan_vectored(const char *const *data, const unsigned int *len,
|
void scan_vectored(const char *const *data, const unsigned int *len,
|
||||||
unsigned int count, unsigned int streamId,
|
unsigned int count, unsigned int streamId,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
||||||
unsigned id) const;
|
unsigned id) const override;
|
||||||
|
|
||||||
void streamClose(std::unique_ptr<EngineStream> stream,
|
void streamClose(std::unique_ptr<EngineStream> stream,
|
||||||
ResultEntry &result) const;
|
ResultEntry &result) const override;
|
||||||
|
|
||||||
void streamCompressExpand(EngineStream &stream,
|
void streamCompressExpand(EngineStream &stream,
|
||||||
std::vector<char> &temp) const;
|
std::vector<char> &temp) const override;
|
||||||
|
|
||||||
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
||||||
unsigned int id, ResultEntry &result) const;
|
unsigned int id, ResultEntry &result) const override;
|
||||||
|
|
||||||
void printStats() const;
|
void printStats() const override;
|
||||||
|
|
||||||
void printCsvStats() const;
|
void printCsvStats() const override;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ch_database_t *db;
|
ch_database_t *db;
|
||||||
|
@ -75,32 +75,32 @@ public:
|
|||||||
explicit EngineHyperscan(hs_database_t *db, CompileHSStats cs);
|
explicit EngineHyperscan(hs_database_t *db, CompileHSStats cs);
|
||||||
~EngineHyperscan();
|
~EngineHyperscan();
|
||||||
|
|
||||||
std::unique_ptr<EngineContext> makeContext() const;
|
std::unique_ptr<EngineContext> makeContext() const override;
|
||||||
|
|
||||||
void scan(const char *data, unsigned int len, unsigned int id,
|
void scan(const char *data, unsigned int len, unsigned int id,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
void scan_vectored(const char *const *data, const unsigned int *len,
|
void scan_vectored(const char *const *data, const unsigned int *len,
|
||||||
unsigned int count, unsigned int streamId,
|
unsigned int count, unsigned int streamId,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
||||||
unsigned id) const;
|
unsigned id) const override;
|
||||||
|
|
||||||
void streamClose(std::unique_ptr<EngineStream> stream,
|
void streamClose(std::unique_ptr<EngineStream> stream,
|
||||||
ResultEntry &result) const;
|
ResultEntry &result) const override;
|
||||||
|
|
||||||
void streamCompressExpand(EngineStream &stream,
|
void streamCompressExpand(EngineStream &stream,
|
||||||
std::vector<char> &temp) const;
|
std::vector<char> &temp) const override;
|
||||||
|
|
||||||
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
||||||
unsigned int id, ResultEntry &result) const;
|
unsigned int id, ResultEntry &result) const override;
|
||||||
|
|
||||||
void printStats() const;
|
void printStats() const override;
|
||||||
|
|
||||||
void printCsvStats() const;
|
void printCsvStats() const override;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hs_database_t *db;
|
hs_database_t *db;
|
||||||
|
@ -74,32 +74,32 @@ public:
|
|||||||
CompilePCREStats cs, int capture_cnt_in);
|
CompilePCREStats cs, int capture_cnt_in);
|
||||||
~EnginePCRE();
|
~EnginePCRE();
|
||||||
|
|
||||||
std::unique_ptr<EngineContext> makeContext() const;
|
std::unique_ptr<EngineContext> makeContext() const override;
|
||||||
|
|
||||||
void scan(const char *data, unsigned int len, unsigned int id,
|
void scan(const char *data, unsigned int len, unsigned int id,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
void scan_vectored(const char *const *data, const unsigned int *len,
|
void scan_vectored(const char *const *data, const unsigned int *len,
|
||||||
unsigned int count, unsigned int streamId,
|
unsigned int count, unsigned int streamId,
|
||||||
ResultEntry &result, EngineContext &ectx) const;
|
ResultEntry &result, EngineContext &ectx) const override;
|
||||||
|
|
||||||
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
std::unique_ptr<EngineStream> streamOpen(EngineContext &ectx,
|
||||||
unsigned id) const;
|
unsigned id) const override;
|
||||||
|
|
||||||
void streamClose(std::unique_ptr<EngineStream> stream,
|
void streamClose(std::unique_ptr<EngineStream> stream,
|
||||||
ResultEntry &result) const;
|
ResultEntry &result) const override;
|
||||||
|
|
||||||
void streamCompressExpand(EngineStream &stream,
|
void streamCompressExpand(EngineStream &stream,
|
||||||
std::vector<char> &temp) const;
|
std::vector<char> &temp) const override;
|
||||||
|
|
||||||
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
void streamScan(EngineStream &stream, const char *data, unsigned int len,
|
||||||
unsigned int id, ResultEntry &result) const;
|
unsigned int id, ResultEntry &result) const override;
|
||||||
|
|
||||||
void printStats() const;
|
void printStats() const override;
|
||||||
|
|
||||||
void printCsvStats() const;
|
void printCsvStats() const override;
|
||||||
|
|
||||||
void sqlStats(SqlDB &db) const;
|
void sqlStats(SqlDB &db) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<PcreDB>> dbs;
|
std::vector<std::unique_ptr<PcreDB>> dbs;
|
||||||
|
@ -488,7 +488,6 @@ TEST_P(FDRFloodp, StreamingMask) {
|
|||||||
Grey());
|
Grey());
|
||||||
CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint);
|
CHECK_WITH_TEDDY_OK_TO_FAIL(fdr, hint);
|
||||||
|
|
||||||
hwlm_error_t fdrStatus;
|
|
||||||
const u32 cnt4 = dataSize - 4 + 1;
|
const u32 cnt4 = dataSize - 4 + 1;
|
||||||
|
|
||||||
for (u32 streamChunk = 1; streamChunk <= 16; streamChunk *= 2) {
|
for (u32 streamChunk = 1; streamChunk <= 16; streamChunk *= 2) {
|
||||||
@ -496,7 +495,7 @@ TEST_P(FDRFloodp, StreamingMask) {
|
|||||||
const u8 *d = data.data();
|
const u8 *d = data.data();
|
||||||
// reference past the end of fake history to allow headroom
|
// reference past the end of fake history to allow headroom
|
||||||
const u8 *fhist = fake_history.data() + fake_history_size;
|
const u8 *fhist = fake_history.data() + fake_history_size;
|
||||||
fdrStatus = fdrExecStreaming(fdr.get(), fhist, 0, d, streamChunk, 0,
|
hwlm_error_t fdrStatus = fdrExecStreaming(fdr.get(), fhist, 0, d, streamChunk, 0,
|
||||||
countCallback, &scratch,
|
countCallback, &scratch,
|
||||||
HWLM_ALL_GROUPS);
|
HWLM_ALL_GROUPS);
|
||||||
ASSERT_EQ(0, fdrStatus);
|
ASSERT_EQ(0, fdrStatus);
|
||||||
|
@ -277,10 +277,9 @@ TEST_P(RepeatTest, FillRing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We should be able to see matches for all of these (beyond the last top offset).
|
// We should be able to see matches for all of these (beyond the last top offset).
|
||||||
enum TriggerResult rv;
|
|
||||||
for (u64a i = offset + info.repeatMax;
|
for (u64a i = offset + info.repeatMax;
|
||||||
i <= offset + info.repeatMax + info.repeatMin; i++) {
|
i <= offset + info.repeatMax + info.repeatMin; i++) {
|
||||||
rv = processTugTrigger(&info, ctrl, state, i);
|
enum TriggerResult rv = processTugTrigger(&info, ctrl, state, i);
|
||||||
if (rv == TRIGGER_SUCCESS_CACHE) {
|
if (rv == TRIGGER_SUCCESS_CACHE) {
|
||||||
rv = TRIGGER_SUCCESS;
|
rv = TRIGGER_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -998,16 +997,14 @@ TEST_P(SparseOptimalTest, FillTops) {
|
|||||||
repeatStore(info, ctrl, state, offset, 0);
|
repeatStore(info, ctrl, state, offset, 0);
|
||||||
ASSERT_EQ(offset, repeatLastTop(info, ctrl, state));
|
ASSERT_EQ(offset, repeatLastTop(info, ctrl, state));
|
||||||
|
|
||||||
u64a offset2;
|
|
||||||
for (u32 i = min_period; i < patch_count * patch_size; i += min_period) {
|
for (u32 i = min_period; i < patch_count * patch_size; i += min_period) {
|
||||||
offset2 = offset + i;
|
u64a offset2 = offset + i;
|
||||||
repeatStore(info, ctrl, state, offset2, 1);
|
repeatStore(info, ctrl, state, offset2, 1);
|
||||||
ASSERT_EQ(offset2, repeatLastTop(info, ctrl, state));
|
ASSERT_EQ(offset2, repeatLastTop(info, ctrl, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
u64a exit2;
|
|
||||||
for (u32 i = 0; i < patch_count * patch_size; i += min_period) {
|
for (u32 i = 0; i < patch_count * patch_size; i += min_period) {
|
||||||
exit2 = exit + i;
|
u64a exit2 = exit + i;
|
||||||
for (u32 j = exit2 + info->repeatMin;
|
for (u32 j = exit2 + info->repeatMin;
|
||||||
j <= offset + info->repeatMax; j++) {
|
j <= offset + info->repeatMax; j++) {
|
||||||
ASSERT_EQ(REPEAT_MATCH, repeatHasMatch(info, ctrl, state, j));
|
ASSERT_EQ(REPEAT_MATCH, repeatHasMatch(info, ctrl, state, j));
|
||||||
|
@ -87,12 +87,11 @@ static int initLegalValidMasks(u64a validMasks[]) {
|
|||||||
*/
|
*/
|
||||||
static int initLegalNegMasks(u64a negMasks[]) {
|
static int initLegalNegMasks(u64a negMasks[]) {
|
||||||
u64a data = 0;
|
u64a data = 0;
|
||||||
u64a offset;
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
while (data != ONES64) {
|
while (data != ONES64) {
|
||||||
negMasks[num] = data;
|
negMasks[num] = data;
|
||||||
num++;
|
num++;
|
||||||
offset = (data | (data +1)) ^ data;
|
u64a offset = (data | (data +1)) ^ data;
|
||||||
data += 0xfeULL * offset + 1;
|
data += 0xfeULL * offset + 1;
|
||||||
}
|
}
|
||||||
negMasks[num] = data;
|
negMasks[num] = data;
|
||||||
|
@ -194,10 +194,9 @@ TEST(ValidateMask32, testMask32_3) {
|
|||||||
u32 valid_mask = ONES32 << (left + right) >> left;
|
u32 valid_mask = ONES32 << (left + right) >> left;
|
||||||
for (int i = 0; i < test_len; i++) {
|
for (int i = 0; i < test_len; i++) {
|
||||||
const auto &t = testBasic[i];
|
const auto &t = testBasic[i];
|
||||||
int bool_result;
|
|
||||||
for (int j = 0; j < 5000; j++) {
|
for (int j = 0; j < 5000; j++) {
|
||||||
u32 neg_mask = neg_mask_rand.Generate(1u << 31);
|
u32 neg_mask = neg_mask_rand.Generate(1u << 31);
|
||||||
bool_result = (neg_mask & valid_mask) ==
|
int bool_result = (neg_mask & valid_mask) ==
|
||||||
(t.neg_mask & valid_mask);
|
(t.neg_mask & valid_mask);
|
||||||
EXPECT_EQ(bool_result, validateMask32(t.data.a256,
|
EXPECT_EQ(bool_result, validateMask32(t.data.a256,
|
||||||
valid_mask,
|
valid_mask,
|
||||||
|
@ -223,7 +223,7 @@ public:
|
|||||||
CorpusProperties &props);
|
CorpusProperties &props);
|
||||||
~CorpusGeneratorImpl() = default;
|
~CorpusGeneratorImpl() = default;
|
||||||
|
|
||||||
void generateCorpus(vector<string> &data);
|
void generateCorpus(vector<string> &data) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char getRandomChar();
|
unsigned char getRandomChar();
|
||||||
@ -419,7 +419,7 @@ public:
|
|||||||
CorpusProperties &props);
|
CorpusProperties &props);
|
||||||
~CorpusGeneratorUtf8() = default;
|
~CorpusGeneratorUtf8() = default;
|
||||||
|
|
||||||
void generateCorpus(vector<string> &data);
|
void generateCorpus(vector<string> &data) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unichar getRandomChar();
|
unichar getRandomChar();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user