• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PROFILING_SAVE_H
17 #define PROFILING_SAVE_H
18 
19 #include <cstdlib>
20 #include <iostream>
21 #include <memory>
22 #include "libprofile/aot_profiling_data.h"
23 #include "runtime/include/mem/panda_containers.h"
24 #include "runtime/jit/profiling_data.h"
25 #include "runtime/include/class.h"
26 #include "runtime/include/class_linker.h"
27 #include "runtime/jit/libprofile/pgo_file_builder.h"
28 
29 namespace ark {
30 class ProfilingSaver {
31 public:
32     void UpdateInlineCaches(pgo::AotProfilingData::AotCallSiteInlineCache *ic, std::vector<Class *> &runtimeClasses,
33                             pgo::AotProfilingData *profileData);
34     void CreateInlineCaches(pgo::AotProfilingData::AotMethodProfilingData *profilingData,
35                             Span<CallSiteInlineCache> &runtimeICs, pgo::AotProfilingData *profileData);
36     void CreateBranchData(pgo::AotProfilingData::AotMethodProfilingData *profilingData,
37                           Span<BranchData> &runtimeBranch);
38     void CreateThrowData(pgo::AotProfilingData::AotMethodProfilingData *profilingData, Span<ThrowData> &runtimeThrow);
39     void AddMethod(pgo::AotProfilingData *profileData, Method *method, int32_t pandaFileIdx);
40     void AddProfiledMethods(pgo::AotProfilingData *profileData, PandaList<Method *> &profiledMethods,
41                             PandaList<Method *>::const_iterator profiledMethodsFinal);
42     void SaveProfile(const PandaString &saveFilePath, const PandaString &classCtxStr,
43                      PandaList<Method *> &profiledMethods, PandaList<Method *>::const_iterator profiledMethodsFinal,
44                      PandaUnorderedSet<std::string_view> &profiledPandaFiles);
45 };
46 }  // namespace ark
47 #endif  // PROFILING_SAVE_H
48