mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 03:34:25 +03:00
util: switch from Boost to std::unordered set/map
This commit replaces the ue2::unordered_{set,map} types with their STL versions, with some new hashing utilities in util/hash.h. The new types ue2_unordered_set<T> and ue2_unordered_map<Key, T> default to using the ue2_hasher. The header util/ue2_containers.h has been removed, and the flat_set/map containers moved to util/flat_containers.h.
This commit is contained in:
committed by
Matthew Barr
parent
a425bb9b7c
commit
9cf66b6ac9
@@ -42,8 +42,8 @@
|
||||
#include "rose_in_graph.h"
|
||||
#include "util/bytecode_ptr.h"
|
||||
#include "util/charreach.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/noncopyable.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
/** \brief True if we can not establish that at most a single callback will
|
||||
* be generated at a given offset from this set of reports. */
|
||||
virtual bool requiresDedupeSupport(const ue2::flat_set<ReportID> &reports)
|
||||
virtual bool requiresDedupeSupport(const flat_set<ReportID> &reports)
|
||||
const = 0;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
/** \brief Adds a single literal. */
|
||||
virtual void add(bool anchored, bool eod, const ue2_literal &lit,
|
||||
const ue2::flat_set<ReportID> &ids) = 0;
|
||||
const flat_set<ReportID> &ids) = 0;
|
||||
|
||||
virtual bool addRose(const RoseInGraph &ig, bool prefilter) = 0;
|
||||
virtual bool addSombeRose(const RoseInGraph &ig) = 0;
|
||||
@@ -99,17 +99,17 @@ public:
|
||||
|
||||
/** \brief Returns true if we were able to add it as a mask. */
|
||||
virtual bool add(bool anchored, const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports) = 0;
|
||||
const flat_set<ReportID> &reports) = 0;
|
||||
|
||||
/** \brief Attempts to add the graph to the anchored acyclic table. Returns
|
||||
* true on success. */
|
||||
virtual bool addAnchoredAcyclic(const NGHolder &graph) = 0;
|
||||
|
||||
virtual bool validateMask(const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports,
|
||||
const flat_set<ReportID> &reports,
|
||||
bool anchored, bool eod) const = 0;
|
||||
virtual void addMask(const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports, bool anchored,
|
||||
const flat_set<ReportID> &reports, bool anchored,
|
||||
bool eod) = 0;
|
||||
|
||||
/** \brief Construct a runtime implementation. */
|
||||
|
@@ -85,7 +85,7 @@ struct RoseBuildData : noncopyable {
|
||||
|
||||
/** Edges we've transformed (in \ref transformAnchoredLiteralOverlap) which
|
||||
* require ANCH history to prevent overlap. */
|
||||
ue2::unordered_set<RoseInEdge> anch_history_edges;
|
||||
unordered_set<RoseInEdge> anch_history_edges;
|
||||
|
||||
/** True if we're tracking Start of Match. */
|
||||
bool som;
|
||||
|
@@ -49,11 +49,12 @@
|
||||
#include "util/compile_error.h"
|
||||
#include "util/container.h"
|
||||
#include "util/determinise.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/unordered.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
#include <map>
|
||||
@@ -285,19 +286,16 @@ struct Holder_StateSet {
|
||||
bool operator==(const Holder_StateSet &b) const {
|
||||
return wdelay == b.wdelay && wrap_state == b.wrap_state;
|
||||
}
|
||||
};
|
||||
|
||||
size_t hash_value(const Holder_StateSet &s) {
|
||||
size_t val = 0;
|
||||
boost::hash_combine(val, s.wrap_state);
|
||||
boost::hash_combine(val, s.wdelay);
|
||||
return val;
|
||||
}
|
||||
size_t hash() const {
|
||||
return hash_all(wrap_state, wdelay);
|
||||
}
|
||||
};
|
||||
|
||||
class Automaton_Holder {
|
||||
public:
|
||||
using StateSet = Holder_StateSet;
|
||||
using StateMap = unordered_map<StateSet, dstate_id_t>;
|
||||
using StateMap = ue2_unordered_map<StateSet, dstate_id_t>;
|
||||
|
||||
explicit Automaton_Holder(const NGHolder &g_in) : g(g_in) {
|
||||
for (auto v : vertices_range(g)) {
|
||||
@@ -416,7 +414,7 @@ public:
|
||||
|
||||
private:
|
||||
const NGHolder &g;
|
||||
ue2::unordered_map<NFAVertex, u32> vertexToIndex;
|
||||
unordered_map<NFAVertex, u32> vertexToIndex;
|
||||
vector<NFAVertex> indexToVertex;
|
||||
vector<CharReach> cr_by_index;
|
||||
StateSet init;
|
||||
@@ -712,7 +710,7 @@ int addAutomaton(RoseBuildImpl &build, const NGHolder &h, ReportID *remap) {
|
||||
|
||||
static
|
||||
void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
|
||||
const ue2::unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
|
||||
const unordered_map<NFAVertex, NFAVertex> &orig_to_copy) {
|
||||
for (const auto &m : reportMap) {
|
||||
NFAVertex t = orig_to_copy.at(m.first);
|
||||
assert(!m.second.empty());
|
||||
@@ -724,7 +722,7 @@ void setReports(NGHolder &h, const map<NFAVertex, set<u32>> &reportMap,
|
||||
int addAnchoredNFA(RoseBuildImpl &build, const NGHolder &wrapper,
|
||||
const map<NFAVertex, set<u32>> &reportMap) {
|
||||
NGHolder h;
|
||||
ue2::unordered_map<NFAVertex, NFAVertex> orig_to_copy;
|
||||
unordered_map<NFAVertex, NFAVertex> orig_to_copy;
|
||||
cloneHolder(h, wrapper, &orig_to_copy);
|
||||
clear_in_edges(h.accept, h);
|
||||
clear_in_edges(h.acceptEod, h);
|
||||
|
@@ -145,8 +145,8 @@ struct build_context : noncopyable {
|
||||
|
||||
/** \brief Simple cache of programs written to engine blob, used for
|
||||
* deduplication. */
|
||||
ue2::unordered_map<RoseProgram, u32, RoseProgramHash,
|
||||
RoseProgramEquivalence> program_cache;
|
||||
unordered_map<RoseProgram, u32, RoseProgramHash,
|
||||
RoseProgramEquivalence> program_cache;
|
||||
|
||||
/** \brief State indices, for those roles that have them.
|
||||
* Each vertex present has a unique state index in the range
|
||||
@@ -155,7 +155,7 @@ struct build_context : noncopyable {
|
||||
|
||||
/** \brief Mapping from queue index to bytecode offset for built engines
|
||||
* that have already been pushed into the engine_blob. */
|
||||
ue2::unordered_map<u32, u32> engineOffsets;
|
||||
unordered_map<u32, u32> engineOffsets;
|
||||
|
||||
/** \brief List of long literals (ones with CHECK_LONG_LIT instructions)
|
||||
* that need hash table support. */
|
||||
@@ -1470,7 +1470,7 @@ bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||
|
||||
map<left_id, set<PredTopPair> > infixTriggers;
|
||||
vector<left_id> order;
|
||||
unordered_map<left_id, vector<RoseVertex> > succs;
|
||||
unordered_map<left_id, vector<RoseVertex>> succs;
|
||||
findInfixTriggers(tbi, &infixTriggers);
|
||||
|
||||
if (cc.grey.allowTamarama && cc.streaming && !do_prefix) {
|
||||
@@ -2269,9 +2269,9 @@ bool hasMpvTrigger(const set<u32> &reports, const ReportManager &rm) {
|
||||
}
|
||||
|
||||
static
|
||||
bool anyEndfixMpvTriggers(const RoseBuildImpl &tbi) {
|
||||
const RoseGraph &g = tbi.g;
|
||||
ue2::unordered_set<suffix_id> done;
|
||||
bool anyEndfixMpvTriggers(const RoseBuildImpl &build) {
|
||||
const RoseGraph &g = build.g;
|
||||
unordered_set<suffix_id> done;
|
||||
|
||||
/* suffixes */
|
||||
for (auto v : vertices_range(g)) {
|
||||
@@ -2283,14 +2283,14 @@ bool anyEndfixMpvTriggers(const RoseBuildImpl &tbi) {
|
||||
}
|
||||
done.insert(g[v].suffix);
|
||||
|
||||
if (hasMpvTrigger(all_reports(g[v].suffix), tbi.rm)) {
|
||||
if (hasMpvTrigger(all_reports(g[v].suffix), build.rm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* outfixes */
|
||||
for (const auto &out : tbi.outfixes) {
|
||||
if (hasMpvTrigger(all_reports(out), tbi.rm)) {
|
||||
for (const auto &out : build.outfixes) {
|
||||
if (hasMpvTrigger(all_reports(out), build.rm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2588,7 +2588,7 @@ void buildLeftInfoTable(const RoseBuildImpl &tbi, build_context &bc,
|
||||
const RoseGraph &g = tbi.g;
|
||||
const CompileContext &cc = tbi.cc;
|
||||
|
||||
ue2::unordered_set<u32> done_core;
|
||||
unordered_set<u32> done_core;
|
||||
|
||||
leftTable.resize(leftfixCount);
|
||||
|
||||
|
@@ -38,7 +38,6 @@
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
|
||||
#include <map>
|
||||
@@ -55,7 +54,7 @@ namespace ue2 {
|
||||
|
||||
static
|
||||
void makeCastle(LeftEngInfo &left,
|
||||
unordered_map<const NGHolder *, shared_ptr<CastleProto>> &cache) {
|
||||
unordered_map<const NGHolder *, shared_ptr<CastleProto>> &cache) {
|
||||
if (left.dfa || left.haig || left.castle) {
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +84,7 @@ void makeCastle(LeftEngInfo &left,
|
||||
|
||||
static
|
||||
void makeCastleSuffix(RoseBuildImpl &tbi, RoseVertex v,
|
||||
ue2::unordered_map<const NGHolder *, shared_ptr<CastleProto> > &cache) {
|
||||
unordered_map<const NGHolder *, shared_ptr<CastleProto>> &cache) {
|
||||
RoseSuffixInfo &suffix = tbi.g[v].suffix;
|
||||
if (!suffix.graph) {
|
||||
return;
|
||||
@@ -298,8 +297,8 @@ bool unmakeCastles(RoseBuildImpl &tbi) {
|
||||
}
|
||||
|
||||
void remapCastleTops(RoseBuildImpl &tbi) {
|
||||
ue2::unordered_map<CastleProto *, vector<RoseVertex> > rose_castles;
|
||||
ue2::unordered_map<CastleProto *, vector<RoseVertex> > suffix_castles;
|
||||
unordered_map<CastleProto *, vector<RoseVertex>> rose_castles;
|
||||
unordered_map<CastleProto *, vector<RoseVertex>> suffix_castles;
|
||||
|
||||
RoseGraph &g = tbi.g;
|
||||
for (auto v : vertices_range(g)) {
|
||||
|
@@ -61,10 +61,10 @@
|
||||
#include "util/compile_context.h"
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/report_manager.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
@@ -1639,7 +1639,7 @@ static
|
||||
bool danglingVertexRef(RoseBuildImpl &tbi) {
|
||||
RoseGraph::vertex_iterator vi, ve;
|
||||
tie(vi, ve) = vertices(tbi.g);
|
||||
const ue2::unordered_set<RoseVertex> valid_vertices(vi, ve);
|
||||
const unordered_set<RoseVertex> valid_vertices(vi, ve);
|
||||
|
||||
if (!contains(valid_vertices, tbi.anchored_root)) {
|
||||
DEBUG_PRINTF("anchored root vertex %zu not in graph\n",
|
||||
|
@@ -58,8 +58,9 @@
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
|
||||
@@ -561,7 +562,7 @@ bool handleMixedPrefixCliche(const NGHolder &h, RoseGraph &g, RoseVertex v,
|
||||
DEBUG_PRINTF("woot?\n");
|
||||
|
||||
shared_ptr<NGHolder> h_new = make_shared<NGHolder>();
|
||||
ue2::unordered_map<NFAVertex, NFAVertex> rhs_map;
|
||||
unordered_map<NFAVertex, NFAVertex> rhs_map;
|
||||
vector<NFAVertex> exits_vec;
|
||||
insert(&exits_vec, exits_vec.end(), exits);
|
||||
splitRHS(h, exits_vec, h_new.get(), &rhs_map);
|
||||
|
@@ -36,13 +36,14 @@
|
||||
#include "util/bytecode_ptr.h"
|
||||
#include "util/charreach.h"
|
||||
#include "util/container.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/multibit_build.h"
|
||||
#include "util/noncopyable.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/verify_types.h"
|
||||
#include "util/unordered.h"
|
||||
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace ue2 {
|
||||
|
||||
@@ -56,9 +57,10 @@ struct lookaround_info : noncopyable {
|
||||
u32 get_offset_of(const std::vector<s8> &look, RoseEngineBlob &blob);
|
||||
|
||||
private:
|
||||
unordered_map<std::vector<std::vector<CharReach>>, u32> multi_cache;
|
||||
unordered_map<std::vector<s8>, u32> lcache;
|
||||
unordered_map<std::vector<CharReach>, u32> rcache;
|
||||
using Path = std::vector<CharReach>;
|
||||
ue2_unordered_map<std::vector<Path>, u32> multi_cache;
|
||||
ue2_unordered_map<std::vector<s8>, u32> lcache;
|
||||
ue2_unordered_map<Path, u32> rcache;
|
||||
};
|
||||
|
||||
class RoseEngineBlob : noncopyable {
|
||||
@@ -160,7 +162,7 @@ private:
|
||||
}
|
||||
|
||||
/** \brief Cache of previously-written sparse iterators. */
|
||||
unordered_map<std::vector<mmbit_sparse_iter>, u32> cached_iters;
|
||||
ue2_unordered_map<std::vector<mmbit_sparse_iter>, u32> cached_iters;
|
||||
|
||||
/**
|
||||
* \brief Contents of the Rose bytecode immediately following the
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Intel Corporation
|
||||
* Copyright (c) 2016-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -87,7 +87,7 @@ vector<RoleChunk<role_id>> divideIntoChunks(const RoseBuildImpl &build,
|
||||
|
||||
/* add prefix literals to engine graph */
|
||||
static
|
||||
bool addPrefixLiterals(NGHolder &h, ue2::unordered_set<u32> &tailId,
|
||||
bool addPrefixLiterals(NGHolder &h, unordered_set<u32> &tailId,
|
||||
const vector<vector<CharReach>> &triggers) {
|
||||
DEBUG_PRINTF("add literals to graph\n");
|
||||
|
||||
@@ -196,8 +196,8 @@ vector<CharReach> findStartPos(const CharReach &cr1,
|
||||
template<typename role_id>
|
||||
static
|
||||
bool isExclusive(const NGHolder &h,
|
||||
const u32 num, ue2::unordered_set<u32> &tailId,
|
||||
map<u32, ue2::unordered_set<u32>> &skipList,
|
||||
const u32 num, unordered_set<u32> &tailId,
|
||||
map<u32, unordered_set<u32>> &skipList,
|
||||
const RoleInfo<role_id> &role1,
|
||||
const RoleInfo<role_id> &role2) {
|
||||
const u32 id1 = role1.id;
|
||||
@@ -253,12 +253,12 @@ bool isExclusive(const NGHolder &h,
|
||||
|
||||
template<typename role_id>
|
||||
static
|
||||
ue2::unordered_set<u32> checkExclusivity(const NGHolder &h,
|
||||
const u32 num, ue2::unordered_set<u32> &tailId,
|
||||
map<u32, ue2::unordered_set<u32>> &skipList,
|
||||
const RoleInfo<role_id> &role1,
|
||||
const RoleChunk<role_id> &roleChunk) {
|
||||
ue2::unordered_set<u32> info;
|
||||
unordered_set<u32> checkExclusivity(const NGHolder &h,
|
||||
const u32 num, unordered_set<u32> &tailId,
|
||||
map<u32, unordered_set<u32>> &skipList,
|
||||
const RoleInfo<role_id> &role1,
|
||||
const RoleChunk<role_id> &roleChunk) {
|
||||
unordered_set<u32> info;
|
||||
const u32 id1 = role1.id;
|
||||
for (const auto &role2 : roleChunk.roles) {
|
||||
const u32 id2 = role2.id;
|
||||
@@ -316,7 +316,7 @@ void findCliques(const map<u32, set<u32>> &exclusiveGroups,
|
||||
|
||||
static
|
||||
map<u32, set<u32>> findExclusiveGroups(const RoseBuildImpl &build,
|
||||
const map<u32, ue2::unordered_set<u32>> &exclusiveInfo,
|
||||
const map<u32, unordered_set<u32>> &exclusiveInfo,
|
||||
const map<u32, vector<RoseVertex>> &vertex_map,
|
||||
const bool is_infix) {
|
||||
map<u32, set<u32>> exclusiveGroups;
|
||||
@@ -396,10 +396,10 @@ void exclusiveAnalysis(const RoseBuildImpl &build,
|
||||
vector<vector<u32>> &exclusive_roles, const bool is_infix) {
|
||||
const auto &chunks = divideIntoChunks(build, roleInfoSet);
|
||||
DEBUG_PRINTF("Exclusivity analysis entry\n");
|
||||
map<u32, ue2::unordered_set<u32>> exclusiveInfo;
|
||||
map<u32, unordered_set<u32>> exclusiveInfo;
|
||||
|
||||
for (const auto &roleChunk : chunks) {
|
||||
map<u32, ue2::unordered_set<u32>> skipList;
|
||||
map<u32, unordered_set<u32>> skipList;
|
||||
for (const auto &role1 : roleChunk.roles) {
|
||||
const u32 id1 = role1.id;
|
||||
const role_id &s1 = role1.role;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Intel Corporation
|
||||
* Copyright (c) 2016-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -35,11 +35,12 @@
|
||||
#define ROSE_BUILD_GROUPS_H
|
||||
|
||||
#include "rose_build_impl.h"
|
||||
#include "util/ue2_containers.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ue2 {
|
||||
|
||||
unordered_map<RoseVertex, rose_group>
|
||||
std::unordered_map<RoseVertex, rose_group>
|
||||
getVertexGroupMap(const RoseBuildImpl &build);
|
||||
|
||||
rose_group getSquashableGroups(const RoseBuildImpl &build);
|
||||
|
@@ -39,11 +39,12 @@
|
||||
#include "nfagraph/ng_holder.h"
|
||||
#include "nfagraph/ng_revacc.h"
|
||||
#include "util/bytecode_ptr.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/queue_index_factory.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/unordered.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
#include <deque>
|
||||
@@ -177,7 +178,6 @@ depth findMinWidth(const suffix_id &s);
|
||||
depth findMaxWidth(const suffix_id &s);
|
||||
depth findMinWidth(const suffix_id &s, u32 top);
|
||||
depth findMaxWidth(const suffix_id &s, u32 top);
|
||||
size_t hash_value(const suffix_id &s);
|
||||
|
||||
/** \brief represents an engine to the left of a rose role */
|
||||
struct left_id {
|
||||
@@ -258,11 +258,10 @@ bool isAnchored(const left_id &r);
|
||||
depth findMinWidth(const left_id &r);
|
||||
depth findMaxWidth(const left_id &r);
|
||||
u32 num_tops(const left_id &r);
|
||||
size_t hash_value(const left_id &r);
|
||||
|
||||
struct rose_literal_info {
|
||||
ue2::flat_set<u32> delayed_ids;
|
||||
ue2::flat_set<RoseVertex> vertices;
|
||||
flat_set<u32> delayed_ids;
|
||||
flat_set<RoseVertex> vertices;
|
||||
rose_group group_mask = 0;
|
||||
u32 undelayed_id = MO_INVALID_IDX;
|
||||
bool squash_group = false;
|
||||
@@ -306,6 +305,10 @@ struct rose_literal_id {
|
||||
return s == b.s && msk == b.msk && cmp == b.cmp && table == b.table &&
|
||||
delay == b.delay && distinctiveness == b.distinctiveness;
|
||||
}
|
||||
|
||||
size_t hash() const {
|
||||
return hash_all(s, msk, cmp, table, delay, distinctiveness);
|
||||
}
|
||||
};
|
||||
|
||||
static inline
|
||||
@@ -319,12 +322,6 @@ bool operator<(const rose_literal_id &a, const rose_literal_id &b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t hash_value(const rose_literal_id &lit) {
|
||||
return hash_all(lit.s, lit.msk, lit.cmp, lit.table, lit.delay,
|
||||
lit.distinctiveness);
|
||||
}
|
||||
|
||||
class RoseLiteralMap {
|
||||
/**
|
||||
* \brief Main storage for literals.
|
||||
@@ -336,7 +333,7 @@ class RoseLiteralMap {
|
||||
std::deque<rose_literal_id> lits;
|
||||
|
||||
/** \brief Quick-lookup index from literal -> index in lits. */
|
||||
unordered_map<rose_literal_id, u32> lits_index;
|
||||
ue2_unordered_map<rose_literal_id, u32> lits_index;
|
||||
|
||||
public:
|
||||
std::pair<u32, bool> insert(const rose_literal_id &lit) {
|
||||
@@ -504,7 +501,7 @@ public:
|
||||
|
||||
// Adds a single literal.
|
||||
void add(bool anchored, bool eod, const ue2_literal &lit,
|
||||
const ue2::flat_set<ReportID> &ids) override;
|
||||
const flat_set<ReportID> &ids) override;
|
||||
|
||||
bool addRose(const RoseInGraph &ig, bool prefilter) override;
|
||||
bool addSombeRose(const RoseInGraph &ig) override;
|
||||
@@ -517,15 +514,15 @@ public:
|
||||
|
||||
// Returns true if we were able to add it as a mask
|
||||
bool add(bool anchored, const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports) override;
|
||||
const flat_set<ReportID> &reports) override;
|
||||
|
||||
bool addAnchoredAcyclic(const NGHolder &graph) override;
|
||||
|
||||
bool validateMask(const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports, bool anchored,
|
||||
const flat_set<ReportID> &reports, bool anchored,
|
||||
bool eod) const override;
|
||||
void addMask(const std::vector<CharReach> &mask,
|
||||
const ue2::flat_set<ReportID> &reports, bool anchored,
|
||||
const flat_set<ReportID> &reports, bool anchored,
|
||||
bool eod) override;
|
||||
|
||||
// Construct a runtime implementation.
|
||||
@@ -627,8 +624,8 @@ public:
|
||||
* overlap calculation in history assignment. */
|
||||
std::map<u32, rose_literal_id> anchoredLitSuffix;
|
||||
|
||||
unordered_set<left_id> transient;
|
||||
unordered_map<left_id, rose_group> rose_squash_masks;
|
||||
ue2_unordered_set<left_id> transient;
|
||||
ue2_unordered_map<left_id, rose_group> rose_squash_masks;
|
||||
|
||||
std::vector<OutfixInfo> outfixes;
|
||||
|
||||
@@ -689,4 +686,22 @@ bool canImplementGraphs(const RoseBuildImpl &tbi);
|
||||
|
||||
} // namespace ue2
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<ue2::left_id> {
|
||||
size_t operator()(const ue2::left_id &l) const {
|
||||
return l.hash();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<ue2::suffix_id> {
|
||||
size_t operator()(const ue2::suffix_id &s) const {
|
||||
return s.hash();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* ROSE_BUILD_IMPL_H */
|
||||
|
@@ -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:
|
||||
@@ -36,10 +36,12 @@
|
||||
#include "rose/rose_build_impl.h"
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/graph.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/unordered.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@@ -51,7 +53,7 @@ namespace ue2 {
|
||||
static
|
||||
bool couldEndLiteral(const ue2_literal &s, NFAVertex initial,
|
||||
const NGHolder &h) {
|
||||
ue2::flat_set<NFAVertex> curr, next;
|
||||
flat_set<NFAVertex> curr, next;
|
||||
curr.insert(initial);
|
||||
|
||||
for (auto it = s.rbegin(), ite = s.rend(); it != ite; ++it) {
|
||||
@@ -82,9 +84,10 @@ bool couldEndLiteral(const ue2_literal &s, NFAVertex initial,
|
||||
return true;
|
||||
}
|
||||
|
||||
using EdgeCache = ue2_unordered_set<pair<NFAVertex, NFAVertex>>;
|
||||
|
||||
static
|
||||
void contractVertex(NGHolder &g, NFAVertex v,
|
||||
ue2::unordered_set<pair<NFAVertex, NFAVertex>> &all_edges) {
|
||||
void contractVertex(NGHolder &g, NFAVertex v, EdgeCache &all_edges) {
|
||||
for (auto u : inv_adjacent_vertices_range(v, g)) {
|
||||
if (u == v) {
|
||||
continue; // self-edge
|
||||
@@ -144,8 +147,9 @@ u32 findMaxLiteralMatches(const NGHolder &h, const set<ue2_literal> &lits) {
|
||||
cloneHolder(g, h);
|
||||
vector<NFAVertex> dead;
|
||||
|
||||
// The set of all edges in the graph is used for existence checks in contractVertex.
|
||||
ue2::unordered_set<pair<NFAVertex, NFAVertex>> all_edges;
|
||||
// The set of all edges in the graph is used for existence checks in
|
||||
// contractVertex.
|
||||
EdgeCache all_edges;
|
||||
for (const auto &e : edges_range(g)) {
|
||||
all_edges.emplace(source(e, g), target(e, g));
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "rose_build_lookaround.h"
|
||||
#include "rose_build_program.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
namespace ue2 {
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
/** \brief Length of the bytecode instruction in bytes. */
|
||||
virtual size_t byte_length() const = 0;
|
||||
|
||||
using OffsetMap = unordered_map<const RoseInstruction *, u32>;
|
||||
using OffsetMap = std::unordered_map<const RoseInstruction *, u32>;
|
||||
|
||||
/**
|
||||
* \brief Writes a concrete implementation of this instruction.
|
||||
@@ -149,6 +150,10 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
template<RoseInstructionCode Opcode, class ImplType, class RoseInstrType>
|
||||
constexpr RoseInstructionCode
|
||||
RoseInstrBase<Opcode, ImplType, RoseInstrType>::opcode;
|
||||
|
||||
/**
|
||||
* \brief Refinement of RoseInstrBase to use for instructions that have
|
||||
* just a single target member, called "target".
|
||||
@@ -190,7 +195,7 @@ public:
|
||||
virtual bool operator==(const RoseInstrType &) const { return true; }
|
||||
|
||||
size_t hash() const override {
|
||||
return boost::hash_value(static_cast<int>(Opcode));
|
||||
return hash_all(Opcode);
|
||||
}
|
||||
|
||||
bool equiv_to(const RoseInstrType &, const RoseInstruction::OffsetMap &,
|
||||
@@ -222,7 +227,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), groups, anch_id);
|
||||
return hash_all(opcode, groups, anch_id);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -251,7 +256,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), min_offset);
|
||||
return hash_all(opcode, min_offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -278,7 +283,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), groups);
|
||||
return hash_all(opcode, groups);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -305,7 +310,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return boost::hash_value(static_cast<int>(opcode));
|
||||
return hash_all(opcode);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -335,7 +340,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), min_bound, max_bound);
|
||||
return hash_all(opcode, min_bound, max_bound);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -364,7 +369,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), key);
|
||||
return hash_all(opcode, key);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -395,7 +400,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), offset, reach);
|
||||
return hash_all(opcode, offset, reach);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -426,7 +431,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), look);
|
||||
return hash_all(opcode, look);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -462,8 +467,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, neg_mask,
|
||||
offset);
|
||||
return hash_all(opcode, and_mask, cmp_mask, neg_mask, offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -501,8 +505,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, neg_mask,
|
||||
offset);
|
||||
return hash_all(opcode, and_mask, cmp_mask, neg_mask, offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -539,8 +542,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), and_mask, cmp_mask, negation,
|
||||
offset);
|
||||
return hash_all(opcode, and_mask, cmp_mask, negation, offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -581,8 +583,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), nib_mask,
|
||||
bucket_select_mask, neg_mask, offset);
|
||||
return hash_all(opcode, nib_mask, bucket_select_mask, neg_mask, offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -626,8 +627,8 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask, neg_mask, offset);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask, neg_mask,
|
||||
offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -671,8 +672,8 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask, neg_mask, offset);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask, neg_mask,
|
||||
offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -720,9 +721,8 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask_hi, bucket_select_mask_lo,
|
||||
neg_mask, offset);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask_hi,
|
||||
bucket_select_mask_lo, neg_mask, offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -758,7 +758,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), queue, lag, report);
|
||||
return hash_all(opcode, queue, lag, report);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -791,7 +791,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), queue, lag, report);
|
||||
return hash_all(opcode, queue, lag, report);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -820,7 +820,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), delay, index);
|
||||
return hash_all(opcode, delay, index);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -861,7 +861,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), distance);
|
||||
return hash_all(opcode, distance);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -889,7 +889,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), queue, lag);
|
||||
return hash_all(opcode, queue, lag);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -917,7 +917,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
|
||||
return hash_all(opcode, som.type, som.onmatch);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -953,7 +953,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), cancel, queue, event);
|
||||
return hash_all(opcode, cancel, queue, event);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -981,7 +981,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), queue, event);
|
||||
return hash_all(opcode, queue, event);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1013,8 +1013,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), quash_som, dkey,
|
||||
offset_adjust);
|
||||
return hash_all(opcode, quash_som, dkey, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1049,8 +1048,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), quash_som, dkey,
|
||||
offset_adjust);
|
||||
return hash_all(opcode, quash_som, dkey, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1081,7 +1079,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), event, top_squash_distance);
|
||||
return hash_all(opcode, event, top_squash_distance);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1110,7 +1108,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
|
||||
return hash_all(opcode, som.type, som.onmatch);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1138,7 +1136,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), som.type, som.onmatch);
|
||||
return hash_all(opcode, som.type, som.onmatch);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1165,7 +1163,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
|
||||
return hash_all(opcode, onmatch, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1196,7 +1194,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust, ekey);
|
||||
return hash_all(opcode, onmatch, offset_adjust, ekey);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1225,7 +1223,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
|
||||
return hash_all(opcode, onmatch, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1256,7 +1254,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust, ekey);
|
||||
return hash_all(opcode, onmatch, offset_adjust, ekey);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1293,8 +1291,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), quash_som, dkey, onmatch,
|
||||
offset_adjust);
|
||||
return hash_all(opcode, quash_som, dkey, onmatch, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1324,7 +1321,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), onmatch, offset_adjust);
|
||||
return hash_all(opcode, onmatch, offset_adjust);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1352,7 +1349,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), ekey);
|
||||
return hash_all(opcode, ekey);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1384,7 +1381,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), end_adj, min_length);
|
||||
return hash_all(opcode, end_adj, min_length);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1410,7 +1407,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), index);
|
||||
return hash_all(opcode, index);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1436,7 +1433,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), groups);
|
||||
return hash_all(opcode, groups);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1462,7 +1459,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), groups);
|
||||
return hash_all(opcode, groups);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1490,7 +1487,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), index);
|
||||
return hash_all(opcode, index);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1522,9 +1519,9 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
size_t v = hash_all(static_cast<int>(opcode), num_keys);
|
||||
size_t v = hash_all(opcode, num_keys);
|
||||
for (const u32 &key : jump_table | boost::adaptors::map_keys) {
|
||||
boost::hash_combine(v, key);
|
||||
hash_combine(v, key);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -1594,7 +1591,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), state);
|
||||
return hash_all(opcode, state);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1638,7 +1635,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), num_keys, keys);
|
||||
return hash_all(opcode, num_keys, keys);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1665,7 +1662,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), iter_offset);
|
||||
return hash_all(opcode, iter_offset);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1709,7 +1706,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), literal);
|
||||
return hash_all(opcode, literal);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1741,7 +1738,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), literal);
|
||||
return hash_all(opcode, literal);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1772,7 +1769,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), literal);
|
||||
return hash_all(opcode, literal);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1804,7 +1801,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), literal);
|
||||
return hash_all(opcode, literal);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1849,8 +1846,7 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), multi_look, last_start,
|
||||
start_mask);
|
||||
return hash_all(opcode, multi_look, last_start, start_mask);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1905,9 +1901,9 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), nib_mask,
|
||||
bucket_select_mask, data_select_mask, hi_bits_mask,
|
||||
lo_bits_mask, neg_mask, base_offset, last_start);
|
||||
return hash_all(opcode, nib_mask, bucket_select_mask, data_select_mask,
|
||||
hi_bits_mask, lo_bits_mask, neg_mask, base_offset,
|
||||
last_start);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -1968,9 +1964,9 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask, data_select_mask, hi_bits_mask,
|
||||
lo_bits_mask, neg_mask, base_offset, last_start);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask,
|
||||
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
|
||||
base_offset, last_start);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -2035,10 +2031,9 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask_hi, bucket_select_mask_lo,
|
||||
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
|
||||
base_offset, last_start);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask_hi,
|
||||
bucket_select_mask_lo, data_select_mask, hi_bits_mask,
|
||||
lo_bits_mask, neg_mask, base_offset, last_start);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
@@ -2100,9 +2095,9 @@ public:
|
||||
}
|
||||
|
||||
size_t hash() const override {
|
||||
return hash_all(static_cast<int>(opcode), hi_mask, lo_mask,
|
||||
bucket_select_mask, data_select_mask, hi_bits_mask,
|
||||
lo_bits_mask, neg_mask, base_offset, last_start);
|
||||
return hash_all(opcode, hi_mask, lo_mask, bucket_select_mask,
|
||||
data_select_mask, hi_bits_mask, lo_bits_mask, neg_mask,
|
||||
base_offset, last_start);
|
||||
}
|
||||
|
||||
void write(void *dest, RoseEngineBlob &blob,
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@@ -79,7 +79,7 @@ string dump(const map<s32, CharReach> &look) {
|
||||
|
||||
static
|
||||
void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) {
|
||||
ue2::flat_set<NFAVertex> curr, next;
|
||||
flat_set<NFAVertex> curr, next;
|
||||
|
||||
// Consider only successors of start with the required top.
|
||||
for (const auto &e : out_edges_range(g.start, g)) {
|
||||
@@ -116,7 +116,7 @@ void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) {
|
||||
static
|
||||
void getBackwardReach(const NGHolder &g, ReportID report, u32 lag,
|
||||
map<s32, CharReach> &look) {
|
||||
ue2::flat_set<NFAVertex> curr, next;
|
||||
flat_set<NFAVertex> curr, next;
|
||||
|
||||
for (auto v : inv_adjacent_vertices_range(g.accept, g)) {
|
||||
if (contains(g[v].reports, report)) {
|
||||
@@ -187,7 +187,7 @@ void getForwardReach(const raw_dfa &rdfa, map<s32, CharReach> &look) {
|
||||
return;
|
||||
}
|
||||
|
||||
ue2::flat_set<dstate_id_t> curr, next;
|
||||
flat_set<dstate_id_t> curr, next;
|
||||
curr.insert(rdfa.start_anchored);
|
||||
|
||||
for (u32 i = 0; i < MAX_FWD_LEN && !curr.empty(); i++) {
|
||||
@@ -849,7 +849,7 @@ void mergeLookaround(vector<LookEntry> &lookaround,
|
||||
}
|
||||
|
||||
// Don't merge lookarounds at offsets we already have entries for.
|
||||
ue2::flat_set<s8> offsets;
|
||||
flat_set<s8> offsets;
|
||||
for (const auto &e : lookaround) {
|
||||
offsets.insert(e.offset);
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#define ROSE_ROSE_BUILD_LOOKAROUND_H
|
||||
|
||||
#include "rose_graph.h"
|
||||
#include "util/hash.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -58,14 +59,6 @@ struct LookEntry {
|
||||
}
|
||||
};
|
||||
|
||||
static inline
|
||||
size_t hash_value(const LookEntry &l) {
|
||||
size_t val = 0;
|
||||
boost::hash_combine(val, l.offset);
|
||||
boost::hash_combine(val, l.reach);
|
||||
return val;
|
||||
}
|
||||
|
||||
void findLookaroundMasks(const RoseBuildImpl &tbi, const RoseVertex v,
|
||||
std::vector<LookEntry> &look_more);
|
||||
|
||||
@@ -83,4 +76,15 @@ void mergeLookaround(std::vector<LookEntry> &lookaround,
|
||||
|
||||
} // namespace ue2
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<ue2::LookEntry> {
|
||||
size_t operator()(const ue2::LookEntry &l) const {
|
||||
return ue2::hash_all(l.offset, l.reach);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // ROSE_ROSE_BUILD_LOOKAROUND_H
|
||||
|
@@ -63,9 +63,11 @@
|
||||
#include "util/container.h"
|
||||
#include "util/dump_charclass.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/report_manager.h"
|
||||
#include "util/ue2string.h"
|
||||
#include "util/unordered.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
@@ -77,12 +79,10 @@
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/functional/hash/hash_fwd.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
|
||||
using namespace std;
|
||||
using boost::adaptors::map_values;
|
||||
using boost::hash_combine;
|
||||
|
||||
namespace ue2 {
|
||||
|
||||
@@ -336,7 +336,7 @@ void findUncalcLeavesCandidates(RoseBuildImpl &tbi,
|
||||
const RoseGraph &g = tbi.g;
|
||||
|
||||
vector<RoseVertex> suffix_vertices; // vertices with suffix graphs
|
||||
ue2::unordered_map<const NGHolder *, u32> fcount; // ref count per graph
|
||||
unordered_map<const NGHolder *, u32> fcount; // ref count per graph
|
||||
|
||||
for (auto v : vertices_range(g)) {
|
||||
if (g[v].suffix) {
|
||||
@@ -566,7 +566,7 @@ bool dedupeLeftfixes(RoseBuildImpl &tbi) {
|
||||
for (deque<RoseVertex> &verts : roses | map_values) {
|
||||
DEBUG_PRINTF("group has %zu vertices\n", verts.size());
|
||||
|
||||
ue2::unordered_set<left_id> seen;
|
||||
unordered_set<left_id> seen;
|
||||
|
||||
for (auto jt = verts.begin(), jte = verts.end(); jt != jte; ++jt) {
|
||||
RoseVertex v = *jt;
|
||||
@@ -636,7 +636,7 @@ bool is_equal(const suffix_id &s1, const suffix_id &s2) {
|
||||
void dedupeSuffixes(RoseBuildImpl &tbi) {
|
||||
DEBUG_PRINTF("deduping suffixes\n");
|
||||
|
||||
ue2::unordered_map<suffix_id, set<RoseVertex>> suffix_map;
|
||||
unordered_map<suffix_id, set<RoseVertex>> suffix_map;
|
||||
map<pair<size_t, set<ReportID>>, vector<suffix_id>> part;
|
||||
|
||||
// Collect suffixes into groups.
|
||||
@@ -703,7 +703,7 @@ template<class EngineRef>
|
||||
class Bouquet {
|
||||
private:
|
||||
list<EngineRef> ordering; // Unique list in insert order.
|
||||
typedef ue2::unordered_map<EngineRef, deque<RoseVertex> > BouquetMap;
|
||||
using BouquetMap = ue2_unordered_map<EngineRef, deque<RoseVertex>>;
|
||||
BouquetMap bouquet;
|
||||
public:
|
||||
void insert(const EngineRef &h, RoseVertex v) {
|
||||
@@ -1331,7 +1331,7 @@ bool mergeRosePair(RoseBuildImpl &tbi, left_id &r1, left_id &r2,
|
||||
static
|
||||
void processMergeQueue(RoseBuildImpl &tbi, RoseBouquet &roses,
|
||||
priority_queue<RoseMergeCandidate> &pq) {
|
||||
ue2::unordered_set<left_id> dead;
|
||||
unordered_set<left_id> dead;
|
||||
|
||||
DEBUG_PRINTF("merge queue has %zu entries\n", pq.size());
|
||||
|
||||
@@ -1862,7 +1862,7 @@ void mergeNfaLeftfixes(RoseBuildImpl &tbi, RoseBouquet &roses) {
|
||||
|
||||
// We track the number of accelerable states for each graph in a map and
|
||||
// only recompute them when the graph is modified.
|
||||
ue2::unordered_map<left_id, u32> accel_count;
|
||||
unordered_map<left_id, u32> accel_count;
|
||||
for (const auto &rose : roses) {
|
||||
assert(rose.graph()->kind == NFA_INFIX);
|
||||
accel_count[rose] = estimatedAccelStates(tbi, *rose.graph());
|
||||
@@ -2157,7 +2157,7 @@ void mergeSuffixes(RoseBuildImpl &tbi, SuffixBouquet &suffixes,
|
||||
// If this isn't an acyclic case, we track the number of accelerable states
|
||||
// for each graph in a map and only recompute them when the graph is
|
||||
// modified.
|
||||
ue2::unordered_map<suffix_id, u32> accel_count;
|
||||
unordered_map<suffix_id, u32> accel_count;
|
||||
if (!acyclic) {
|
||||
for (const auto &suffix : suffixes) {
|
||||
assert(suffix.graph() && suffix.graph()->kind == NFA_SUFFIX);
|
||||
@@ -2499,7 +2499,7 @@ private:
|
||||
template<class RawDfa, class MergeFunctor>
|
||||
static
|
||||
void pairwiseDfaMerge(vector<RawDfa *> &dfas,
|
||||
ue2::unordered_map<RawDfa *, size_t> &dfa_mapping,
|
||||
unordered_map<RawDfa *, size_t> &dfa_mapping,
|
||||
vector<OutfixInfo> &outfixes,
|
||||
MergeFunctor merge_func) {
|
||||
DEBUG_PRINTF("merging group of size %zu\n", dfas.size());
|
||||
@@ -2541,7 +2541,7 @@ void pairwiseDfaMerge(vector<RawDfa *> &dfas,
|
||||
template<class RawDfa, class MergeFunctor>
|
||||
static
|
||||
void chunkedDfaMerge(vector<RawDfa *> &dfas,
|
||||
ue2::unordered_map<RawDfa *, size_t> &dfa_mapping,
|
||||
unordered_map<RawDfa *, size_t> &dfa_mapping,
|
||||
vector<OutfixInfo> &outfixes,
|
||||
MergeFunctor merge_func) {
|
||||
DEBUG_PRINTF("begin merge of %zu dfas\n", dfas.size());
|
||||
@@ -2575,7 +2575,7 @@ void mergeOutfixDfas(RoseBuildImpl &tbi, vector<raw_dfa *> &dfas) {
|
||||
|
||||
/* key is index into outfix array as iterators, etc may be invalidated by
|
||||
* element addition. */
|
||||
ue2::unordered_map<raw_dfa *, size_t> dfa_mapping;
|
||||
unordered_map<raw_dfa *, size_t> dfa_mapping;
|
||||
for (size_t i = 0; i < outfixes.size(); i++) {
|
||||
auto *rdfa = outfixes[i].rdfa();
|
||||
if (rdfa) {
|
||||
@@ -2619,7 +2619,7 @@ void mergeOutfixCombo(RoseBuildImpl &tbi, const ReportManager &rm,
|
||||
/* key is index into outfix array as iterators, etc may be invalidated by
|
||||
* element addition. */
|
||||
size_t new_dfas = 0;
|
||||
ue2::unordered_map<raw_dfa *, size_t> dfa_mapping;
|
||||
unordered_map<raw_dfa *, size_t> dfa_mapping;
|
||||
vector<raw_dfa *> dfas;
|
||||
|
||||
for (auto it = tbi.outfixes.begin(); it != tbi.outfixes.end(); ++it) {
|
||||
@@ -2670,7 +2670,7 @@ void mergeOutfixHaigs(RoseBuildImpl &tbi, vector<raw_som_dfa *> &dfas,
|
||||
|
||||
vector<OutfixInfo> &outfixes = tbi.outfixes;
|
||||
|
||||
ue2::unordered_map<raw_som_dfa *, size_t> dfa_mapping;
|
||||
unordered_map<raw_som_dfa *, size_t> dfa_mapping;
|
||||
for (size_t i = 0; i < outfixes.size(); i++) {
|
||||
auto *haig = outfixes[i].haig();
|
||||
if (haig) {
|
||||
|
@@ -56,11 +56,9 @@
|
||||
#include "ue2common.h"
|
||||
#include "grey.h"
|
||||
|
||||
#include <boost/functional/hash/hash_fwd.hpp>
|
||||
#include <boost/graph/breadth_first_search.hpp>
|
||||
|
||||
using namespace std;
|
||||
using boost::hash_combine;
|
||||
|
||||
namespace ue2 {
|
||||
|
||||
@@ -691,16 +689,7 @@ set<u32> all_tops(const suffix_id &s) {
|
||||
}
|
||||
|
||||
size_t suffix_id::hash() const {
|
||||
size_t val = 0;
|
||||
hash_combine(val, g);
|
||||
hash_combine(val, c);
|
||||
hash_combine(val, d);
|
||||
hash_combine(val, h);
|
||||
return val;
|
||||
}
|
||||
|
||||
size_t hash_value(const suffix_id &s) {
|
||||
return s.hash();
|
||||
return hash_all(g, c, d, h);
|
||||
}
|
||||
|
||||
bool isAnchored(const left_id &r) {
|
||||
@@ -761,16 +750,7 @@ u32 num_tops(const left_id &r) {
|
||||
}
|
||||
|
||||
size_t left_id::hash() const {
|
||||
size_t val = 0;
|
||||
hash_combine(val, g);
|
||||
hash_combine(val, c);
|
||||
hash_combine(val, d);
|
||||
hash_combine(val, h);
|
||||
return val;
|
||||
}
|
||||
|
||||
size_t hash_value(const left_id &r) {
|
||||
return r.hash();
|
||||
return hash_all(g, c, d, h);
|
||||
}
|
||||
|
||||
u64a findMaxOffset(const set<ReportID> &reports, const ReportManager &rm) {
|
||||
@@ -997,8 +977,8 @@ bool canImplementGraphs(const RoseBuildImpl &tbi) {
|
||||
bool hasOrphanedTops(const RoseBuildImpl &build) {
|
||||
const RoseGraph &g = build.g;
|
||||
|
||||
ue2::unordered_map<left_id, set<u32> > roses;
|
||||
ue2::unordered_map<suffix_id, set<u32> > suffixes;
|
||||
unordered_map<left_id, set<u32>> roses;
|
||||
unordered_map<suffix_id, set<u32>> suffixes;
|
||||
|
||||
for (auto v : vertices_range(g)) {
|
||||
if (g[v].left) {
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "util/compile_context.h"
|
||||
#include "util/compile_error.h"
|
||||
#include "util/report_manager.h"
|
||||
#include "util/unordered.h"
|
||||
#include "util/verify_types.h"
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
@@ -226,7 +227,7 @@ size_t RoseProgramHash::operator()(const RoseProgram &program) const {
|
||||
size_t v = 0;
|
||||
for (const auto &ri : program) {
|
||||
assert(ri);
|
||||
boost::hash_combine(v, ri->hash());
|
||||
hash_combine(v, ri->hash());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -1934,14 +1935,14 @@ void makeGroupSquashInstruction(const RoseBuildImpl &build, u32 lit_id,
|
||||
|
||||
namespace {
|
||||
struct ProgKey {
|
||||
ProgKey(const RoseProgram &p) : prog(&p) { }
|
||||
ProgKey(const RoseProgram &p) : prog(&p) {}
|
||||
|
||||
bool operator==(const ProgKey &b) const {
|
||||
return RoseProgramEquivalence()(*prog, *b.prog);
|
||||
}
|
||||
|
||||
friend size_t hash_value(const ProgKey &a) {
|
||||
return RoseProgramHash()(*a.prog);
|
||||
size_t hash() const {
|
||||
return RoseProgramHash()(*prog);
|
||||
}
|
||||
private:
|
||||
const RoseProgram *prog;
|
||||
@@ -1954,7 +1955,7 @@ RoseProgram assembleProgramBlocks(vector<RoseProgram> &&blocks_in) {
|
||||
vector<RoseProgram> blocks;
|
||||
blocks.reserve(blocks_in.size()); /* to ensure stable reference for seen */
|
||||
|
||||
unordered_set<ProgKey> seen;
|
||||
ue2_unordered_set<ProgKey> seen;
|
||||
for (auto &block : blocks_in) {
|
||||
if (contains(seen, block)) {
|
||||
continue;
|
||||
|
@@ -34,8 +34,8 @@
|
||||
#include "util/bytecode_ptr.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/ue2_containers.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
@@ -168,7 +168,7 @@ struct ProgramBuild : noncopyable {
|
||||
|
||||
/** \brief Mapping from vertex to key, for vertices with a
|
||||
* CHECK_NOT_HANDLED instruction. */
|
||||
ue2::unordered_map<RoseVertex, u32> handledKeys;
|
||||
std::unordered_map<RoseVertex, u32> handledKeys;
|
||||
|
||||
/** \brief Mapping from Rose literal ID to anchored program index. */
|
||||
std::map<u32, u32> anchored_programs;
|
||||
@@ -178,7 +178,7 @@ struct ProgramBuild : noncopyable {
|
||||
|
||||
/** \brief Mapping from every vertex to the groups that must be on for that
|
||||
* vertex to be reached. */
|
||||
ue2::unordered_map<RoseVertex, rose_group> vertex_group_map;
|
||||
std::unordered_map<RoseVertex, rose_group> vertex_group_map;
|
||||
|
||||
/** \brief Global bitmap of groups that can be squashed. */
|
||||
rose_group squashable_groups = 0;
|
||||
@@ -239,13 +239,13 @@ struct engine_info {
|
||||
RoseProgram assembleProgramBlocks(std::vector<RoseProgram> &&blocks);
|
||||
|
||||
RoseProgram makeLiteralProgram(const RoseBuildImpl &build,
|
||||
const std::map<RoseVertex, left_build_info> &leftfix_info,
|
||||
const std::map<suffix_id, u32> &suffixes,
|
||||
const std::map<u32, engine_info> &engine_info_by_queue,
|
||||
const unordered_map<RoseVertex, u32> &roleStateIndices,
|
||||
ProgramBuild &prog_build, u32 lit_id,
|
||||
const std::vector<RoseEdge> &lit_edges,
|
||||
bool is_anchored_replay_program);
|
||||
const std::map<RoseVertex, left_build_info> &leftfix_info,
|
||||
const std::map<suffix_id, u32> &suffixes,
|
||||
const std::map<u32, engine_info> &engine_info_by_queue,
|
||||
const std::unordered_map<RoseVertex, u32> &roleStateIndices,
|
||||
ProgramBuild &prog_build, u32 lit_id,
|
||||
const std::vector<RoseEdge> &lit_edges,
|
||||
bool is_anchored_replay_program);
|
||||
|
||||
RoseProgram makeDelayRebuildProgram(const RoseBuildImpl &build,
|
||||
ProgramBuild &prog_build,
|
||||
|
@@ -45,16 +45,15 @@
|
||||
#include "util/bitutils.h"
|
||||
#include "util/compile_context.h"
|
||||
#include "util/container.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/graph.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/order_check.h"
|
||||
#include "util/ue2_containers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
#include <boost/graph/adjacency_iterator.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
|
||||
@@ -154,7 +153,7 @@ public:
|
||||
private:
|
||||
/* if a vertex is worth storing, it is worth storing twice */
|
||||
set<RoseVertex> main_cont; /* deterministic iterator */
|
||||
ue2::unordered_set<RoseVertex> hash_cont; /* member checks */
|
||||
unordered_set<RoseVertex> hash_cont; /* member checks */
|
||||
};
|
||||
|
||||
struct RoseAliasingInfo {
|
||||
@@ -175,10 +174,10 @@ struct RoseAliasingInfo {
|
||||
}
|
||||
|
||||
/** \brief Mapping from leftfix to vertices. */
|
||||
ue2::unordered_map<left_id, set<RoseVertex>> rev_leftfix;
|
||||
unordered_map<left_id, set<RoseVertex>> rev_leftfix;
|
||||
|
||||
/** \brief Mapping from undelayed ghost to delayed vertices. */
|
||||
ue2::unordered_map<RoseVertex, set<RoseVertex>> rev_ghost;
|
||||
unordered_map<RoseVertex, set<RoseVertex>> rev_ghost;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -787,7 +786,7 @@ void updateEdgeTops(RoseGraph &g, RoseVertex v, const map<u32, u32> &top_map) {
|
||||
static
|
||||
void pruneUnusedTops(CastleProto &castle, const RoseGraph &g,
|
||||
const set<RoseVertex> &verts) {
|
||||
ue2::unordered_set<u32> used_tops;
|
||||
unordered_set<u32> used_tops;
|
||||
for (auto v : verts) {
|
||||
assert(g[v].left.castle.get() == &castle);
|
||||
|
||||
@@ -818,7 +817,7 @@ void pruneUnusedTops(NGHolder &h, const RoseGraph &g,
|
||||
}
|
||||
assert(isCorrectlyTopped(h));
|
||||
DEBUG_PRINTF("pruning unused tops\n");
|
||||
ue2::flat_set<u32> used_tops;
|
||||
flat_set<u32> used_tops;
|
||||
for (auto v : verts) {
|
||||
assert(g[v].left.graph.get() == &h);
|
||||
|
||||
@@ -1415,7 +1414,7 @@ void removeSingletonBuckets(vector<vector<RoseVertex>> &buckets) {
|
||||
|
||||
static
|
||||
void buildInvBucketMap(const vector<vector<RoseVertex>> &buckets,
|
||||
ue2::unordered_map<RoseVertex, size_t> &inv) {
|
||||
unordered_map<RoseVertex, size_t> &inv) {
|
||||
inv.clear();
|
||||
for (size_t i = 0; i < buckets.size(); i++) {
|
||||
for (auto v : buckets[i]) {
|
||||
@@ -1469,7 +1468,7 @@ void splitByReportSuffixBehaviour(const RoseGraph &g,
|
||||
vector<vector<RoseVertex>> &buckets) {
|
||||
// Split by report set and suffix info.
|
||||
auto make_split_key = [&g](RoseVertex v) {
|
||||
return hash_all(g[v].reports, g[v].suffix);
|
||||
return hash_all(g[v].reports, suffix_id(g[v].suffix));
|
||||
};
|
||||
splitAndFilterBuckets(buckets, make_split_key);
|
||||
}
|
||||
@@ -1483,14 +1482,15 @@ void splitByLiteralTable(const RoseBuildImpl &build,
|
||||
auto make_split_key = [&](RoseVertex v) {
|
||||
const auto &lits = g[v].literals;
|
||||
assert(!lits.empty());
|
||||
return build.literals.at(*lits.begin()).table;
|
||||
auto table = build.literals.at(*lits.begin()).table;
|
||||
return std::underlying_type<decltype(table)>::type(table);
|
||||
};
|
||||
splitAndFilterBuckets(buckets, make_split_key);
|
||||
}
|
||||
|
||||
static
|
||||
void splitByNeighbour(const RoseGraph &g, vector<vector<RoseVertex>> &buckets,
|
||||
ue2::unordered_map<RoseVertex, size_t> &inv, bool succ) {
|
||||
unordered_map<RoseVertex, size_t> &inv, bool succ) {
|
||||
vector<vector<RoseVertex>> extras;
|
||||
map<size_t, vector<RoseVertex>> neighbours_by_bucket;
|
||||
set<RoseVertex> picked;
|
||||
@@ -1575,7 +1575,7 @@ splitDiamondMergeBuckets(CandidateSet &candidates, const RoseBuildImpl &build) {
|
||||
}
|
||||
|
||||
// Neighbour splits require inverse map.
|
||||
ue2::unordered_map<RoseVertex, size_t> inv;
|
||||
unordered_map<RoseVertex, size_t> inv;
|
||||
buildInvBucketMap(buckets, inv);
|
||||
|
||||
splitByNeighbour(g, buckets, inv, true);
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include "nfa/nfa_internal.h" // for MO_INVALID_IDX
|
||||
#include "util/charreach.h"
|
||||
#include "util/depth.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/ue2_graph.h"
|
||||
|
||||
#include <memory>
|
||||
|
@@ -45,7 +45,7 @@
|
||||
|
||||
#include "ue2common.h"
|
||||
#include "rose/rose_common.h"
|
||||
#include "util/ue2_containers.h"
|
||||
#include "util/flat_containers.h"
|
||||
#include "util/ue2_graph.h"
|
||||
#include "util/ue2string.h"
|
||||
|
||||
|
@@ -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:
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "util/container.h"
|
||||
#include "util/graph_range.h"
|
||||
#include "util/make_unique.h"
|
||||
#include "util/ue2_containers.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
Reference in New Issue
Block a user