mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-23 14:50:51 +00:00
The compiler outputs size statistics for each data structure
Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I95JE4
Signed-off-by: liujia178 <liujia178@huawei.com>
Change-Id: c580a5491b
This commit is contained in:
parent
c580a5491b
commit
bb1fd6c7da
@ -420,10 +420,13 @@ void ItemContainer::DeduplicateItems(bool computeLayout)
|
||||
|
||||
uint32_t ItemContainer::ComputeLayout()
|
||||
{
|
||||
uint32_t original_offset = 0;
|
||||
uint32_t num_classes = class_map_.size();
|
||||
uint32_t num_literalarrays = literalarray_map_.size();
|
||||
uint32_t class_idx_offset = sizeof(File::Header);
|
||||
uint32_t cur_offset = class_idx_offset + (num_classes + num_literalarrays) * ID_SIZE;
|
||||
items_round_up_size_.clear();
|
||||
foreign_item_roundup_size_ = 0;
|
||||
|
||||
UpdateOrderIndexes();
|
||||
|
||||
@ -435,25 +438,33 @@ uint32_t ItemContainer::ComputeLayout()
|
||||
cur_offset += index_section_item_.GetSize();
|
||||
|
||||
for (auto &item : foreign_items_) {
|
||||
original_offset = cur_offset;
|
||||
cur_offset = RoundUp(cur_offset, item->Alignment());
|
||||
foreign_item_roundup_size_ += caculateRoundUpSize(original_offset, cur_offset);
|
||||
item->SetOffset(cur_offset);
|
||||
item->ComputeLayout();
|
||||
cur_offset += item->GetSize();
|
||||
}
|
||||
|
||||
for (auto &item : items_) {
|
||||
const auto &name = item->GetName();
|
||||
|
||||
if (!item->NeedsEmit()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
original_offset = cur_offset;
|
||||
cur_offset = RoundUp(cur_offset, item->Alignment());
|
||||
items_round_up_size_[name] += caculateRoundUpSize(original_offset, cur_offset);
|
||||
item->SetOffset(cur_offset);
|
||||
item->ComputeLayout();
|
||||
cur_offset += item->GetSize();
|
||||
}
|
||||
|
||||
// Line number program should be last because it's size is known only after deduplication
|
||||
original_offset = cur_offset;
|
||||
cur_offset = RoundUp(cur_offset, line_number_program_index_item_.Alignment());
|
||||
line_number_item_roundup_size_ = caculateRoundUpSize(original_offset, cur_offset);
|
||||
line_number_program_index_item_.SetOffset(cur_offset);
|
||||
line_number_program_index_item_.ComputeLayout();
|
||||
cur_offset += line_number_program_index_item_.GetSize();
|
||||
@ -714,11 +725,12 @@ std::map<std::string, size_t> ItemContainer::GetStat()
|
||||
|
||||
stat["header_item"] = sizeof(File::Header);
|
||||
stat["class_idx_item"] = class_map_.size() * ID_SIZE;
|
||||
stat["line_number_program_idx_item"] = line_number_program_index_item_.GetNumItems() * ID_SIZE;
|
||||
stat["line_number_program_idx_item"] = line_number_program_index_item_.GetNumItems() * ID_SIZE
|
||||
+ line_number_item_roundup_size_;
|
||||
stat["literalarray_idx"] = literalarray_map_.size() * ID_SIZE;
|
||||
|
||||
stat["index_section_item"] = index_section_item_.GetSize();
|
||||
stat["foreign_item"] = GetForeignSize();
|
||||
stat["foreign_item"] = GetForeignSize() + foreign_item_roundup_size_;
|
||||
|
||||
size_t num_ins = 0;
|
||||
size_t codesize = 0;
|
||||
@ -740,6 +752,10 @@ std::map<std::string, size_t> ItemContainer::GetStat()
|
||||
codesize += static_cast<CodeItem *>(item.get())->GetCodeSize();
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &[name, round_up_size] : items_round_up_size_) {
|
||||
stat[name] += round_up_size;
|
||||
}
|
||||
stat["instructions_number"] = num_ins;
|
||||
stat["codesize"] = codesize;
|
||||
|
||||
|
@ -111,6 +111,11 @@ public:
|
||||
|
||||
void DumpItemsStat(std::ostream &os) const;
|
||||
|
||||
uint32_t caculateRoundUpSize(uint32_t before, uint32_t after)
|
||||
{
|
||||
return after - before;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, StringItem *> *GetStringMap()
|
||||
{
|
||||
return &string_map_;
|
||||
@ -565,6 +570,11 @@ private:
|
||||
std::list<std::unique_ptr<BaseItem>>::iterator code_items_end_;
|
||||
std::list<std::unique_ptr<BaseItem>>::iterator debug_items_end_;
|
||||
|
||||
// Get Roundup Alignment Size
|
||||
std::unordered_map<std::string, size_t> items_round_up_size_;
|
||||
uint32_t foreign_item_roundup_size_ {0};
|
||||
uint32_t line_number_item_roundup_size_ {0};
|
||||
|
||||
BaseItem *end_;
|
||||
size_t indexed_item_count_ {0};
|
||||
const uint8_t api_{0};
|
||||
|
Loading…
Reference in New Issue
Block a user