mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-23 06:40:32 +00:00
Support inter-app hsp deps bytecode har
Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IAZT2E Signed-off-by: ElevenDuan <duanshiyi1@huawei.com> Change-Id: I5b7c9b02658e0b54d15a345e3bb1682f0b27de6a
This commit is contained in:
parent
2cd9760fab
commit
9a026fe965
@ -77,7 +77,8 @@ pandasm::Program *Abc2ProgramCompiler::CompileAbcFile()
|
||||
void Abc2ProgramCompiler::CompileAbcClass(const panda_file::File::EntityId &record_id,
|
||||
pandasm::Program &program, std::string &record_name)
|
||||
{
|
||||
Abc2ProgramEntityContainer entity_container(*file_, program, *debug_info_extractor_, record_id.GetOffset());
|
||||
Abc2ProgramEntityContainer entity_container(*file_, program, *debug_info_extractor_, record_id.GetOffset(),
|
||||
bundle_name_);
|
||||
record_name = entity_container.GetFullRecordNameById(record_id);
|
||||
panda::Timer::timerStart(EVENT_COMPILE_ABC_FILE_RECORD, record_name);
|
||||
AbcClassProcessor class_processor(record_id, entity_container);
|
||||
|
@ -38,11 +38,18 @@ public:
|
||||
std::string &record_name);
|
||||
bool CheckClassId(uint32_t class_id, size_t offset) const;
|
||||
|
||||
void SetBundleName(std::string bundle_name)
|
||||
{
|
||||
bundle_name_ = bundle_name;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<const panda_file::File> file_;
|
||||
std::unique_ptr<panda_file::DebugInfoExtractor> debug_info_extractor_;
|
||||
// the single whole program compiled from the abc file, only used in non-parallel mode
|
||||
pandasm::Program *prog_ = nullptr;
|
||||
// It should modify record name when the bundle_name_ is not empty
|
||||
std::string bundle_name_ {};
|
||||
}; // class Abc2ProgramCompiler
|
||||
|
||||
} // namespace panda::abc2program
|
||||
|
@ -53,10 +53,33 @@ std::string Abc2ProgramEntityContainer::GetFullRecordNameById(const panda_file::
|
||||
std::string name = GetStringById(class_id);
|
||||
pandasm::Type type = pandasm::Type::FromDescriptor(name);
|
||||
std::string record_full_name = type.GetName();
|
||||
ModifyRecordName(record_full_name);
|
||||
record_full_name_map_.emplace(class_id_offset, record_full_name);
|
||||
return record_full_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support the inter-app hsp dependents bytecode har.
|
||||
* The record name format: <bundleName>&<normalizedImportPath>&<version>
|
||||
* The ohmurl specs that must have bundleName in inter-app package. The records need compile into the inter-app
|
||||
* hsp package. So the recordNames need to add bundleName in front when the abc-file as input for the
|
||||
* inter-app hsp package.
|
||||
*/
|
||||
void Abc2ProgramEntityContainer::ModifyRecordName(std::string &record_name)
|
||||
{
|
||||
if (bundle_name_.empty()) {
|
||||
return;
|
||||
}
|
||||
if (IsSourceFileRecord(record_name)) {
|
||||
record_name = bundle_name_ + record_name;
|
||||
}
|
||||
}
|
||||
|
||||
bool Abc2ProgramEntityContainer::IsSourceFileRecord(const std::string& record_name)
|
||||
{
|
||||
return record_name.find(NORMALIZED_OHMURL_SEPARATOR) == 0;
|
||||
}
|
||||
|
||||
std::string Abc2ProgramEntityContainer::GetFullMethodNameById(const panda_file::File::EntityId &method_id)
|
||||
{
|
||||
auto method_id_offset = method_id.GetOffset();
|
||||
|
@ -32,9 +32,9 @@ public:
|
||||
Abc2ProgramEntityContainer(const panda_file::File &file,
|
||||
pandasm::Program &program,
|
||||
const panda_file::DebugInfoExtractor &debug_info_extractor,
|
||||
uint32_t class_id)
|
||||
uint32_t class_id, std::string bundle_name)
|
||||
: file_(file), program_(program), debug_info_extractor_(debug_info_extractor),
|
||||
current_class_id_(class_id) {}
|
||||
current_class_id_(class_id), bundle_name_(bundle_name) {}
|
||||
const panda_file::File &GetAbcFile() const;
|
||||
pandasm::Program &GetProgram() const;
|
||||
|
||||
@ -54,6 +54,8 @@ public:
|
||||
void TryAddUnprocessedNestedLiteralArrayId(uint32_t nested_literal_array_id);
|
||||
std::string GetLiteralArrayIdName(uint32_t literal_array_id);
|
||||
const panda_file::DebugInfoExtractor &GetDebugInfoExtractor() const;
|
||||
void ModifyRecordName(std::string &record_name);
|
||||
bool IsSourceFileRecord(const std::string& record_name);
|
||||
|
||||
private:
|
||||
std::string ConcatFullMethodNameById(const panda_file::File::EntityId &method_id);
|
||||
@ -68,6 +70,8 @@ private:
|
||||
std::unordered_set<uint32_t> processed_nested_literal_array_id_set_;
|
||||
std::unordered_set<uint32_t> unprocessed_nested_literal_array_id_set_;
|
||||
uint32_t current_class_id_{0};
|
||||
// It should modify record name when the bundle_name_ is not empty
|
||||
std::string bundle_name_ {};
|
||||
}; // class Abc2ProgramEntityContainer
|
||||
|
||||
} // namespace panda::abc2program
|
||||
|
@ -39,6 +39,7 @@ constexpr std::string_view CONCURRENT_MODULE_REQUEST_RECORD_NAME = "_ESConcurren
|
||||
constexpr std::string_view SLOT_NUMBER_ANN_RECORD_TYPE_DESCRIPTOR = "L_ESSlotNumberAnnotation;";
|
||||
constexpr std::string_view SLOT_NUMBER_RECORD_NAME = "_ESSlotNumberAnnotation";
|
||||
constexpr std::string_view DOT = ".";
|
||||
constexpr char NORMALIZED_OHMURL_SEPARATOR = '&';
|
||||
|
||||
// attribute constant
|
||||
constexpr std::string_view ABC_ATTR_EXTERNAL = "external";
|
||||
|
Loading…
Reference in New Issue
Block a user