diff --git a/src/script_opt/Stmt.cc b/src/script_opt/Stmt.cc index d1eebfeccd..b89b44a264 100644 --- a/src/script_opt/Stmt.cc +++ b/src/script_opt/Stmt.cc @@ -904,6 +904,10 @@ bool StmtList::SimplifyChain(unsigned int start, unsigned int end, std::vector 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()); diff --git a/src/script_opt/ZAM/Expr.cc b/src/script_opt/ZAM/Expr.cc index aa01b4728b..81b09c5fdc 100644 --- a/src/script_opt/ZAM/Expr.cc +++ b/src/script_opt/ZAM/Expr.cc @@ -242,7 +242,7 @@ const ZAMStmt ZAMCompiler::CompileRecFieldUpdates(const RecordFieldUpdates* e) { std::set 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 ) diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index fd90ee4b8c..4a6c672f57 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -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