From dba07348d0d3421e8b6e0a685abe389641f75c76 Mon Sep 17 00:00:00 2001 From: Mikhail Ivanov Date: Wed, 18 Jun 2025 16:00:53 +0300 Subject: [PATCH] Optimize node history Description: Do not copy Checker data Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICG6HN Signed-off-by: Mikhail Ivanov --- ets2panda/checker/ETSchecker.cpp | 182 ++++++++++++++---- ets2panda/checker/ETSchecker.h | 47 +++-- ets2panda/checker/ets/object.cpp | 52 ++--- ets2panda/checker/ets/typeCreation.cpp | 9 +- .../checker/types/ets/etsFunctionType.cpp | 27 ++- ets2panda/checker/types/ets/etsObjectType.cpp | 33 ++-- ets2panda/compiler/core/ETSemitter.cpp | 4 +- 7 files changed, 240 insertions(+), 114 deletions(-) diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index f345e2e86b..d3f7b7daf3 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -57,36 +57,13 @@ void ETSChecker::ReputCheckerData() continue; } readdedChecker_.insert(eChecker->readdedChecker_.begin(), eChecker->readdedChecker_.end()); - auto computedAbstractMapToCopy = eChecker->GetCachedComputedAbstracts(); - for (auto &[key, value] : *computedAbstractMapToCopy) { - if (GetCachedComputedAbstracts()->find(key) != GetCachedComputedAbstracts()->end()) { - continue; - } - auto &[v1, v2] = value; - ArenaVector newV1(Allocator()->Adapter()); - ArenaUnorderedSet newV2(Allocator()->Adapter()); - newV1.assign(v1.cbegin(), v1.cend()); - newV2.insert(v2.cbegin(), v2.cend()); - GetCachedComputedAbstracts()->try_emplace(key, newV1, newV2); - } - - auto &globalArraySigs = eChecker->globalArraySignatures_; - globalArraySignatures_.insert(globalArraySigs.cbegin(), globalArraySigs.cend()); - auto &apparentTypes = eChecker->apparentTypes_; - apparentTypes_.insert(apparentTypes.cbegin(), apparentTypes.cend()); - - auto &objectInstantiationMap = eChecker->objectInstantiationMap_; - for (auto &[key, value] : objectInstantiationMap) { - if (objectInstantiationMap_.find(key) == objectInstantiationMap_.end()) { - objectInstantiationMap_.insert(objectInstantiationMap.cbegin(), objectInstantiationMap.cend()); - } - } - - auto &invokeToArrowSignatures = eChecker->invokeToArrowSignatures_; - invokeToArrowSignatures_.insert(invokeToArrowSignatures.cbegin(), invokeToArrowSignatures.cend()); - auto &arrowToFuncInterfaces = eChecker->arrowToFuncInterfaces_; - arrowToFuncInterfaces_.insert(arrowToFuncInterfaces.cbegin(), arrowToFuncInterfaces.cend()); + linkedCachedComputedAbstracts_.insert(eChecker->cachedComputedAbstracts_); + linkedGlobalArraySignatures_.insert(&eChecker->globalArraySignatures_); + linkedApparentTypes_.insert(&eChecker->apparentTypes_); + linkedObjectInstantiationMap_.insert(&eChecker->objectInstantiationMap_); + linkedInvokeToArrowSignatures_.insert(&eChecker->invokeToArrowSignatures_); + linkedArrowToFuncInterfaces_.insert(&eChecker->arrowToFuncInterfaces_); } } @@ -693,14 +670,153 @@ ETSObjectType *ETSChecker::GlobalBuiltinBoxType(Type *contents) } } -GlobalArraySignatureMap &ETSChecker::GlobalArrayTypes() +Signature *ETSChecker::FindGlobalArrayTypes(const ETSArrayType *key) +{ + if (auto found = globalArraySignatures_.find(key); LIKELY(found != globalArraySignatures_.end())) { + return found->second; + } + + for (auto globalArraySignatures : linkedGlobalArraySignatures_) { + if (auto found = globalArraySignatures->find(key); LIKELY(found != globalArraySignatures->end())) { + return found->second; + } + } + + return nullptr; +} + +Signature *ETSChecker::AddGlobalArrayTypes(const ETSArrayType *key, Signature *value) +{ + return globalArraySignatures_.emplace(key, value).first->second; +} + +void ETSChecker::Iterate(const ETSChecker::GlobalArraySignatureMapTraverser &cb) const +{ + for (auto &[key, value] : globalArraySignatures_) { + cb(key, value); + } + + for (auto globalArraySignatures : linkedGlobalArraySignatures_) { + for (auto &[key, value] : *globalArraySignatures) { + cb(key, value); + } + } +} + +bool ETSChecker::TryFindObjectInstantiationMap(ETSObjectType *key, + ArenaUnorderedMap *&value) +{ + if (auto found = objectInstantiationMap_.find(key); LIKELY(found != objectInstantiationMap_.end())) { + value = &found->second; + return true; + } + + for (auto objectInstantiationMap : linkedObjectInstantiationMap_) { + if (auto found = objectInstantiationMap->find(key); LIKELY(found != objectInstantiationMap->end())) { + value = &found->second; + return true; + } + } + + return false; +} + +ArenaUnorderedMap &ETSChecker::AddObjectInstantiationMap( + ETSObjectType *key, ArenaUnorderedMap &&value) +{ + return objectInstantiationMap_.emplace(key, std::move(value)).first->second; +} + +ETSFunctionType *ETSChecker::FindInvokeToArrowSignatures(ETSFunctionType *key) +{ + if (auto found = invokeToArrowSignatures_.find(key); LIKELY(found != invokeToArrowSignatures_.end())) { + return found->second; + } + + for (auto invokeToArrowSignatures : linkedInvokeToArrowSignatures_) { + if (auto found = invokeToArrowSignatures->find(key); LIKELY(found != invokeToArrowSignatures->end())) { + return found->second; + } + } + + return nullptr; +} + +ETSFunctionType *ETSChecker::AddInvokeToArrowSignatures(ETSFunctionType *key, ETSFunctionType *value) { - return globalArraySignatures_; + return invokeToArrowSignatures_.emplace(key, value).first->second; } -const GlobalArraySignatureMap &ETSChecker::GlobalArrayTypes() const +ETSObjectType *ETSChecker::FindArrowToFuncInterfaces(ETSFunctionType *key) { - return globalArraySignatures_; + if (auto found = arrowToFuncInterfaces_.find(key); LIKELY(found != arrowToFuncInterfaces_.end())) { + return found->second; + } + + for (auto arrowToFuncInterfaces : linkedArrowToFuncInterfaces_) { + if (auto found = arrowToFuncInterfaces->find(key); LIKELY(found != arrowToFuncInterfaces->end())) { + return found->second; + } + } + + return nullptr; +} + +ETSObjectType *ETSChecker::AddArrowToFuncInterfaces(ETSFunctionType *key, ETSObjectType *value) +{ + return arrowToFuncInterfaces_.emplace(key, value).first->second; +} + +Type *ETSChecker::FindApparentTypes(Type const *key) +{ + if (auto found = apparentTypes_.find(key); LIKELY(found != apparentTypes_.end())) { + return found->second; + } + + for (auto apparentTypes : linkedApparentTypes_) { + if (auto found = apparentTypes->find(key); LIKELY(found != apparentTypes->end())) { + return found->second; + } + } + + return nullptr; +} + +Type *ETSChecker::AddApparentTypes(Type const *key, Type *value) +{ + return apparentTypes_.emplace(key, value).first->second; +} + +bool ETSChecker::TryFindCachedComputedAbstracts( + ETSObjectType *key, std::pair, ArenaUnorderedSet> *&value) +{ + if (cachedComputedAbstracts_ == nullptr) { + InitCachedComputedAbstracts(); + } + + if (auto found = cachedComputedAbstracts_->find(key); LIKELY(found != cachedComputedAbstracts_->end())) { + value = &found->second; + return true; + } + + for (auto cachedComputedAbstracts : linkedCachedComputedAbstracts_) { + if (auto found = cachedComputedAbstracts->find(key); LIKELY(found != cachedComputedAbstracts->end())) { + value = &found->second; + return true; + } + } + + return false; +} + +std::pair, ArenaUnorderedSet> &ETSChecker::AddCachedComputedAbstracts( + ETSObjectType *key, std::pair, ArenaUnorderedSet> &&value) +{ + if (cachedComputedAbstracts_ == nullptr) { + InitCachedComputedAbstracts(); + } + + return cachedComputedAbstracts_->emplace(key, value).first->second; } Type *ETSChecker::GlobalTypeError() const diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 97ae5b8f2b..74a6d8822e 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -89,9 +89,14 @@ public: arrayTypes_(Allocator()->Adapter()), pendingConstraintCheckRecords_(Allocator()->Adapter()), objectInstantiationMap_(Allocator()->Adapter()), + linkedObjectInstantiationMap_(Allocator()->Adapter()), invokeToArrowSignatures_(Allocator()->Adapter()), + linkedInvokeToArrowSignatures_(Allocator()->Adapter()), arrowToFuncInterfaces_(Allocator()->Adapter()), + linkedArrowToFuncInterfaces_(Allocator()->Adapter()), globalArraySignatures_(Allocator()->Adapter()), + linkedGlobalArraySignatures_(Allocator()->Adapter()), + linkedCachedComputedAbstracts_(Allocator()->Adapter()), dynamicIntrinsics_ {DynamicCallIntrinsicsMap {Allocator()->Adapter()}, DynamicCallIntrinsicsMap {Allocator()->Adapter()}}, dynamicClasses_ {DynamicClassIntrinsicsMap(Allocator()->Adapter()), @@ -99,6 +104,7 @@ public: dynamicLambdaSignatureCache_(Allocator()->Adapter()), functionalInterfaceCache_(Allocator()->Adapter()), apparentTypes_(Allocator()->Adapter()), + linkedApparentTypes_(Allocator()->Adapter()), dynamicCallNames_ { {DynamicCallNamesMap(Allocator()->Adapter()), DynamicCallNamesMap(Allocator()->Adapter())}}, overloadSigContainer_(Allocator()->Adapter()), @@ -168,8 +174,11 @@ public: ETSObjectType *GlobalBuiltinDynamicType(Language lang) const; - GlobalArraySignatureMap &GlobalArrayTypes(); - const GlobalArraySignatureMap &GlobalArrayTypes() const; + Signature *FindGlobalArrayTypes(const ETSArrayType *key); + Signature *AddGlobalArrayTypes(const ETSArrayType *key, Signature *value); + + using GlobalArraySignatureMapTraverser = std::function; + void Iterate(const GlobalArraySignatureMapTraverser &cb) const; Type *GlobalTypeError() const; [[nodiscard]] Type *InvalidateType(ir::Typed *node); @@ -886,20 +895,19 @@ public: return overloadSigContainer_; } - ObjectInstantiationMap &GetObjectInstantiationMap() - { - return objectInstantiationMap_; - } + bool TryFindObjectInstantiationMap(ETSObjectType *key, + ArenaUnorderedMap *&value); + ArenaUnorderedMap &AddObjectInstantiationMap( + ETSObjectType *key, ArenaUnorderedMap &&value); - FunctionSignatureMap &GetInvokeToArrowSignatures() - { - return invokeToArrowSignatures_; - } + ETSFunctionType *FindInvokeToArrowSignatures(ETSFunctionType *key); + ETSFunctionType *AddInvokeToArrowSignatures(ETSFunctionType *key, ETSFunctionType *value); - FunctionInterfaceMap &GetArrowToFuncInterfaces() - { - return arrowToFuncInterfaces_; - } + ETSObjectType *FindArrowToFuncInterfaces(ETSFunctionType *key); + ETSObjectType *AddArrowToFuncInterfaces(ETSFunctionType *key, ETSObjectType *value); + + Type *FindApparentTypes(Type const *key); + Type *AddApparentTypes(Type const *key, Type *value); void ClearApparentTypes() noexcept { @@ -936,6 +944,11 @@ public: checker::ETSFunctionType *IntersectSignatureSets(const checker::ETSFunctionType *left, const checker::ETSFunctionType *right); + bool TryFindCachedComputedAbstracts( + ETSObjectType *key, std::pair, ArenaUnorderedSet> *&value); + std::pair, ArenaUnorderedSet> &AddCachedComputedAbstracts( + ETSObjectType *key, std::pair, ArenaUnorderedSet> &&value); + ComputedAbstracts *GetCachedComputedAbstracts() { if (cachedComputedAbstracts_ == nullptr) { @@ -1068,17 +1081,23 @@ private: ArrayMap arrayTypes_; ArenaVector pendingConstraintCheckRecords_; ObjectInstantiationMap objectInstantiationMap_; + ArenaSet linkedObjectInstantiationMap_; FunctionSignatureMap invokeToArrowSignatures_; + ArenaSet linkedInvokeToArrowSignatures_; FunctionInterfaceMap arrowToFuncInterfaces_; + ArenaSet linkedArrowToFuncInterfaces_; size_t constraintCheckScopesCount_ {0}; GlobalArraySignatureMap globalArraySignatures_; + ArenaSet linkedGlobalArraySignatures_; ComputedAbstracts *cachedComputedAbstracts_ {nullptr}; + ArenaSet linkedCachedComputedAbstracts_; // NOTE(aleksisch): Extract dynamic from checker to separate class std::array dynamicIntrinsics_; std::array dynamicClasses_; DynamicLambdaObjectSignatureMap dynamicLambdaSignatureCache_; FunctionalInterfaceMap functionalInterfaceCache_; TypeMapping apparentTypes_; + ArenaSet linkedApparentTypes_; std::array dynamicCallNames_; std::recursive_mutex mtx_; evaluate::ScopedDebugInfoPlugin *debugInfoPlugin_ {nullptr}; diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 4760ea0ca1..2e38404c8c 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -727,8 +727,8 @@ void ETSChecker::CreateFunctionTypesFromAbstracts(const std::vector void ETSChecker::ComputeAbstractsFromInterface(ETSObjectType *interfaceType) { - auto cached = GetCachedComputedAbstracts()->find(interfaceType); - if (cached != GetCachedComputedAbstracts()->end()) { + std::pair, ArenaUnorderedSet> *found = nullptr; + if (TryFindCachedComputedAbstracts(interfaceType, found)) { return; } @@ -741,21 +741,22 @@ void ETSChecker::ComputeAbstractsFromInterface(ETSObjectType *interfaceType) ArenaUnorderedSet abstractInheritanceTarget(ProgramAllocator()->Adapter()); for (auto *interface : interfaceType->Interfaces()) { - auto found = GetCachedComputedAbstracts()->find(interface); - ES2PANDA_ASSERT(found != GetCachedComputedAbstracts()->end()); + found = nullptr; + TryFindCachedComputedAbstracts(interface, found); + ES2PANDA_ASSERT(found != nullptr); - if (!abstractInheritanceTarget.insert(found->first).second) { + if (!abstractInheritanceTarget.insert(interface).second) { continue; } - MergeComputedAbstracts(merged, found->second.first); + MergeComputedAbstracts(merged, found->first); - for (auto *base : found->second.second) { + for (auto *base : found->second) { abstractInheritanceTarget.insert(base); } } - GetCachedComputedAbstracts()->insert({interfaceType, {merged, abstractInheritanceTarget}}); + AddCachedComputedAbstracts(interfaceType, {merged, abstractInheritanceTarget}); } ArenaVector &ETSChecker::GetAbstractsForClass(ETSObjectType *classType) @@ -765,33 +766,35 @@ ArenaVector &ETSChecker::GetAbstractsForClass(ETSObjectType * ArenaUnorderedSet abstractInheritanceTarget(ProgramAllocator()->Adapter()); if (classType->SuperType() != nullptr) { - auto base = GetCachedComputedAbstracts()->find(classType->SuperType()); - ES2PANDA_ASSERT(base != GetCachedComputedAbstracts()->end()); - MergeComputedAbstracts(merged, base->second.first); + std::pair, ArenaUnorderedSet> *base = nullptr; + TryFindCachedComputedAbstracts(classType->SuperType(), base); + ES2PANDA_ASSERT(base != nullptr); + MergeComputedAbstracts(merged, base->first); - abstractInheritanceTarget.insert(base->first); - for (auto *it : base->second.second) { + abstractInheritanceTarget.insert(classType->SuperType()); + for (auto *it : base->second) { abstractInheritanceTarget.insert(it); } } for (auto *it : classType->Interfaces()) { ComputeAbstractsFromInterface(it); - auto found = GetCachedComputedAbstracts()->find(it); - ES2PANDA_ASSERT(found != GetCachedComputedAbstracts()->end()); + std::pair, ArenaUnorderedSet> *found = nullptr; + TryFindCachedComputedAbstracts(it, found); + ES2PANDA_ASSERT(found != nullptr); - if (!abstractInheritanceTarget.insert(found->first).second) { + if (!abstractInheritanceTarget.insert(it).second) { continue; } - MergeComputedAbstracts(merged, found->second.first); + MergeComputedAbstracts(merged, found->first); - for (auto *interface : found->second.second) { + for (auto *interface : found->second) { abstractInheritanceTarget.insert(interface); } } - return GetCachedComputedAbstracts()->insert({classType, {merged, abstractInheritanceTarget}}).first->second.first; + return AddCachedComputedAbstracts(classType, {merged, abstractInheritanceTarget}).first; } [[maybe_unused]] static bool DoObjectImplementInterface(const ETSObjectType *interfaceType, const ETSObjectType *target, @@ -2474,17 +2477,16 @@ void ETSChecker::AddElementsToModuleObject(ETSObjectType *moduleObj, const util: Type *ETSChecker::GetApparentType(Type *type) { auto currChecker = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker(); - auto &apparentTypes = currChecker->apparentTypes_; - if (auto it = apparentTypes.find(type); LIKELY(it != apparentTypes.end())) { - return it->second; + if (auto found = FindApparentTypes(type); LIKELY(found != nullptr)) { + return found; } - auto cached = [&apparentTypes, type](Type *res) { + auto cached = [currChecker, type](Type *res) { if (type != res) { - apparentTypes.insert({type, res}); + currChecker->AddApparentTypes(type, res); } - apparentTypes.insert({res, res}); + currChecker->AddApparentTypes(res, res); return res; }; diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index fd835f0b7a..926f23003f 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -426,16 +426,15 @@ Signature *ETSChecker::CreateBuiltinArraySignature(const ETSArrayType *arrayType { auto currentChecker = compiler::GetPhaseManager()->Context() != nullptr ? compiler::GetPhaseManager()->Context()->GetChecker() : this; - auto &globalArraySignatures = currentChecker->AsETSChecker()->globalArraySignatures_; - auto res = globalArraySignatures.find(arrayType); - if (res != globalArraySignatures.end()) { - return res->second; + + if (auto found = currentChecker->AsETSChecker()->FindGlobalArrayTypes(arrayType); found != nullptr) { + return found; } auto [internalName, info] = CreateBuiltinArraySignatureInfo(arrayType, dim); auto *signature = CreateSignature(info, GlobalVoidType(), ir::ScriptFunctionFlags::NONE, false); signature->SetInternalName(internalName); - globalArraySignatures.insert({arrayType, signature}); + currentChecker->AsETSChecker()->AddGlobalArrayTypes(arrayType, signature); return signature; } diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 5a9a176d9c..de05c47864 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -119,16 +119,13 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, ETSObjectType *ETSFunctionType::ArrowToFunctionalInterface(ETSChecker *checker) { - auto &cached = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetArrowToFuncInterfaces(); - - auto found = cached.find(this); - if (LIKELY(found != cached.end())) { - return found->second; + if (auto found = + compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->FindArrowToFuncInterfaces(this); + found != nullptr) { + return found; } - return cached - .emplace(this, - FunctionTypeToFunctionalInterfaceType(checker, ArrowSignature(), ArrowSignature()->MinArgCount())) - .first->second; + return compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->AddArrowToFuncInterfaces( + this, FunctionTypeToFunctionalInterfaceType(checker, ArrowSignature(), ArrowSignature()->MinArgCount())); } ETSObjectType *ETSFunctionType::ArrowToFunctionalInterfaceDesiredArity(ETSChecker *checker, size_t arity) @@ -141,15 +138,15 @@ ETSObjectType *ETSFunctionType::ArrowToFunctionalInterfaceDesiredArity(ETSChecke ETSFunctionType *ETSFunctionType::MethodToArrow(ETSChecker *checker) { - auto &cached = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetInvokeToArrowSignatures(); - - auto found = cached.find(this); - if (LIKELY(found != cached.end())) { - return found->second; + if (auto found = + compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->FindInvokeToArrowSignatures(this); + LIKELY(found != nullptr)) { + return found; } ES2PANDA_ASSERT(!IsETSArrowType() && CallSignatures().size() == 1); - return cached.emplace(this, checker->CreateETSArrowType(CallSignatures()[0])).first->second; + return compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->AddInvokeToArrowSignatures( + this, checker->CreateETSArrowType(CallSignatures()[0])); } void ETSFunctionType::AddCallSignature(Signature *signature) diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index c86dbcd510..a202ea5619 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -1473,15 +1473,14 @@ void ETSObjectType::CheckVarianceRecursively(TypeRelation *relation, VarianceFla ETSObjectType *ETSObjectType::GetInstantiatedType(util::StringView hash) { - auto &instantiationMap = - compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetObjectInstantiationMap(); - auto found = instantiationMap.find(this); - if (found == instantiationMap.end()) { + auto checker = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker(); + ArenaUnorderedMap *found = nullptr; + if (!checker->TryFindObjectInstantiationMap(this, found)) { return nullptr; } - auto found2 = instantiationMap.at(this).find(hash); - if (found2 == instantiationMap.at(this).end()) { + auto found2 = found->find(hash); + if (found2 == found->end()) { return nullptr; } @@ -1490,21 +1489,15 @@ ETSObjectType *ETSObjectType::GetInstantiatedType(util::StringView hash) void ETSObjectType::InsertInstantiationMap(util::StringView key, ETSObjectType *value) { - auto &instantiationMap = - compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetObjectInstantiationMap(); - if (instantiationMap.find(this) == instantiationMap.end()) { - ArenaUnorderedMap instantiation( - compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->Allocator()->Adapter()); + auto checker = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker(); + ArenaUnorderedMap *found = nullptr; + if (!checker->TryFindObjectInstantiationMap(this, found)) { + ArenaUnorderedMap instantiation(checker->Allocator()->Adapter()); instantiation.emplace(key, value); - instantiationMap.emplace(this, instantiation); - } - compiler::GetPhaseManager() - ->Context() - ->GetChecker() - ->AsETSChecker() - ->GetObjectInstantiationMap() - .at(this) - .try_emplace(key, value); + found = &checker->AddObjectInstantiationMap(this, std::move(instantiation)); + } + + found->try_emplace(key, value); } } // namespace ark::es2panda::checker diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index d3dd8aa926..94b58a2e46 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -303,9 +303,9 @@ void ETSEmitter::GenAnnotation() const auto *checker = static_cast(Context()->GetChecker()); - for (auto [arrType, signature] : checker->GlobalArrayTypes()) { + checker->Iterate([this](const checker::ETSArrayType *arrType, checker::Signature *signature) { GenGlobalArrayRecord(arrType, signature); - } + }); if (Context()->config->options->WasSetWithExportTable()) { auto result = StoreExportNodes(Context()->parserProgram->DeclGenExportNodes(), Program()); Program()->exportStrMap = std::move(result); -- Gitee