Merge remote-tracking branch 'origin/topic/vern/ZAM-assert-streamlining'

* origin/topic/vern/ZAM-assert-streamlining:
  simplified ZAM instructions for executing "assert" statements
This commit is contained in:
Tim Wojtulewicz 2024-12-13 12:14:46 -07:00
commit d788ab8f0e
4 changed files with 19 additions and 17 deletions

View file

@ -1,3 +1,7 @@
7.1.0-dev.823 | 2024-12-13 12:14:46 -0700
* simplified ZAM instructions for executing "assert" statements (Vern Paxson, Corelight)
7.1.0-dev.821 | 2024-12-13 12:14:17 -0700 7.1.0-dev.821 | 2024-12-13 12:14:17 -0700
* cirrus/container_image_manifest: match RC tags, too (Arne Welzel, Corelight) * cirrus/container_image_manifest: match RC tags, too (Arne Welzel, Corelight)

View file

@ -1 +1 @@
7.1.0-dev.821 7.1.0-dev.823

View file

@ -348,22 +348,20 @@ eval static auto assertion_result_hook = id::find_func("assertion_result");
$$ = ! $1 || run_result_hook; $$ = ! $1 || run_result_hook;
op Report-Assert op Report-Assert
# Operands are (1) result from Should-Report-Assert, (2) assertion value, # Operands are (1) assertion value, (2) description of the condition
# (3) description of the condition (always a constant). # (always a constant).
op1-read op1-read
classes VVC classes VC
op-types I I S op-types I S
eval if ( $$ ) eval {
{ zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString(); report_assert($$, $1->ToStdString(), msg_val, Z_LOC->Loc());
report_assert($1, $2->ToStdString(), msg_val, Z_LOC->Loc()); }
}
op Report-Assert-With-Message op Report-Assert-With-Message
# The same, but with an additional operand being the associated message # The same, but with an additional operand being the associated message
# (as a variable, so it comes in $2 rather than $3). # (as a variable, so it comes in $1 rather than $2).
op1-read op1-read
classes VVVC classes VVC
op-types I I S S op-types I S S
eval if ( $$ ) eval report_assert($$, $2->ToStdString(), {NewRef{}, $1}, Z_LOC->Loc());
report_assert($1, $3->ToStdString(), {NewRef{}, $2}, Z_LOC->Loc());

View file

@ -1083,10 +1083,10 @@ const ZAMStmt ZAMCompiler::CompileAssert(const AssertStmt* as) {
else else
msg_slot = FrameSlot(msg->AsNameExpr()); msg_slot = FrameSlot(msg->AsNameExpr());
z = ZInstI(OP_REPORT_ASSERT_WITH_MESSAGE_VVVC, decision_slot, cond_slot, msg_slot, cond_desc_e.get()); z = ZInstI(OP_REPORT_ASSERT_WITH_MESSAGE_VVC, cond_slot, msg_slot, cond_desc_e.get());
} }
else else
z = ZInstI(OP_REPORT_ASSERT_VVC, decision_slot, cond_slot, cond_desc_e.get()); z = ZInstI(OP_REPORT_ASSERT_VC, cond_slot, cond_desc_e.get());
auto end_inst = AddInst(z); auto end_inst = AddInst(z);
AddCFT(insts1.back(), CFT_BLOCK_END); AddCFT(insts1.back(), CFT_BLOCK_END);