mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
switch over to tracking current Body's rather than individual components
This commit is contained in:
parent
16c46a3462
commit
f92acb3a4c
5 changed files with 26 additions and 13 deletions
|
@ -216,6 +216,16 @@ public:
|
|||
*/
|
||||
void AddFunc(detail::ScriptFuncPtr f);
|
||||
|
||||
/**
|
||||
* @return The name associated with the group.
|
||||
*/
|
||||
const auto& GetName() const { return name; }
|
||||
|
||||
/**
|
||||
* @return The type of group.
|
||||
*/
|
||||
const auto& GetEventGroupKind() const { return kind; }
|
||||
|
||||
private:
|
||||
void UpdateFuncBodies();
|
||||
|
||||
|
|
|
@ -265,9 +265,7 @@ public:
|
|||
*/
|
||||
void ReplaceBody(const detail::StmtPtr& old_body, detail::StmtPtr new_body);
|
||||
|
||||
StmtPtr CurrentBody() const { return current_body.stmts; }
|
||||
int CurrentPriority() const { return current_body.priority; }
|
||||
auto CurrentEventGroups() const { return current_body.groups; }
|
||||
auto CurrentBody() const { return current_body; }
|
||||
|
||||
/**
|
||||
* Returns the function's frame size.
|
||||
|
|
|
@ -299,7 +299,11 @@ void Inliner::CoalesceEventHandlers(ScriptFuncPtr func, const std::vector<Func::
|
|||
|
||||
PostInline(oi, inlined_func);
|
||||
|
||||
funcs.emplace_back(inlined_func, new_scope, merged_body, 0);
|
||||
// We don't need to worry about event groups because the CoalescedScriptFunc
|
||||
// wrapper checks at run-time for whether any handlers have been disabled,
|
||||
// and if so skips coalesced execution.
|
||||
Func::Body body{.stmts = merged_body, .priority = 0};
|
||||
funcs.emplace_back(inlined_func, new_scope, std::move(body));
|
||||
|
||||
auto pf = std::make_shared<ProfileFunc>(inlined_func.get(), merged_body, true);
|
||||
funcs.back().SetProfile(std::move(pf));
|
||||
|
|
|
@ -41,7 +41,7 @@ void analyze_func(ScriptFuncPtr f) {
|
|||
// Even if we're analyzing only a subset of the scripts, we still
|
||||
// track all functions here because the inliner will need the full list.
|
||||
ASSERT(f->GetScope());
|
||||
funcs.emplace_back(f, f->GetScope(), f->CurrentBody(), f->CurrentPriority());
|
||||
funcs.emplace_back(f, f->GetScope(), f->CurrentBody());
|
||||
}
|
||||
|
||||
void analyze_lambda(LambdaExpr* l) {
|
||||
|
@ -78,7 +78,8 @@ void analyze_global_stmts(Stmt* stmts) {
|
|||
global_stmts->SetScope(sc);
|
||||
|
||||
global_stmts_ind = funcs.size();
|
||||
funcs.emplace_back(global_stmts, sc, stmts->ThisPtr(), 0);
|
||||
Func::Body body{.stmts = stmts->ThisPtr(), .priority = 0};
|
||||
funcs.emplace_back(global_stmts, sc, body);
|
||||
}
|
||||
|
||||
std::pair<StmtPtr, ScopePtr> get_global_stmts() {
|
||||
|
|
|
@ -154,19 +154,20 @@ using ScriptFuncPtr = IntrusivePtr<ScriptFunc>;
|
|||
// Info we need for tracking an instance of a function.
|
||||
class FuncInfo {
|
||||
public:
|
||||
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body, int _priority)
|
||||
: func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body)), priority(_priority) {}
|
||||
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, Func::Body _body)
|
||||
: func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body)) {}
|
||||
|
||||
ScriptFunc* Func() const { return func.get(); }
|
||||
const ScriptFuncPtr& FuncPtr() const { return func; }
|
||||
const ScopePtr& Scope() const { return scope; }
|
||||
const StmtPtr& Body() const { return body; }
|
||||
int Priority() const { return priority; }
|
||||
const StmtPtr& Body() const { return body.stmts; }
|
||||
int Priority() const { return body.priority; }
|
||||
auto EventGroups() const { return body.groups; }
|
||||
const ProfileFunc* Profile() const { return pf.get(); }
|
||||
std::shared_ptr<ProfileFunc> ProfilePtr() const { return pf; }
|
||||
|
||||
void SetScope(ScopePtr new_scope) { scope = std::move(new_scope); }
|
||||
void SetBody(StmtPtr new_body) { body = std::move(new_body); }
|
||||
void SetBody(StmtPtr new_body) { body.stmts = std::move(new_body); }
|
||||
void SetProfile(std::shared_ptr<ProfileFunc> _pf) { pf = std::move(_pf); }
|
||||
|
||||
bool ShouldAnalyze() const { return should_analyze; }
|
||||
|
@ -183,9 +184,8 @@ public:
|
|||
protected:
|
||||
ScriptFuncPtr func;
|
||||
ScopePtr scope;
|
||||
StmtPtr body;
|
||||
Func::Body body;
|
||||
std::shared_ptr<ProfileFunc> pf;
|
||||
int priority;
|
||||
|
||||
// Whether to analyze this function at all, per optimization selection
|
||||
// via --optimize-file/--optimize-func. If those flags aren't used,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue