mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-26 07:16:57 +00:00
!4931 GTModuleIdUseAbcName
Merge pull request !4931 from hzzhouzebin/GTModuleIdUseAbcName
This commit is contained in:
commit
70593a6b42
@ -344,6 +344,11 @@ void JSPandaFileManager::ObsoleteLoadedJSPandaFile(const CString &filename)
|
||||
}
|
||||
|
||||
std::shared_ptr<JSPandaFile> JSPandaFileManager::OpenJSPandaFile(const CString &filename)
|
||||
{
|
||||
return OpenJSPandaFile(filename, filename);
|
||||
}
|
||||
|
||||
std::shared_ptr<JSPandaFile> JSPandaFileManager::OpenJSPandaFile(const CString &filename, const CString &desc)
|
||||
{
|
||||
auto pf = panda_file::OpenPandaFileOrZip(filename, panda_file::File::READ_WRITE);
|
||||
if (pf == nullptr) {
|
||||
@ -351,7 +356,7 @@ std::shared_ptr<JSPandaFile> JSPandaFileManager::OpenJSPandaFile(const CString &
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return NewJSPandaFile(pf.release(), filename);
|
||||
return NewJSPandaFile(pf.release(), desc);
|
||||
}
|
||||
|
||||
std::shared_ptr<JSPandaFile> JSPandaFileManager::OpenJSPandaFileFromBuffer(uint8_t *buffer,
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
|
||||
std::shared_ptr<JSPandaFile> OpenJSPandaFile(const CString &filename);
|
||||
|
||||
std::shared_ptr<JSPandaFile> OpenJSPandaFile(const CString &filename, const CString &desc);
|
||||
|
||||
std::shared_ptr<JSPandaFile> OpenJSPandaFileFromBuffer(uint8_t *buffer, size_t size, const CString &filename);
|
||||
|
||||
std::shared_ptr<JSPandaFile> NewJSPandaFile(const panda_file::File *pf, const CString &desc);
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
ApEntityId entryId_ {};
|
||||
ApEntityId entryId_ {0};
|
||||
CString name_;
|
||||
};
|
||||
using PoolType = PoolTemplate<Entry, CString>;
|
||||
|
@ -236,6 +236,14 @@ bool PGOProfilerDecoder::InitMergeData()
|
||||
return true;
|
||||
}
|
||||
|
||||
void PGOProfilerDecoder::SwapAbcIdPool(PGOProfilerDecoder &decoder)
|
||||
{
|
||||
if (abcFilePool_) {
|
||||
abcFilePool_->Clear();
|
||||
}
|
||||
abcFilePool_.swap(decoder.abcFilePool_);
|
||||
}
|
||||
|
||||
void PGOProfilerDecoder::Merge(const PGOProfilerDecoder &decoder)
|
||||
{
|
||||
if (!isLoaded_ || !isVerifySuccess_) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "ecmascript/log.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
#include "ecmascript/pgo_profiler/pgo_profiler_info.h"
|
||||
#include "ecmascript/pgo_profiler/pgo_utils.h"
|
||||
#include "ecmascript/pgo_profiler/types/pgo_profiler_type.h"
|
||||
#include "ecmascript/platform/map.h"
|
||||
|
||||
@ -48,6 +49,8 @@ public:
|
||||
|
||||
void Merge(const PGOProfilerDecoder &decoder);
|
||||
|
||||
void SwapAbcIdPool(PGOProfilerDecoder &decoder);
|
||||
|
||||
bool InitMergeData();
|
||||
|
||||
const std::string& GetInPath() const
|
||||
@ -139,6 +142,23 @@ public:
|
||||
return pandaFileInfos_;
|
||||
}
|
||||
|
||||
bool GetAbcNameById(ApEntityId abcId, CString &abcName) const
|
||||
{
|
||||
ASSERT(header_ != nullptr);
|
||||
if (!header_->SupportProfileTypeWithAbcId()) {
|
||||
return false;
|
||||
}
|
||||
ASSERT(abcFilePool_ != nullptr);
|
||||
ASSERT(abcFilePool_->GetPool() != nullptr);
|
||||
const auto *entry = abcFilePool_->GetPool()->GetEntry(abcId);
|
||||
if (entry == nullptr) {
|
||||
LOG_COMPILER(ERROR) << "Can not find abcId in pgo file. abcId: " << abcId;
|
||||
return false;
|
||||
}
|
||||
abcName = entry->GetData();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool Load();
|
||||
bool Verify(uint32_t checksum);
|
||||
|
@ -462,8 +462,8 @@ public:
|
||||
bool AddType(ProfileType recordProfileType, PGOMethodId methodId, int32_t offset, PGOSampleType type);
|
||||
bool AddCallTargetType(ProfileType recordProfileType, PGOMethodId methodId, int32_t offset, PGOSampleType type);
|
||||
bool AddObjectInfo(ProfileType recordProfileType, PGOMethodId methodId, int32_t offset, const PGOObjectInfo &info);
|
||||
bool AddDefine(
|
||||
ProfileType recordProfileType, PGOMethodId methodId, int32_t offset, PGOSampleType type, PGOSampleType superType);
|
||||
bool AddDefine(ProfileType recordProfileType, PGOMethodId methodId, int32_t offset, PGOSampleType type,
|
||||
PGOSampleType superType);
|
||||
bool AddLayout(PGOSampleType type, JSTaggedType hclass, PGOObjKind kind);
|
||||
bool UpdateElementsKind(PGOSampleType type, ElementsKind kind);
|
||||
void Merge(const PGORecordDetailInfos &recordInfos);
|
||||
|
@ -84,6 +84,7 @@ bool PGOProfilerManager::MergeApFiles(uint32_t checksum, PGOProfilerDecoder &mer
|
||||
}
|
||||
if (isFirstFile) {
|
||||
firstApFileName = fileName;
|
||||
merger.SwapAbcIdPool(decoder);
|
||||
} else {
|
||||
if (!merger.GetPandaFileInfos().VerifyChecksum(decoder.GetPandaFileInfos(), firstApFileName, fileName)) {
|
||||
continue;
|
||||
|
@ -575,7 +575,7 @@ HWTEST_F_L0(PGOProfilerTest, BinaryToText)
|
||||
|
||||
PGOProfilerHeader *header = nullptr;
|
||||
PGOProfilerHeader::Build(&header, PGOProfilerHeader::LastSize());
|
||||
std::unique_ptr<PGOAbcFilePool> abcFilePool = std::make_unique<PGOAbcFilePool>();
|
||||
std::unique_ptr<PGOAbcFilePool> abcFilePool = std::make_unique<PGOAbcFilePool>();
|
||||
std::unique_ptr<PGOPandaFileInfos> pandaFileInfos = std::make_unique<PGOPandaFileInfos>();
|
||||
std::unique_ptr<PGORecordDetailInfos> recordInfos = std::make_unique<PGORecordDetailInfos>(2);
|
||||
|
||||
|
@ -56,15 +56,16 @@ public:
|
||||
|
||||
HWTEST_F_L0(TSTypeTableGeneratorTest, TestTryGetModuleId)
|
||||
{
|
||||
auto tsManager = ecmaVm->GetJSThread()->GetCurrentEcmaContext()->GetTSManager();
|
||||
const auto *abcName = TSTypeTable::DEFAULT_TYPE_VIRTUAL_NAME;
|
||||
auto *tsManager = ecmaVm->GetJSThread()->GetCurrentEcmaContext()->GetTSManager();
|
||||
tsManager->Initialize();
|
||||
TSTypeTableGenerator tableGenerator(tsManager);
|
||||
uint32_t primitiveTableId = tableGenerator.TryGetModuleId(TSTypeTable::PRIMITIVE_TABLE_NAME);
|
||||
uint32_t builtinTableId = tableGenerator.TryGetModuleId(TSTypeTable::BUILTINS_TABLE_NAME);
|
||||
uint32_t inferTableId = tableGenerator.TryGetModuleId(TSTypeTable::INFER_TABLE_NAME);
|
||||
uint32_t runtimeTableId = tableGenerator.TryGetModuleId(TSTypeTable::RUNTIME_TABLE_NAME);
|
||||
uint32_t genericsTableId = tableGenerator.TryGetModuleId(TSTypeTable::GENERICS_TABLE_NAME);
|
||||
uint32_t firstUserModuleId = tableGenerator.TryGetModuleId("test");
|
||||
uint32_t primitiveTableId = tableGenerator.TryGetModuleId(abcName, TSTypeTable::PRIMITIVE_TABLE_NAME);
|
||||
uint32_t builtinTableId = tableGenerator.TryGetModuleId(abcName, TSTypeTable::BUILTINS_TABLE_NAME);
|
||||
uint32_t inferTableId = tableGenerator.TryGetModuleId(abcName, TSTypeTable::INFER_TABLE_NAME);
|
||||
uint32_t runtimeTableId = tableGenerator.TryGetModuleId(abcName, TSTypeTable::RUNTIME_TABLE_NAME);
|
||||
uint32_t genericsTableId = tableGenerator.TryGetModuleId(abcName, TSTypeTable::GENERICS_TABLE_NAME);
|
||||
uint32_t firstUserModuleId = tableGenerator.TryGetModuleId(abcName, "test");
|
||||
EXPECT_EQ(primitiveTableId, static_cast<uint32_t>(ModuleTableIdx::PRIMITIVE));
|
||||
EXPECT_EQ(builtinTableId, static_cast<uint32_t>(ModuleTableIdx::BUILTIN));
|
||||
EXPECT_EQ(inferTableId, static_cast<uint32_t>(ModuleTableIdx::INFERRED));
|
||||
|
@ -1721,7 +1721,8 @@ void TSManager::GenerateBuiltinSummary()
|
||||
{
|
||||
ASSERT(IsBuiltinsDTSEnabled());
|
||||
CString builtinsDTSFileName = GetBuiltinsDTS();
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile = JSPandaFileManager::GetInstance()->OpenJSPandaFile(builtinsDTSFileName);
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile = JSPandaFileManager::GetInstance()->OpenJSPandaFile(
|
||||
builtinsDTSFileName, panda::ecmascript::TSTypeTable::DEFAULT_TYPE_VIRTUAL_NAME);
|
||||
if (jsPandaFile == nullptr) {
|
||||
LOG_COMPILER(FATAL) << "load lib_ark_builtins.d.ts failed";
|
||||
}
|
||||
@ -1744,6 +1745,8 @@ void TSManager::PrintNumOfTypes() const
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSHandle<EcmaString> valueString = mTable->GetModuleRequestByModuleId(thread_, i);
|
||||
std::string name = EcmaStringAccessor(valueString).ToStdString();
|
||||
valueString = mTable->GetAbcRequestByModuleId(thread_, i);
|
||||
std::string abcName = EcmaStringAccessor(valueString).ToStdString();
|
||||
JSHandle<TSTypeTable> tTable = GetTSTypeTable(i);
|
||||
uint32_t numOfExpectedTypes = static_cast<uint32_t>(tTable->GetNumberOfTypes());
|
||||
uint32_t numOfTypes = 0;
|
||||
@ -1755,6 +1758,7 @@ void TSManager::PrintNumOfTypes() const
|
||||
}
|
||||
totalNumOfTypes += numOfTypes;
|
||||
LOG_COMPILER(DEBUG) << "module table: " << i << ", "
|
||||
<< "abc name: " << abcName << ", "
|
||||
<< "module name: " << name << ", "
|
||||
<< "number of types: " << numOfTypes;
|
||||
}
|
||||
@ -1791,12 +1795,21 @@ JSHandle<EcmaString> TSModuleTable::GetModuleRequestByModuleId(JSThread *thread,
|
||||
return amiPath;
|
||||
}
|
||||
|
||||
int TSModuleTable::GetGlobalModuleID(JSThread *thread, JSHandle<EcmaString> amiPath) const
|
||||
JSHandle<EcmaString> TSModuleTable::GetAbcRequestByModuleId(JSThread *thread, int entry) const
|
||||
{
|
||||
int amiOffset = GetAbcRequestOffset(entry);
|
||||
JSHandle<EcmaString> abcPath(thread, Get(amiOffset));
|
||||
return abcPath;
|
||||
}
|
||||
|
||||
int TSModuleTable::GetGlobalModuleID(JSThread *thread, JSHandle<EcmaString> amiPath, JSHandle<EcmaString> abcPath) const
|
||||
{
|
||||
uint32_t length = GetNumberOfTSTypeTables();
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSHandle<EcmaString> valueString = GetModuleRequestByModuleId(thread, i);
|
||||
if (EcmaStringAccessor::StringsAreEqual(*amiPath, *valueString)) {
|
||||
JSHandle<EcmaString> moduleString = GetModuleRequestByModuleId(thread, i);
|
||||
JSHandle<EcmaString> abcName = GetAbcRequestByModuleId(thread, i);
|
||||
if (EcmaStringAccessor::StringsAreEqual(*amiPath, *moduleString) &&
|
||||
EcmaStringAccessor::StringsAreEqual(*abcPath, *abcName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,11 @@ struct ModuleInfo {
|
||||
class TSModuleTable : public TaggedArray {
|
||||
public:
|
||||
// Each TSTypeTable occupies three positions
|
||||
static constexpr int ELEMENTS_LENGTH = 3;
|
||||
static constexpr int ELEMENTS_LENGTH = 4;
|
||||
static constexpr int MODULE_REQUEST_OFFSET = 1;
|
||||
static constexpr int SORT_ID_OFFSET = 2;
|
||||
static constexpr int TYPE_TABLE_OFFSET = 3;
|
||||
static constexpr int ABC_ID_OFFSET = 4;
|
||||
// Reserve a position which is used to store the number of TSTypeTables and a TSTypeTable storage space
|
||||
static constexpr int INITIAL_CAPACITY = ELEMENTS_LENGTH + 1;
|
||||
static constexpr int NUMBER_OF_TABLES_INDEX = 0;
|
||||
@ -155,7 +156,9 @@ public:
|
||||
|
||||
JSHandle<EcmaString> GetModuleRequestByModuleId(JSThread *thread, int entry) const;
|
||||
|
||||
int GetGlobalModuleID(JSThread *thread, JSHandle<EcmaString> amiPath) const;
|
||||
JSHandle<EcmaString> GetAbcRequestByModuleId(JSThread *thread, int entry) const;
|
||||
|
||||
int GetGlobalModuleID(JSThread *thread, JSHandle<EcmaString> amiPath, JSHandle<EcmaString> abcPath) const;
|
||||
|
||||
inline int GetNumberOfTSTypeTables() const
|
||||
{
|
||||
@ -181,6 +184,11 @@ public:
|
||||
{
|
||||
return entry * ELEMENTS_LENGTH + SORT_ID_OFFSET;
|
||||
}
|
||||
|
||||
static uint32_t GetAbcRequestOffset(int entry)
|
||||
{
|
||||
return entry * ELEMENTS_LENGTH + ABC_ID_OFFSET;
|
||||
}
|
||||
};
|
||||
|
||||
class TSManager {
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "ecmascript/ts_types/ts_type_parser.h"
|
||||
|
||||
#include "ecmascript/ecma_string.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
#include "ecmascript/pgo_profiler/pgo_profiler_layout.h"
|
||||
#include "ecmascript/subtyping_operator.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_manager.h"
|
||||
@ -88,7 +90,7 @@ GlobalTSTypeRef TSTypeParser::ParseType(const JSPandaFile *jsPandaFile, const CS
|
||||
return ResolveType(jsPandaFile, recordName, &typeLiteralExtractor);
|
||||
}
|
||||
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(recordName);
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(jsPandaFile->GetNormalizedFileDesc(), recordName);
|
||||
if (UNLIKELY(!GlobalTSTypeRef::IsValidModuleId(moduleId))) {
|
||||
LOG_COMPILER(DEBUG) << "The maximum number of TSTypeTables is reached. All TSTypes in the record "
|
||||
<< recordName << " will not be parsed and will be treated as any.";
|
||||
@ -164,7 +166,7 @@ GlobalTSTypeRef TSTypeParser::ResolveImportType(const JSPandaFile *jsPandaFile,
|
||||
return GetAndStoreGT(jsPandaFile, typeId, recordName);
|
||||
}
|
||||
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(entryPoint);
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(jsPandaFile->GetNormalizedFileDesc(), entryPoint);
|
||||
if (UNLIKELY(!GlobalTSTypeRef::IsValidModuleId(moduleId))) {
|
||||
LOG_COMPILER(DEBUG) << "The maximum number of TSTypeTables is reached. All TSTypes in the record "
|
||||
<< entryPoint << " will not be parsed and will be treated as any.";
|
||||
@ -609,7 +611,7 @@ GlobalTSTypeRef TSTypeParser::IterateStarExport(JSHandle<EcmaString> target, con
|
||||
if (markSet.find(star) != markSet.end()) {
|
||||
continue;
|
||||
}
|
||||
uint32_t starModuleId = tableGenerator_.TryGetModuleId(star);
|
||||
uint32_t starModuleId = tableGenerator_.TryGetModuleId(jsPandaFile->GetNormalizedFileDesc(), star);
|
||||
if (UNLIKELY(!GlobalTSTypeRef::IsValidModuleId(starModuleId))) {
|
||||
continue;
|
||||
}
|
||||
@ -811,9 +813,30 @@ GlobalTSTypeRef TSTypeParser::CreatePGOGT(PGOInfo info)
|
||||
return ParsePGOType(info);
|
||||
}
|
||||
|
||||
bool TSTypeParser::GetAbcNameFromProfileType(ProfileType profileType, PGOProfilerDecoder *decoder, CString &abcName)
|
||||
{
|
||||
if (profileType.IsBuiltinsType()) {
|
||||
// drop abcName in ap file, just use compiler's
|
||||
abcName = panda::ecmascript::TSTypeTable::DEFAULT_TYPE_VIRTUAL_NAME;
|
||||
} else {
|
||||
auto abcId = profileType.GetAbcId();
|
||||
if (!decoder->GetAbcNameById(abcId, abcName)) {
|
||||
return false;
|
||||
}
|
||||
abcName = JSPandaFile::GetNormalizedFileDesc(abcName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GlobalTSTypeRef TSTypeParser::ParsePGOType(PGOInfo &info)
|
||||
{
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(info.recordName);
|
||||
CString abcName = info.jsPandaFile->GetNormalizedFileDesc();
|
||||
if (info.pgoType.IsProfileType()) {
|
||||
if (!GetAbcNameFromProfileType(info.pgoType.GetProfileType(), info.decoder, abcName)) {
|
||||
return GlobalTSTypeRef::Default();
|
||||
}
|
||||
}
|
||||
uint32_t moduleId = tableGenerator_.TryGetModuleId(abcName, info.recordName);
|
||||
if (UNLIKELY(!GlobalTSTypeRef::IsValidModuleId(moduleId))) {
|
||||
LOG_COMPILER(DEBUG) << "The maximum number of TSTypeTables is reached. All TSTypes in the record "
|
||||
<< info.recordName << " will not be parsed and will be treated as any.";
|
||||
|
@ -182,6 +182,8 @@ private:
|
||||
|
||||
GlobalTSTypeRef ParsePGOType(PGOInfo &info);
|
||||
|
||||
bool GetAbcNameFromProfileType(ProfileType profileType, PGOProfilerDecoder *decoder, CString &abcName);
|
||||
|
||||
JSHandle<JSTaggedValue> ParseNonImportPGOType(GlobalTSTypeRef gt, PGOInfo &info);
|
||||
|
||||
JSHandle<JSTaggedValue> ParseObjectPGOType(GlobalTSTypeRef gt, PGOInfo &info);
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
static constexpr size_t INCREASE_CAPACITY_RATE = 2;
|
||||
static constexpr const char* PRIMITIVE_TABLE_NAME = "primitiveTypes";
|
||||
static constexpr const char* BUILTINS_TABLE_NAME = "lib_ark_builtins.d";
|
||||
static constexpr const char* DEFAULT_TYPE_VIRTUAL_NAME = "default_type_virtual_name";
|
||||
static constexpr const char* INFER_TABLE_NAME = "inferTypes";
|
||||
static constexpr const char* RUNTIME_TABLE_NAME = "runtimeTypes";
|
||||
static constexpr const char* GENERICS_TABLE_NAME = "genericsTypes";
|
||||
|
@ -18,36 +18,38 @@
|
||||
#include "ecmascript/global_env_constants-inl.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_manager.h"
|
||||
#include "ecmascript/jspandafile/type_literal_extractor.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
void TSTypeTableGenerator::GenerateDefaultTSTypeTables()
|
||||
{
|
||||
JSHandle<EcmaString> defaultTypeAbcName = factory_->NewFromASCII(TSTypeTable::DEFAULT_TYPE_VIRTUAL_NAME);
|
||||
JSHandle<EcmaString> primitiveTableName = factory_->NewFromASCII(TSTypeTable::PRIMITIVE_TABLE_NAME);
|
||||
AddTypeTable(primitiveTableName);
|
||||
AddTypeTable(defaultTypeAbcName, primitiveTableName);
|
||||
|
||||
GenerateBuiltinsTypeTable();
|
||||
GenerateBuiltinsTypeTable(defaultTypeAbcName);
|
||||
|
||||
JSHandle<EcmaString> inferTableName = factory_->NewFromASCII(TSTypeTable::INFER_TABLE_NAME);
|
||||
AddTypeTable(inferTableName);
|
||||
AddTypeTable(defaultTypeAbcName, inferTableName);
|
||||
|
||||
JSHandle<EcmaString> runtimeTableName = factory_->NewFromASCII(TSTypeTable::RUNTIME_TABLE_NAME);
|
||||
AddTypeTable(runtimeTableName);
|
||||
AddTypeTable(defaultTypeAbcName, runtimeTableName);
|
||||
|
||||
InitRuntimeTypeTable();
|
||||
|
||||
JSHandle<EcmaString> genericsTableName = factory_->NewFromASCII(TSTypeTable::GENERICS_TABLE_NAME);
|
||||
AddTypeTable(genericsTableName);
|
||||
AddTypeTable(defaultTypeAbcName, genericsTableName);
|
||||
}
|
||||
|
||||
void TSTypeTableGenerator::GenerateBuiltinsTypeTable()
|
||||
void TSTypeTableGenerator::GenerateBuiltinsTypeTable(JSHandle<EcmaString> defaultTypeAbcName)
|
||||
{
|
||||
JSHandle<EcmaString> builtinsTableName = factory_->NewFromASCII(TSTypeTable::BUILTINS_TABLE_NAME);
|
||||
if (LIKELY(tsManager_->IsBuiltinsDTSEnabled())) {
|
||||
tsManager_->GenerateBuiltinSummary();
|
||||
uint32_t numOfTypes = tsManager_->GetBuiltinOffset(static_cast<uint32_t>(BuiltinTypeId::NUM_INDEX_IN_SUMMARY));
|
||||
AddTypeTable(builtinsTableName, numOfTypes);
|
||||
AddTypeTable(defaultTypeAbcName, builtinsTableName, numOfTypes);
|
||||
} else {
|
||||
AddTypeTable(builtinsTableName);
|
||||
AddTypeTable(defaultTypeAbcName, builtinsTableName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +61,7 @@ JSHandle<TSTypeTable> TSTypeTableGenerator::GetOrGenerateTSTypeTable(const JSPan
|
||||
return tsManager_->GetTSTypeTable(moduleId);
|
||||
}
|
||||
JSHandle<EcmaString> recordNameStr = factory_->NewFromUtf8(recordName);
|
||||
JSHandle<EcmaString> abcNameStr = factory_->NewFromUtf8(jsPandaFile->GetJSPandaFileDesc());
|
||||
// when PGO is enabled, no matter whether the abc file is a '.js' or a '.ts' file, it may contain PGO GT
|
||||
uint32_t typeNum = tsManager_->GetPGOGTCountByRecordName(recordName);
|
||||
if (jsPandaFile->HasTSTypes(recordName)) {
|
||||
@ -66,14 +69,15 @@ JSHandle<TSTypeTable> TSTypeTableGenerator::GetOrGenerateTSTypeTable(const JSPan
|
||||
TypeSummaryExtractor summExtractor(jsPandaFile, recordName);
|
||||
typeNum += summExtractor.GetNumOfTypes();
|
||||
}
|
||||
JSHandle<TSTypeTable> table = AddTypeTable(recordNameStr, typeNum);
|
||||
JSHandle<TSTypeTable> table = AddTypeTable(abcNameStr, recordNameStr, typeNum);
|
||||
return table;
|
||||
}
|
||||
|
||||
uint32_t TSTypeTableGenerator::TryGetModuleId(const CString &recordName) const
|
||||
uint32_t TSTypeTableGenerator::TryGetModuleId(const CString &abcName, const CString &recordName) const
|
||||
{
|
||||
JSHandle<EcmaString> recordNameStr = factory_->NewFromUtf8(recordName);
|
||||
int moduleIdBaseOnFile = GetTSModuleTable()->GetGlobalModuleID(thread_, recordNameStr);
|
||||
JSHandle<EcmaString> abcNameStr = factory_->NewFromUtf8(abcName);
|
||||
int moduleIdBaseOnFile = GetTSModuleTable()->GetGlobalModuleID(thread_, recordNameStr, abcNameStr);
|
||||
if (moduleIdBaseOnFile != TSModuleTable::NOT_FOUND) {
|
||||
return moduleIdBaseOnFile;
|
||||
}
|
||||
@ -85,19 +89,21 @@ uint32_t TSTypeTableGenerator::TryGetLocalId(const JSHandle<TSTypeTable> &table)
|
||||
return table->GetNumberOfTypes() + 1;
|
||||
}
|
||||
|
||||
JSHandle<TSTypeTable> TSTypeTableGenerator::AddTypeTable(const JSHandle<EcmaString> &recordNameStr,
|
||||
JSHandle<TSTypeTable> TSTypeTableGenerator::AddTypeTable(const JSHandle<EcmaString> &abcNameStr,
|
||||
const JSHandle<EcmaString> &recordNameStr,
|
||||
uint32_t numTypes)
|
||||
{
|
||||
JSHandle<TSTypeTable> typeTable = factory_->NewTSTypeTable(numTypes);
|
||||
|
||||
JSHandle<TSModuleTable> table = GetTSModuleTable();
|
||||
int numberOfTSTypeTable = table->GetNumberOfTSTypeTables();
|
||||
if (TSModuleTable::GetTSTypeTableOffset(numberOfTSTypeTable) > table->GetLength()) {
|
||||
if (TSModuleTable::GetAbcRequestOffset(numberOfTSTypeTable) >= table->GetLength()) {
|
||||
table = JSHandle<TSModuleTable>(TaggedArray::SetCapacity(thread_, JSHandle<TaggedArray>(table),
|
||||
table->GetLength() * TSModuleTable::INCREASE_CAPACITY_RATE));
|
||||
}
|
||||
// add ts type table
|
||||
table->SetNumberOfTSTypeTables(thread_, numberOfTSTypeTable + 1);
|
||||
table->Set(thread_, TSModuleTable::GetAbcRequestOffset(numberOfTSTypeTable), abcNameStr);
|
||||
table->Set(thread_, TSModuleTable::GetModuleRequestOffset(numberOfTSTypeTable), recordNameStr);
|
||||
table->Set(thread_, TSModuleTable::GetSortIdOffset(numberOfTSTypeTable), JSTaggedValue(numberOfTSTypeTable));
|
||||
table->Set(thread_, TSModuleTable::GetTSTypeTableOffset(numberOfTSTypeTable), typeTable);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
const CString &recordName,
|
||||
uint32_t moduleId);
|
||||
|
||||
uint32_t TryGetModuleId(const CString &recordName) const;
|
||||
uint32_t TryGetModuleId(const CString &abcName, const CString &recordName) const;
|
||||
|
||||
uint32_t TryGetLocalId(const JSHandle<TSTypeTable> &table) const;
|
||||
|
||||
@ -49,9 +49,10 @@ private:
|
||||
return table->GetNumberOfTSTypeTables();
|
||||
}
|
||||
|
||||
JSHandle<TSTypeTable> AddTypeTable(const JSHandle<EcmaString> &recordNameStr, uint32_t numTypes = 0);
|
||||
JSHandle<TSTypeTable> AddTypeTable(const JSHandle<EcmaString> &abcNameStr,
|
||||
const JSHandle<EcmaString> &recordNameStr, uint32_t numTypes = 0);
|
||||
|
||||
void GenerateBuiltinsTypeTable();
|
||||
void GenerateBuiltinsTypeTable(JSHandle<EcmaString> defaultTypeAbcName);
|
||||
|
||||
void InitRuntimeTypeTable();
|
||||
|
||||
@ -64,5 +65,5 @@ private:
|
||||
JSThread *thread_ {nullptr};
|
||||
ObjectFactory *factory_ {nullptr};
|
||||
};
|
||||
} // panda::ecmascript
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_TS_TYPES_TS_TYPE_TABLE_GENERATOR_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user