mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
minor enhancements for ZAM inlining
This commit is contained in:
parent
88c73f4680
commit
94e71b738a
3 changed files with 10 additions and 18 deletions
|
@ -626,8 +626,8 @@ protected:
|
||||||
// type (vec, list, table, record).
|
// type (vec, list, table, record).
|
||||||
bool IsScalarAggregateOp() const;
|
bool IsScalarAggregateOp() const;
|
||||||
|
|
||||||
// Warns about depreciated scalar vector operations like `[1, 2,
|
// Warns about deprecated scalar vector operations like
|
||||||
// 3] == 1` or `["a", "b", "c"] + "a"`.
|
// `[1, 2, 3] == 1` or `["a", "b", "c"] + "a"`.
|
||||||
void CheckScalarAggOp() const;
|
void CheckScalarAggOp() const;
|
||||||
|
|
||||||
ExprPtr op1;
|
ExprPtr op1;
|
||||||
|
@ -1161,6 +1161,7 @@ public:
|
||||||
|
|
||||||
// Optimization-related:
|
// Optimization-related:
|
||||||
ExprPtr Duplicate() override;
|
ExprPtr Duplicate() override;
|
||||||
|
ExprPtr Inline(Inliner* inl) override;
|
||||||
|
|
||||||
bool HasReducedOps(Reducer* c) const override;
|
bool HasReducedOps(Reducer* c) const override;
|
||||||
ExprPtr Reduce(Reducer* c, StmtPtr& red_stmt) override;
|
ExprPtr Reduce(Reducer* c, StmtPtr& red_stmt) override;
|
||||||
|
|
|
@ -1858,6 +1858,12 @@ ExprPtr RecordConstructorExpr::Duplicate()
|
||||||
return SetSucc(new RecordConstructorExpr(op_l));
|
return SetSucc(new RecordConstructorExpr(op_l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExprPtr RecordConstructorExpr::Inline(Inliner* inl)
|
||||||
|
{
|
||||||
|
op = op->Inline(inl)->AsListExprPtr();
|
||||||
|
return ThisPtr();
|
||||||
|
}
|
||||||
|
|
||||||
bool RecordConstructorExpr::HasReducedOps(Reducer* c) const
|
bool RecordConstructorExpr::HasReducedOps(Reducer* c) const
|
||||||
{
|
{
|
||||||
auto& exprs = op->AsListExpr()->Exprs();
|
auto& exprs = op->AsListExpr()->Exprs();
|
||||||
|
|
|
@ -125,23 +125,8 @@ void Inliner::Analyze()
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto& f : funcs )
|
for ( auto& f : funcs )
|
||||||
{
|
if ( should_analyze(f.FuncPtr(), f.Body()) )
|
||||||
const auto& func_ptr = f.FuncPtr();
|
|
||||||
const auto& func = func_ptr.get();
|
|
||||||
const auto& body = f.Body();
|
|
||||||
|
|
||||||
// Processing optimization: only spend time trying to inline f
|
|
||||||
// if we haven't marked it as inlineable. This trades off a
|
|
||||||
// bunch of compilation load (inlining every single function,
|
|
||||||
// even though almost none will be called directly) for a
|
|
||||||
// modest gain of having compiled code for those rare
|
|
||||||
// circumstances in which a Zeek function can be called
|
|
||||||
// not ultimately stemming from an event (such as global
|
|
||||||
// scripting, or expiration functions).
|
|
||||||
|
|
||||||
if ( should_analyze(func_ptr, body) && inline_ables.count(func) == 0 )
|
|
||||||
InlineFunction(&f);
|
InlineFunction(&f);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inliner::InlineFunction(FuncInfo* f)
|
void Inliner::InlineFunction(FuncInfo* f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue