mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-23 06:40:32 +00:00
improve_debug_info_visiting_performance
Signed-off-by: l00680486 <litengfei26@huawei.com> Change-Id: Iba164bc5ee8c27853349d8586d31eac1a9f9b60e
This commit is contained in:
parent
e6c9cf3fde
commit
5f128f2129
@ -70,7 +70,7 @@ private:
|
||||
uint32_t curr_try_end_inst_pc_ = 0;
|
||||
uint32_t curr_catch_begin_pc_ = 0;
|
||||
uint32_t curr_catch_end_pc_ = 0;
|
||||
panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
const panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
}; // AbcCodeProcessor
|
||||
|
||||
} // namespace panda::abc2program
|
||||
|
@ -46,7 +46,7 @@ class AbcMethodProcessor : public AbcFileEntityProcessor {
|
||||
AbcTypeConverter type_converter_;
|
||||
pandasm::Function function_;
|
||||
std::unique_ptr<panda_file::MethodDataAccessor> method_data_accessor_;
|
||||
panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
const panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
};
|
||||
|
||||
} // namespace panda::abc2program
|
||||
|
@ -36,7 +36,7 @@ pandasm::Program &Abc2ProgramEntityContainer::GetProgram() const
|
||||
return program_;
|
||||
}
|
||||
|
||||
panda_file::DebugInfoExtractor &Abc2ProgramEntityContainer::GetDebugInfoExtractor() const
|
||||
const panda_file::DebugInfoExtractor &Abc2ProgramEntityContainer::GetDebugInfoExtractor() const
|
||||
{
|
||||
return debug_info_extractor_;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
Abc2ProgramEntityContainer(const panda_file::File &file,
|
||||
AbcStringTable &string_table,
|
||||
pandasm::Program &program,
|
||||
panda_file::DebugInfoExtractor &debug_info_extractor)
|
||||
const panda_file::DebugInfoExtractor &debug_info_extractor)
|
||||
: file_(file), string_table_(string_table), program_(program), debug_info_extractor_(debug_info_extractor) {}
|
||||
const panda_file::File &GetAbcFile() const;
|
||||
AbcStringTable &GetAbcStringTable() const;
|
||||
@ -64,7 +64,7 @@ public:
|
||||
std::string GetLiteralArrayIdName(uint32_t literal_array_id);
|
||||
std::string GetLiteralArrayIdName(const panda_file::File::EntityId &literal_array_id);
|
||||
std::string GetAbcFileAbsolutePath() const;
|
||||
panda_file::DebugInfoExtractor &GetDebugInfoExtractor() const;
|
||||
const panda_file::DebugInfoExtractor &GetDebugInfoExtractor() const;
|
||||
|
||||
void SetCurrentClassId(uint32_t class_id);
|
||||
void ClearLiteralArrayIdSet();
|
||||
@ -74,7 +74,7 @@ private:
|
||||
const panda_file::File &file_;
|
||||
AbcStringTable &string_table_;
|
||||
pandasm::Program &program_;
|
||||
panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
const panda_file::DebugInfoExtractor &debug_info_extractor_;
|
||||
std::unordered_map<uint32_t, const pandasm::Record*> record_map_;
|
||||
std::unordered_map<uint32_t, const pandasm::Function*> function_map_;
|
||||
std::unordered_map<uint32_t, const pandasm::Field*> field_map_;
|
||||
|
@ -253,19 +253,20 @@ void DebugInfoExtractor::Extract(const File *pf)
|
||||
if (UNLIKELY(source_code == nullptr)) {
|
||||
source_code = "";
|
||||
}
|
||||
methods_.push_back({source_file, source_code, method_id, handler.GetLineNumberTable(),
|
||||
handler.GetLocalVariableTable(), std::move(param_info),
|
||||
handler.GetColumnNumberTable()});
|
||||
ASSERT(methods_.find(method_id.GetOffset()) == methods_.end());
|
||||
methods_.emplace(method_id.GetOffset(),
|
||||
MethodDebugInfo {source_file, source_code, method_id, handler.GetLineNumberTable(),
|
||||
handler.GetLocalVariableTable(), std::move(param_info),
|
||||
handler.GetColumnNumberTable()});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const LineNumberTable &DebugInfoExtractor::GetLineNumberTable(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.line_number_table;
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.line_number_table;
|
||||
}
|
||||
|
||||
static const LineNumberTable EMPTY_LINE_TABLE {}; // NOLINT(fuchsia-statically-constructed-objects)
|
||||
@ -274,10 +275,9 @@ const LineNumberTable &DebugInfoExtractor::GetLineNumberTable(File::EntityId met
|
||||
|
||||
const ColumnNumberTable &DebugInfoExtractor::GetColumnNumberTable(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.column_number_table;
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.column_number_table;
|
||||
}
|
||||
|
||||
static const ColumnNumberTable EMPTY_COLUMN_TABLE {}; // NOLINT(fuchsia-statically-constructed-objects)
|
||||
@ -286,10 +286,9 @@ const ColumnNumberTable &DebugInfoExtractor::GetColumnNumberTable(File::EntityId
|
||||
|
||||
const LocalVariableTable &DebugInfoExtractor::GetLocalVariableTable(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.local_variable_table;
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.local_variable_table;
|
||||
}
|
||||
|
||||
static const LocalVariableTable EMPTY_VARIABLE_TABLE {}; // NOLINT(fuchsia-statically-constructed-objects)
|
||||
@ -298,10 +297,9 @@ const LocalVariableTable &DebugInfoExtractor::GetLocalVariableTable(File::Entity
|
||||
|
||||
const std::vector<DebugInfoExtractor::ParamInfo> &DebugInfoExtractor::GetParameterInfo(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.param_info;
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.param_info;
|
||||
}
|
||||
|
||||
static const std::vector<ParamInfo> EMPTY_PARAM_INFO {}; // NOLINT(fuchsia-statically-constructed-objects)
|
||||
@ -310,20 +308,18 @@ const std::vector<DebugInfoExtractor::ParamInfo> &DebugInfoExtractor::GetParamet
|
||||
|
||||
const char *DebugInfoExtractor::GetSourceFile(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.source_file.c_str();
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.source_file.c_str();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *DebugInfoExtractor::GetSourceCode(File::EntityId method_id) const
|
||||
{
|
||||
for (const auto &method : methods_) {
|
||||
if (method.method_id == method_id) {
|
||||
return method.source_code.c_str();
|
||||
}
|
||||
auto it = methods_.find(method_id.GetOffset());
|
||||
if (it != methods_.end()) {
|
||||
return it->second.source_code.c_str();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -333,7 +329,7 @@ std::vector<File::EntityId> DebugInfoExtractor::GetMethodIdList() const
|
||||
std::vector<File::EntityId> list;
|
||||
|
||||
for (const auto &method : methods_) {
|
||||
list.push_back(method.method_id);
|
||||
list.push_back(method.second.method_id);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace panda::panda_file {
|
||||
|
||||
@ -90,7 +90,7 @@ private:
|
||||
ColumnNumberTable column_number_table;
|
||||
};
|
||||
|
||||
std::list<MethodDebugInfo> methods_;
|
||||
std::unordered_map<uint32_t, MethodDebugInfo> methods_;
|
||||
};
|
||||
|
||||
} // namespace panda::panda_file
|
||||
|
@ -385,6 +385,7 @@ HWTEST_F(ExtractorTest, DebugInfoTestColumnNumber, testing::ext::TestSize.Level0
|
||||
DebugInfoExtractor extractor(pf);
|
||||
|
||||
auto methods = extractor.GetMethodIdList();
|
||||
std::sort(methods.begin(), methods.end());
|
||||
constexpr uint32_t column_start = 5;
|
||||
uint32_t i = column_start;
|
||||
for (auto const &method_id : methods) {
|
||||
|
Loading…
Reference in New Issue
Block a user