mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
hook for skipping chains + optimize common case of all-assignments-managed
This commit is contained in:
parent
9d886f61cc
commit
c0045c4643
3 changed files with 28 additions and 4 deletions
|
@ -904,6 +904,10 @@ bool StmtList::SimplifyChain(unsigned int start, unsigned int end, std::vector<S
|
|||
OpChain add_chains;
|
||||
std::set<const Stmt*> chain_stmts;
|
||||
|
||||
static bool skip_chains = getenv("ZAM_SKIP_CHAINS");
|
||||
if ( skip_chains )
|
||||
return false;
|
||||
|
||||
for ( auto i = start; i <= end; ++i ) {
|
||||
auto& s = stmts[i];
|
||||
chain_stmts.insert(s.get());
|
||||
|
|
|
@ -242,7 +242,7 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdates* e) {
|
|||
|
||||
std::set<TypeTag> field_tags;
|
||||
|
||||
bool is_managed = false;
|
||||
size_t num_managed = 0;
|
||||
|
||||
for ( auto i : rhs_map ) {
|
||||
auto rt = rhs->GetType()->AsRecordType();
|
||||
|
@ -251,7 +251,7 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdates* e) {
|
|||
|
||||
if ( ZVal::IsManagedType(rt_ft_i) ) {
|
||||
aux->is_managed.push_back(true);
|
||||
is_managed = true;
|
||||
++num_managed;
|
||||
}
|
||||
else
|
||||
// This will only be needed if is_managed winds up being true,
|
||||
|
@ -269,8 +269,14 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdates* e) {
|
|||
|
||||
ZOp op;
|
||||
|
||||
if ( e->Tag() == EXPR_REC_ASSIGN_FIELDS )
|
||||
op = is_managed ? OP_REC_ASSIGN_FIELDS_MANAGED_VV : OP_REC_ASSIGN_FIELDS_VV;
|
||||
if ( e->Tag() == EXPR_REC_ASSIGN_FIELDS ) {
|
||||
if ( num_managed == rhs_map.size() )
|
||||
op = OP_REC_ASSIGN_FIELDS_ALL_MANAGED_VV;
|
||||
else if ( num_managed > 0 )
|
||||
op = OP_REC_ASSIGN_FIELDS_MANAGED_VV;
|
||||
else
|
||||
op = OP_REC_ASSIGN_FIELDS_VV;
|
||||
}
|
||||
|
||||
else if ( homogeneous ) {
|
||||
if ( field_tags.count(TYPE_DOUBLE) > 0 )
|
||||
|
|
|
@ -1301,6 +1301,20 @@ eval SetUpRecFieldOps()
|
|||
else
|
||||
lhs->RawOptField(lhs_map[i]) = rhs->RawField(rhs_map[i]);
|
||||
|
||||
op Rec-Assign-Fields-All-Managed
|
||||
op1-read
|
||||
type VV
|
||||
eval SetUpRecFieldOps()
|
||||
for ( size_t i = 0U; i < n; ++i )
|
||||
{
|
||||
auto& lhs_i = lhs->RawOptField(lhs_map[i]);
|
||||
auto rhs_i = rhs->RawField(rhs_map[i]);
|
||||
zeek::Ref(rhs_i.ManagedVal());
|
||||
if ( lhs_i )
|
||||
ZVal::DeleteManagedType(*lhs_i);
|
||||
lhs_i = rhs_i;
|
||||
}
|
||||
|
||||
op Rec-Add-Int-Fields
|
||||
op1-read
|
||||
type VV
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue