rewrite of ZAM optimization of BiFs and script functions/idioms

This commit is contained in:
Vern Paxson 2024-04-08 18:33:06 -04:00 committed by Tim Wojtulewicz
parent 263093af78
commit 9cddf16800
8 changed files with 1300 additions and 409 deletions

View file

@ -85,6 +85,13 @@ public:
void Dump();
private:
friend class SimpleZBI;
friend class CondZBI;
friend class OptAssignZBI;
friend class SortZBI;
friend class CatZBI;
friend class MultiZBI;
void Init();
void InitGlobals();
void InitArgs();
@ -182,6 +189,7 @@ private:
const ZAMStmt CompileAddToExpr(const AddToExpr* e);
const ZAMStmt CompileRemoveFromExpr(const RemoveFromExpr* e);
const ZAMStmt CompileAssignExpr(const AssignExpr* e);
const ZAMStmt CompileZAMBuiltin(const NameExpr* lhs, const ScriptOptBuiltinExpr* zbi);
const ZAMStmt CompileAssignToIndex(const NameExpr* lhs, const IndexExpr* rhs);
const ZAMStmt CompileFieldLHSAssignExpr(const FieldLHSAssignExpr* e);
const ZAMStmt CompileScheduleExpr(const ScheduleExpr* e);
@ -246,17 +254,8 @@ private:
const ZAMStmt Is(const NameExpr* n, const Expr* e);
#include "zeek/script_opt/ZAM/BuiltIn.h"
#include "zeek/script_opt/ZAM/Inst-Gen.h"
// A bit weird, but handy for switch statements used in built-in
// operations: returns a bit mask of which of the arguments in the
// given list correspond to constants, with the high-ordered bit
// being the first argument (argument "0" in the list) and the
// low-ordered bit being the last. Second parameter is the number
// of arguments that should be present.
zeek_uint_t ConstArgsMask(const ExprPList& args, int nargs) const;
int ConvertToInt(const Expr* e) {
if ( e->Tag() == EXPR_NAME )
return FrameSlot(e->AsNameExpr()->Id());