mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose_build_anchored: use bytecode_ptr
This commit is contained in:
parent
7b17d418e7
commit
905ac78061
@ -869,14 +869,13 @@ vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
|
|||||||
return dfas;
|
return dfas;
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<anchored_matcher_info>
|
bytecode_ptr<anchored_matcher_info>
|
||||||
buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
|
buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
|
||||||
vector<raw_dfa> &dfas, size_t *asize) {
|
vector<raw_dfa> &dfas) {
|
||||||
const CompileContext &cc = build.cc;
|
const CompileContext &cc = build.cc;
|
||||||
|
|
||||||
if (dfas.empty()) {
|
if (dfas.empty()) {
|
||||||
DEBUG_PRINTF("empty\n");
|
DEBUG_PRINTF("empty\n");
|
||||||
*asize = 0;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,8 +891,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
|
|||||||
throw ResourceLimitError();
|
throw ResourceLimitError();
|
||||||
}
|
}
|
||||||
|
|
||||||
*asize = total_size;
|
auto atable = make_bytecode_ptr<anchored_matcher_info>(total_size, 64);
|
||||||
auto atable = aligned_zmalloc_unique<anchored_matcher_info>(total_size);
|
|
||||||
char *curr = (char *)atable.get();
|
char *curr = (char *)atable.get();
|
||||||
|
|
||||||
u32 state_offset = 0;
|
u32 state_offset = 0;
|
||||||
@ -919,7 +917,7 @@ buildAnchoredMatcher(RoseBuildImpl &build, const vector<LitFragment> &fragments,
|
|||||||
ami->anchoredMinDistance = start_offset[i];
|
ami->anchoredMinDistance = start_offset[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("success %zu\n", *asize);
|
DEBUG_PRINTF("success %zu\n", atable.size());
|
||||||
return atable;
|
return atable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
#include "rose_build_impl.h"
|
#include "rose_build_impl.h"
|
||||||
#include "nfagraph/ng_holder.h"
|
#include "nfagraph/ng_holder.h"
|
||||||
#include "util/alloc.h"
|
#include "util/bytecode_ptr.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -59,10 +59,10 @@ std::vector<raw_dfa> buildAnchoredDfas(RoseBuildImpl &build,
|
|||||||
* Remap the literal final_ids used for raw_dfa reports to the program offsets
|
* Remap the literal final_ids used for raw_dfa reports to the program offsets
|
||||||
* given in litPrograms.
|
* given in litPrograms.
|
||||||
*/
|
*/
|
||||||
aligned_unique_ptr<anchored_matcher_info>
|
bytecode_ptr<anchored_matcher_info>
|
||||||
buildAnchoredMatcher(RoseBuildImpl &build,
|
buildAnchoredMatcher(RoseBuildImpl &build,
|
||||||
const std::vector<LitFragment> &fragments,
|
const std::vector<LitFragment> &fragments,
|
||||||
std::vector<raw_dfa> &dfas, size_t *asize);
|
std::vector<raw_dfa> &dfas);
|
||||||
|
|
||||||
u32 anchoredStateSize(const anchored_matcher_info &atable);
|
u32 anchoredStateSize(const anchored_matcher_info &atable);
|
||||||
|
|
||||||
|
@ -5824,10 +5824,9 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
writeLeftInfo(bc.engine_blob, proto, leftInfoTable);
|
writeLeftInfo(bc.engine_blob, proto, leftInfoTable);
|
||||||
|
|
||||||
// Build anchored matcher.
|
// Build anchored matcher.
|
||||||
size_t asize = 0;
|
auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas);
|
||||||
auto atable = buildAnchoredMatcher(*this, fragments, anchored_dfas, &asize);
|
|
||||||
if (atable) {
|
if (atable) {
|
||||||
proto.amatcherOffset = bc.engine_blob.add(atable.get(), asize, 64);
|
proto.amatcherOffset = bc.engine_blob.add(atable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build floating HWLM matcher.
|
// Build floating HWLM matcher.
|
||||||
@ -5952,7 +5951,7 @@ bytecode_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
|
|||||||
proto.initialGroups = getInitialGroups();
|
proto.initialGroups = getInitialGroups();
|
||||||
proto.floating_group_mask = fgroups;
|
proto.floating_group_mask = fgroups;
|
||||||
proto.totalNumLiterals = verify_u32(literal_info.size());
|
proto.totalNumLiterals = verify_u32(literal_info.size());
|
||||||
proto.asize = verify_u32(asize);
|
proto.asize = verify_u32(atable.size());
|
||||||
proto.ematcherRegionSize = ematcher_region_size;
|
proto.ematcherRegionSize = ematcher_region_size;
|
||||||
proto.longLitStreamState = verify_u32(longLitStreamStateRequired);
|
proto.longLitStreamState = verify_u32(longLitStreamStateRequired);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user