mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 19:47:43 +03:00
bytecode_ptr: add make_zeroed_bytecode_ptr
Rather than always zeroing memory.
This commit is contained in:
committed by
Matthew Barr
parent
5653fa55a1
commit
63fe84c3f1
@@ -579,7 +579,7 @@ buildCastle(const CastleProto &proto,
|
||||
total_size = ROUNDUP_N(total_size, alignof(mmbit_sparse_iter));
|
||||
total_size += byte_length(stale_iter); // stale sparse iter
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
nfa->type = verify_u8(CASTLE_NFA);
|
||||
nfa->length = verify_u32(total_size);
|
||||
nfa->nPositions = verify_u32(subs.size());
|
||||
|
@@ -1116,7 +1116,7 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
|
||||
gi.stream_som_loc_width = somPrecision;
|
||||
|
||||
u32 gough_size = ROUNDUP_N(curr_offset, 16);
|
||||
auto gough_dfa = make_bytecode_ptr<NFA>(gough_size);
|
||||
auto gough_dfa = make_zeroed_bytecode_ptr<NFA>(gough_size);
|
||||
|
||||
memcpy(gough_dfa.get(), basic_dfa.get(), basic_dfa->length);
|
||||
memcpy((char *)gough_dfa.get() + haig_offset, &gi, sizeof(gi));
|
||||
|
@@ -1797,7 +1797,7 @@ struct Factory {
|
||||
|
||||
u32 tableOffset, tugMaskOffset;
|
||||
size_t len = repeatAllocSize(br, &tableOffset, &tugMaskOffset);
|
||||
auto info = make_bytecode_ptr<NFARepeatInfo>(len);
|
||||
auto info = make_zeroed_bytecode_ptr<NFARepeatInfo>(len);
|
||||
char *info_ptr = (char *)info.get();
|
||||
|
||||
// Collect state space info.
|
||||
@@ -2297,7 +2297,7 @@ struct Factory {
|
||||
|
||||
size_t nfaSize = sizeof(NFA) + offset;
|
||||
DEBUG_PRINTF("nfa size %zu\n", nfaSize);
|
||||
auto nfa = make_bytecode_ptr<NFA>(nfaSize);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(nfaSize);
|
||||
assert(nfa); // otherwise we would have thrown std::bad_alloc
|
||||
|
||||
implNFA_t *limex = (implNFA_t *)getMutableImplNfa(nfa.get());
|
||||
|
@@ -496,7 +496,7 @@ bytecode_ptr<NFA> mcclellanCompile16(dfa_info &info, const CompileContext &cc,
|
||||
accel_offset -= sizeof(NFA); /* adj accel offset to be relative to m */
|
||||
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
char *nfa_base = (char *)nfa.get();
|
||||
|
||||
populateBasicInfo(sizeof(u16), info, total_size, aux_offset, accel_offset,
|
||||
@@ -715,7 +715,7 @@ bytecode_ptr<NFA> mcclellanCompile8(dfa_info &info, const CompileContext &cc,
|
||||
accel_offset -= sizeof(NFA); /* adj accel offset to be relative to m */
|
||||
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
|
||||
|
||||
auto nfa = bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
char *nfa_base = (char *)nfa.get();
|
||||
|
||||
mcclellan *m = (mcclellan *)getMutableImplNfa(nfa.get());
|
||||
|
@@ -872,7 +872,7 @@ bytecode_ptr<NFA> mcshengCompile16(dfa_info &info, dstate_id_t sheng_end,
|
||||
accel_offset -= sizeof(NFA); /* adj accel offset to be relative to m */
|
||||
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
mcsheng *m = (mcsheng *)getMutableImplNfa(nfa.get());
|
||||
|
||||
populateBasicInfo(sizeof(u16), info, total_size, aux_offset, accel_offset,
|
||||
@@ -998,7 +998,7 @@ bytecode_ptr<NFA> mcshengCompile8(dfa_info &info, dstate_id_t sheng_end,
|
||||
accel_offset -= sizeof(NFA); /* adj accel offset to be relative to m */
|
||||
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
mcsheng *m = (mcsheng *)getMutableImplNfa(nfa.get());
|
||||
|
||||
allocateImplId8(info, sheng_end, accel_escape_info, &m->accel_limit_8,
|
||||
|
@@ -343,7 +343,7 @@ bytecode_ptr<NFA> mpvCompile(const vector<raw_puff> &puffs_in,
|
||||
|
||||
DEBUG_PRINTF("%u puffs, len = %u\n", puffette_count, len);
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(len);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(len);
|
||||
|
||||
mpv_puffette *pa_base = (mpv_puffette *)
|
||||
((char *)nfa.get() + sizeof(NFA) + sizeof(mpv)
|
||||
|
@@ -507,7 +507,7 @@ bytecode_ptr<NFA> shengCompile(raw_dfa &raw, const CompileContext &cc,
|
||||
DEBUG_PRINTF("NFA: %u, aux: %u, reports: %u, accel: %u, total: %u\n",
|
||||
nfa_size, total_aux, total_reports, total_accel, total_size);
|
||||
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
|
||||
populateBasicInfo(nfa.get(), info, accelInfo, nfa_size, reports_offset,
|
||||
accel_offset, total_size, total_size - sizeof(NFA));
|
||||
|
@@ -134,7 +134,7 @@ buildTamarama(const TamaInfo &tamaInfo, const u32 queue,
|
||||
// use subSize as a sentinel value for no active subengines,
|
||||
// so add one to subSize here
|
||||
u32 activeIdxSize = calcPackedBytes(subSize + 1);
|
||||
auto nfa = make_bytecode_ptr<NFA>(total_size);
|
||||
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
|
||||
nfa->type = verify_u8(TAMARAMA_NFA);
|
||||
nfa->length = verify_u32(total_size);
|
||||
nfa->queueIndex = queue;
|
||||
|
Reference in New Issue
Block a user