Skip to content

Conversation

@obastemur
Copy link
Collaborator

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

@rhuanjl
Copy link
Collaborator

rhuanjl commented Jan 13, 2018

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.
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@obastemur
Copy link
Collaborator Author

My only comment would be that I'd like to see the test case added.

@rhuanjl on your previous branch, could you please make test case a single commit? So, I could cherry pick here.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Jan 16, 2018

@obastemur
Did it as a new branch, don't know a way to easily split 1 commit into 2.
This is the test case only:
rhuanjl@efad36f

@akroshg
Copy link
Contributor

akroshg commented Jan 16, 2018

Please add a native tests to cover the scenario

Copy link
Contributor

@boingoing boingoing left a 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();
Copy link
Contributor

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() ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, done!

@obastemur
Copy link
Collaborator Author

@rhuanjl @jackhorton @akroshg @boingoing Thanks for review!

@chakrabot chakrabot merged commit b20e1aa into chakra-core:release/1.8 Jan 16, 2018
chakrabot pushed a commit that referenced this pull request Jan 16, 2018
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
chakrabot pushed a commit that referenced this pull request Jan 16, 2018
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
chakrabot pushed a commit that referenced this pull request Jan 17, 2018
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants