mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: reduce anchored program dep on final_id
We only need to build anchored programs for cases where a RECORD_ANCHORED instruction has been generated, and we can key those directly rather than using final_id.
This commit is contained in:
parent
ea8d0bcb1c
commit
c426d2dc7d
@ -103,7 +103,7 @@ void rosePushDelayedMatch(const struct RoseEngine *t,
|
|||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
void recordAnchoredLiteralMatch(const struct RoseEngine *t,
|
void recordAnchoredLiteralMatch(const struct RoseEngine *t,
|
||||||
struct hs_scratch *scratch, u32 literal_id,
|
struct hs_scratch *scratch, u32 anch_id,
|
||||||
u64a end) {
|
u64a end) {
|
||||||
assert(end);
|
assert(end);
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ void recordAnchoredLiteralMatch(const struct RoseEngine *t,
|
|||||||
|
|
||||||
struct fatbit **anchoredLiteralRows = getAnchoredLiteralLog(scratch);
|
struct fatbit **anchoredLiteralRows = getAnchoredLiteralLog(scratch);
|
||||||
|
|
||||||
DEBUG_PRINTF("record %u @ %llu\n", literal_id, end);
|
DEBUG_PRINTF("record %u (of %u) @ %llu\n", anch_id, t->anchored_count, end);
|
||||||
|
|
||||||
if (!bf64_set(&scratch->al_log_sum, end - 1)) {
|
if (!bf64_set(&scratch->al_log_sum, end - 1)) {
|
||||||
// first time, clear row
|
// first time, clear row
|
||||||
@ -121,11 +121,8 @@ void recordAnchoredLiteralMatch(const struct RoseEngine *t,
|
|||||||
fatbit_clear(anchoredLiteralRows[end - 1]);
|
fatbit_clear(anchoredLiteralRows[end - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 rel_idx = literal_id - t->anchored_base_id;
|
assert(anch_id < t->anchored_count);
|
||||||
DEBUG_PRINTF("record %u @ %llu index %u/%u\n", literal_id, end, rel_idx,
|
fatbit_set(anchoredLiteralRows[end - 1], t->anchored_count, anch_id);
|
||||||
t->anchored_count);
|
|
||||||
assert(rel_idx < t->anchored_count);
|
|
||||||
fatbit_set(anchoredLiteralRows[end - 1], t->anchored_count, rel_idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static rose_inline
|
static rose_inline
|
||||||
|
@ -246,6 +246,9 @@ struct build_context : boost::noncopyable {
|
|||||||
|
|
||||||
/** \brief Mapping from final ID to the set of literals it is used for. */
|
/** \brief Mapping from final ID to the set of literals it is used for. */
|
||||||
map<u32, flat_set<u32>> final_id_to_literal;
|
map<u32, flat_set<u32>> final_id_to_literal;
|
||||||
|
|
||||||
|
/** \brief Mapping from final ID to anchored program index. */
|
||||||
|
map<u32, u32> anchored_programs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief subengine info including built engine and
|
/** \brief subengine info including built engine and
|
||||||
@ -4269,7 +4272,14 @@ void makeRecordAnchoredInstruction(const RoseBuildImpl &build,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
program.add_before_end(make_unique<RoseInstrRecordAnchored>(final_id));
|
auto it = bc.anchored_programs.find(final_id);
|
||||||
|
if (it == bc.anchored_programs.end()) {
|
||||||
|
u32 anch_id = verify_u32(bc.anchored_programs.size());
|
||||||
|
it = bc.anchored_programs.emplace(final_id, anch_id).first;
|
||||||
|
DEBUG_PRINTF("added anch_id=%u for final_id %u\n", anch_id, final_id);
|
||||||
|
}
|
||||||
|
u32 anch_id = it->second;
|
||||||
|
program.add_before_end(make_unique<RoseInstrRecordAnchored>(anch_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -4757,11 +4767,14 @@ u32 buildAnchoredPrograms(RoseBuildImpl &build, build_context &bc) {
|
|||||||
auto lit_edge_map = findEdgesByLiteral(build);
|
auto lit_edge_map = findEdgesByLiteral(build);
|
||||||
|
|
||||||
vector<u32> programs;
|
vector<u32> programs;
|
||||||
|
programs.resize(bc.anchored_programs.size(), ROSE_INVALID_PROG_OFFSET);
|
||||||
|
|
||||||
for (u32 final_id = build.anchored_base_id;
|
for (const auto &m : bc.anchored_programs) {
|
||||||
final_id < build.delay_base_id; final_id++) {
|
u32 final_id = m.first;
|
||||||
|
u32 anch_id = m.second;
|
||||||
u32 offset = writeLiteralProgram(build, bc, {final_id}, lit_edge_map);
|
u32 offset = writeLiteralProgram(build, bc, {final_id}, lit_edge_map);
|
||||||
programs.push_back(offset);
|
DEBUG_PRINTF("final_id %u -> anch prog at %u\n", final_id, offset);
|
||||||
|
programs[anch_id] = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("%zu anchored programs\n", programs.size());
|
DEBUG_PRINTF("%zu anchored programs\n", programs.size());
|
||||||
@ -5704,7 +5717,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
engine->delay_fatbit_size = fatbit_size(engine->delay_count);
|
engine->delay_fatbit_size = fatbit_size(engine->delay_count);
|
||||||
engine->delay_base_id = delay_base_id;
|
engine->delay_base_id = delay_base_id;
|
||||||
engine->anchored_base_id = anchored_base_id;
|
engine->anchored_base_id = anchored_base_id;
|
||||||
engine->anchored_count = delay_base_id - anchored_base_id;
|
engine->anchored_count = bc.anchored_programs.size();
|
||||||
engine->anchored_fatbit_size = fatbit_size(engine->anchored_count);
|
engine->anchored_fatbit_size = fatbit_size(engine->anchored_count);
|
||||||
|
|
||||||
engine->rosePrefixCount = rosePrefixCount;
|
engine->rosePrefixCount = rosePrefixCount;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user