mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-10-06 21:34:16 +00:00
!2149 Implement re-layout of abc file items
Merge pull request !2149 from huyunhui/file_items
This commit is contained in:
commit
e72547ff1c
@ -1453,6 +1453,7 @@ bool AsmEmitter::EmitPrograms(const std::string &filename, const std::vector<Pro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
items.ReLayout();
|
||||||
items.ComputeLayout();
|
items.ComputeLayout();
|
||||||
|
|
||||||
for (const auto *prog : progs) {
|
for (const auto *prog : progs) {
|
||||||
|
@ -406,6 +406,40 @@ void ItemContainer::DeduplicateItems(bool computeLayout)
|
|||||||
DeduplicateAnnotations();
|
DeduplicateAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool Compare(const std::unique_ptr<BaseItem> &item1, const std::unique_ptr<BaseItem> &item2)
|
||||||
|
{
|
||||||
|
return item1->GetReLayoutRank() > item2->GetReLayoutRank();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemContainer::ReLayout()
|
||||||
|
{
|
||||||
|
for (auto &item : items_) {
|
||||||
|
if (!item->NeedsEmit()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Because only class items and func_main_0 will be accessed in runtime's initialization,
|
||||||
|
* the items in abc will be arranged in following order to increase cache hit rate:
|
||||||
|
* class items -> string items(for field name) -> other items
|
||||||
|
*/
|
||||||
|
switch (item->GetItemType()) {
|
||||||
|
case ItemTypes::CLASS_ITEM: {
|
||||||
|
item->SetReLayoutRank(ItemRank::CLASS_ITEM_RANK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemTypes::STRING_ITEM: {
|
||||||
|
item->SetReLayoutRank(ItemRank::STRING_ITEM_RANK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items_.sort(Compare);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ItemContainer::ComputeLayout()
|
uint32_t ItemContainer::ComputeLayout()
|
||||||
{
|
{
|
||||||
uint32_t original_offset = 0;
|
uint32_t original_offset = 0;
|
||||||
|
@ -104,6 +104,7 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReLayout();
|
||||||
uint32_t ComputeLayout();
|
uint32_t ComputeLayout();
|
||||||
bool Write(Writer *writer, bool deduplicateItems = true);
|
bool Write(Writer *writer, bool deduplicateItems = true);
|
||||||
|
|
||||||
|
@ -84,6 +84,12 @@ enum class FunctionKind : uint8_t {
|
|||||||
SENDABLE_FUNCTION = 1 << 3
|
SENDABLE_FUNCTION = 1 << 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ItemRank : uint8_t {
|
||||||
|
DEFAULT_RANK = 0x0,
|
||||||
|
STRING_ITEM_RANK = 0x1,
|
||||||
|
CLASS_ITEM_RANK = 0x2
|
||||||
|
};
|
||||||
|
|
||||||
bool IsDynamicLanguage(panda::panda_file::SourceLang lang);
|
bool IsDynamicLanguage(panda::panda_file::SourceLang lang);
|
||||||
std::optional<panda::panda_file::SourceLang> LanguageFromString(const std::string_view &lang);
|
std::optional<panda::panda_file::SourceLang> LanguageFromString(const std::string_view &lang);
|
||||||
const char *LanguageToString(panda::panda_file::SourceLang lang);
|
const char *LanguageToString(panda::panda_file::SourceLang lang);
|
||||||
@ -273,6 +279,16 @@ public:
|
|||||||
return original_rank_;
|
return original_rank_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetReLayoutRank(ItemRank rank)
|
||||||
|
{
|
||||||
|
re_layout_rank_ = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemRank GetReLayoutRank() const
|
||||||
|
{
|
||||||
|
return re_layout_rank_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool needs_emit_ {true};
|
bool needs_emit_ {true};
|
||||||
uint32_t offset_ {0};
|
uint32_t offset_ {0};
|
||||||
@ -280,6 +296,7 @@ private:
|
|||||||
std::list<IndexedItem *> index_deps_;
|
std::list<IndexedItem *> index_deps_;
|
||||||
uint32_t pgo_rank_ {0};
|
uint32_t pgo_rank_ {0};
|
||||||
uint32_t original_rank_ {0};
|
uint32_t original_rank_ {0};
|
||||||
|
ItemRank re_layout_rank_ {ItemRank::DEFAULT_RANK};
|
||||||
};
|
};
|
||||||
|
|
||||||
class IndexedItem : public BaseItem {
|
class IndexedItem : public BaseItem {
|
||||||
|
Loading…
Reference in New Issue
Block a user