mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
FuncInfo now tracks priority; some tidying/widening of its accessors
This commit is contained in:
parent
8d2bb28f03
commit
72f62f398a
3 changed files with 19 additions and 13 deletions
|
@ -433,7 +433,7 @@ ProfileFuncs::ProfileFuncs(std::vector<FuncInfo>& funcs,
|
|||
f.SetSkip(true);
|
||||
|
||||
f.SetProfile(std::move(pf));
|
||||
func_profs[f.Func()] = f.Profile();
|
||||
func_profs[f.Func()] = f.ProfilePtr();
|
||||
}
|
||||
|
||||
// We now have the main (starting) types used by all of the
|
||||
|
@ -524,7 +524,7 @@ void ProfileFuncs::ComputeBodyHashes(std::vector<FuncInfo>& funcs)
|
|||
{
|
||||
for ( auto& f : funcs )
|
||||
if ( ! f.ShouldSkip() )
|
||||
ComputeProfileHash(f.Profile());
|
||||
ComputeProfileHash(f.ProfilePtr());
|
||||
|
||||
for ( auto& l : lambdas )
|
||||
ComputeProfileHash(ExprProf(l));
|
||||
|
|
|
@ -138,8 +138,10 @@ void optimize_func(ScriptFunc* f, std::shared_ptr<ProfileFunc> pf,
|
|||
}
|
||||
|
||||
|
||||
FuncInfo::FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body)
|
||||
: func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body))
|
||||
FuncInfo::FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body,
|
||||
int _priority)
|
||||
: func(std::move(_func)), scope(std::move(_scope)),
|
||||
body(std::move(_body)), priority(_priority)
|
||||
{}
|
||||
|
||||
void FuncInfo::SetProfile(std::shared_ptr<ProfileFunc> _pf)
|
||||
|
@ -151,7 +153,8 @@ void analyze_func(ScriptFuncPtr f)
|
|||
*analysis_options.only_func != f->Name() )
|
||||
return;
|
||||
|
||||
funcs.emplace_back(f, ScopePtr{NewRef{}, f->GetScope()}, f->CurrentBody());
|
||||
funcs.emplace_back(f, ScopePtr{NewRef{}, f->GetScope()},
|
||||
f->CurrentBody(), f->CurrentPriority());
|
||||
}
|
||||
|
||||
const FuncInfo* analyze_global_stmts(Stmt* stmts)
|
||||
|
@ -170,7 +173,7 @@ const FuncInfo* analyze_global_stmts(Stmt* stmts)
|
|||
StmtPtr stmts_p{NewRef{}, stmts};
|
||||
auto sf = make_intrusive<ScriptFunc>(id, stmts_p, empty_inits, sc->Length(), 0);
|
||||
|
||||
funcs.emplace_back(sf, ScopePtr{NewRef{}, sc}, stmts_p);
|
||||
funcs.emplace_back(sf, ScopePtr{NewRef{}, sc}, stmts_p, 0);
|
||||
|
||||
return &funcs.back();
|
||||
}
|
||||
|
@ -301,7 +304,7 @@ void analyze_scripts()
|
|||
continue;
|
||||
|
||||
auto new_body = f.Body();
|
||||
optimize_func(f.Func(), f.Profile(), f.Scope(),
|
||||
optimize_func(f.Func(), f.ProfilePtr(), f.Scope(),
|
||||
new_body, analysis_options);
|
||||
f.SetBody(new_body);
|
||||
}
|
||||
|
|
|
@ -62,13 +62,15 @@ using ScriptFuncPtr = IntrusivePtr<ScriptFunc>;
|
|||
// Info we need for tracking an instance of a function.
|
||||
class FuncInfo {
|
||||
public:
|
||||
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body);
|
||||
FuncInfo(ScriptFuncPtr func, ScopePtr scope, StmtPtr body, int priority);
|
||||
|
||||
ScriptFunc* Func() const { return func.get(); }
|
||||
ScriptFuncPtr FuncPtr() const { return func; }
|
||||
ScopePtr Scope() const { return scope; }
|
||||
StmtPtr Body() const { return body; }
|
||||
std::shared_ptr<ProfileFunc> Profile() const { return pf; }
|
||||
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 ProfileFunc* Profile() const { return pf.get(); }
|
||||
std::shared_ptr<ProfileFunc> ProfilePtr() const { return pf; }
|
||||
const std::string& SaveFile() const { return save_file; }
|
||||
|
||||
void SetBody(StmtPtr new_body) { body = std::move(new_body); }
|
||||
|
@ -87,6 +89,7 @@ protected:
|
|||
ScopePtr scope;
|
||||
StmtPtr body;
|
||||
std::shared_ptr<ProfileFunc> pf;
|
||||
int priority;
|
||||
|
||||
// If we're saving this function in a file, this is the name
|
||||
// of the file to use.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue