-
Notifications
You must be signed in to change notification settings - Fork 1.2k
module: support for circular import #4551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
48082f2 to
8329c60
Compare
|
Definitely neater than my proposed fix was and does indeed fix the issue so I've closed my PR. My only comment would be that I'd like to see the test case added. |
| const static uint InvalidSlotIndex = 0xffffffff; | ||
| // TODO: move non-GC fields out to avoid false reference? | ||
| // This is the parsed tree resulted from compilation. | ||
| // This is the parsed tree resulted from compilation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment supposed to be one line below now?
| if (moduleRecord->shouldGenerateRootFunction) | ||
| { | ||
| moduleRecord->shouldGenerateRootFunction = false; | ||
| moduleRecord->GenerateRootFunction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can GenerateRootFunction set the above flag false itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually false rest of the times.
@rhuanjl on your previous branch, could you please make test case a single commit? So, I could cherry pick here. |
|
@obastemur |
|
Please add a native tests to cover the scenario |
8329c60 to
4f1aefe
Compare
4f1aefe to
aac4d94
Compare
boingoing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for fixing that memory leak which makes testing hard. 👍
|
|
||
| void SourceTextModuleRecord::GenerateRootFunction() | ||
| { | ||
| ScriptContext* scriptContext = GetScriptContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to assert this->WasDeclarationInitialized() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, done!
|
@rhuanjl @jackhorton @akroshg @boingoing Thanks for review! |
Merge pull request #4551 from obastemur:module_circular Alternative to #4550 , fixes #4482 Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support. I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg @boingoing @rhuanjl #### how it works Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
Merge pull request #4551 from obastemur:module_circular Alternative to #4550 , fixes #4482 Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support. I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg @boingoing @rhuanjl #### how it works Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
…ircular import Merge pull request #4551 from obastemur:module_circular Alternative to #4550 , fixes #4482 Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support. I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg @boingoing @rhuanjl #### how it works Separate `ModuleDeclarationInstantiation` into `ModuleDeclarationInstantiation` and `GenerateRootFunction`. This way, in case `childrenModuleSet` has circular dependents, we may instantiate all the modules prior to triggering the rest
Alternative to #4550 , fixes #4482
Saw the test case brought by @rhuanjl to #4482 and the proposed fix at #4550 . After looking at the code, looks like couple of tiny changes are needed to module support.
I don't have much context on modules though. This PR is just a weekend after breakfast hacking. /cc @akroshg @boingoing @rhuanjl
how it works
Separate
ModuleDeclarationInstantiationintoModuleDeclarationInstantiationandGenerateRootFunction. This way, in casechildrenModuleSethas circular dependents, we may instantiate all the modules prior to triggering the rest