diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index 29d873dd34..ac44f79a3b 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -433,7 +433,7 @@ ProfileFuncs::ProfileFuncs(std::vector& 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& funcs) { for ( auto& f : funcs ) if ( ! f.ShouldSkip() ) - ComputeProfileHash(f.Profile()); + ComputeProfileHash(f.ProfilePtr()); for ( auto& l : lambdas ) ComputeProfileHash(ExprProf(l)); diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 911730c2ef..457d1b8534 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -138,8 +138,10 @@ void optimize_func(ScriptFunc* f, std::shared_ptr 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 _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(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); } diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 11da7c22f3..c887580a8d 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -62,13 +62,15 @@ using ScriptFuncPtr = IntrusivePtr; // 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 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 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 pf; + int priority; // If we're saving this function in a file, this is the name // of the file to use.