From 8cc46eb471a8152b1a03aac7806667e3e9fbc35c Mon Sep 17 00:00:00 2001 From: rhuanjl Date: Fri, 19 Jan 2018 23:13:59 +0000 Subject: [PATCH 1/2] Correct test case to be independent of module load order. --- test/es6/module_4482_dep1.js | 9 ++++++--- test/es6/module_4482_dep2.js | 4 ++-- test/es6/module_4482_dep3.js | 7 +++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/es6/module_4482_dep1.js b/test/es6/module_4482_dep1.js index a1bf7c6120f..f2946d8e6e3 100644 --- a/test/es6/module_4482_dep1.js +++ b/test/es6/module_4482_dep1.js @@ -13,11 +13,14 @@ //v) Thing2 would not yet exist = segfault -import Thing1 from './module_4482_dep2.js'; -import Thing2 from './module_4482_dep3.js'; +import Thing1 from 'module_4482_dep2.js'; +import Thing2 from 'module_4482_dep3.js'; export { Thing1, Thing2 }; export default function main() -{} +{ + Thing1(); + Thing2(); +} diff --git a/test/es6/module_4482_dep2.js b/test/es6/module_4482_dep2.js index 32cf672cf9b..3f26da81abf 100644 --- a/test/es6/module_4482_dep2.js +++ b/test/es6/module_4482_dep2.js @@ -4,10 +4,10 @@ //------------------------------------------------------------------------------------------------------- //thing1.js -import { Thing2 } from './module_4482_dep1.js'; +import { Thing2 } from 'module_4482_dep1.js'; export default -function Thing1() +function main() { Thing2(); } diff --git a/test/es6/module_4482_dep3.js b/test/es6/module_4482_dep3.js index d15a10caf34..6b7b95046e5 100644 --- a/test/es6/module_4482_dep3.js +++ b/test/es6/module_4482_dep3.js @@ -4,7 +4,10 @@ //------------------------------------------------------------------------------------------------------- -import { Thing1 } from './module_4482_dep1.js'; +import { Thing1 } from 'module_4482_dep1.js'; export default -function Thing2(){} +function main() +{ + Thing1(); +} From 7f45088c4940209f2852750c2dc07df8e13f6be4 Mon Sep 17 00:00:00 2001 From: rhuanjl Date: Sat, 20 Jan 2018 00:03:21 +0000 Subject: [PATCH 2/2] Fixing 4482 again... Ensure that all child modules direct or indirect have been instantiated before we start generating any root functions. --- lib/Runtime/Language/SourceTextModuleRecord.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Runtime/Language/SourceTextModuleRecord.cpp b/lib/Runtime/Language/SourceTextModuleRecord.cpp index 4242cf4c329..9790aeee4cd 100644 --- a/lib/Runtime/Language/SourceTextModuleRecord.cpp +++ b/lib/Runtime/Language/SourceTextModuleRecord.cpp @@ -842,11 +842,6 @@ namespace Js Assert(childModuleRecord->WasParsed()); childModuleRecord->ModuleDeclarationInstantiation(); }); - - childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord) - { - childModuleRecord->GenerateRootFunction(); - }); } ENTER_SCRIPT_IF(scriptContext, true, false, false, !scriptContext->GetThreadContext()->IsScriptActive(), @@ -903,6 +898,13 @@ namespace Js scriptContext->GetDebugContext()->RegisterFunction(this->rootFunction->GetFunctionBody(), nullptr); } #endif + if (childrenModuleSet != nullptr) + { + childrenModuleSet->EachValue([=](SourceTextModuleRecord* childModuleRecord) + { + childModuleRecord->GenerateRootFunction(); + }); + } } Var SourceTextModuleRecord::ModuleEvaluation()