diff --git a/ecmascript/module/js_module_source_text.cpp b/ecmascript/module/js_module_source_text.cpp index 790050a045867f15d510974b007e1a01d82ecdd6..d5367cd2dadfd149da2400d9ef1a2c8c0e22363d 100644 --- a/ecmascript/module/js_module_source_text.cpp +++ b/ecmascript/module/js_module_source_text.cpp @@ -645,8 +645,6 @@ bool SourceTextModule::PreModuleInstantiation(JSThread *thread, int SourceTextModule::FinishModuleInstantiation(JSThread *thread, JSHandle module, CVector> &stack, int index, JSHandle exception) { - // Add a safepoint here to check if a suspension is needed. - thread->CheckSafepointIfSuspended(); // ArkTS module doesn't implement other module Record, delete follow branch. // 1. If module is not a Source Text Module Record, then // a. Perform ? module.Instantiate(). @@ -711,6 +709,9 @@ int SourceTextModule::FinishModuleInstantiation(JSThread *thread, JSHandle &module) { + // Add a safepoint here to check if a suspension is needed. + thread->CheckSafepointIfSuspended(); + CheckResolvedBinding(thread, module); if (module->GetImportEntries(thread).IsUndefined()) { return; @@ -789,6 +790,9 @@ void SourceTextModule::ModuleDeclarationEnvironmentSetup(JSThread *thread, void SourceTextModule::ModuleDeclarationArrayEnvironmentSetup(JSThread *thread, const JSHandle &module) { + // Add a safepoint here to check if a suspension is needed. + thread->CheckSafepointIfSuspended(); + ModuleTraceScope moduleTraceScope(thread, "SourceTextModule::Instantiating:" + module->GetEcmaModuleRecordNameString()); if (IsSharedModule(module) && SharedModuleManager::GetInstance()->IsInstantiatedSModule(thread, module)) {