Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Initial codegen node factory cleanup#6411

Merged
trylek merged 6 commits into
dotnet:r2rfrom
lkts:codegen-node-factory-cleanup
Oct 13, 2018
Merged

Initial codegen node factory cleanup#6411
trylek merged 6 commits into
dotnet:r2rfrom
lkts:codegen-node-factory-cleanup

Conversation

@lkts
Copy link
Copy Markdown

@lkts lkts commented Oct 1, 2018

This is a very harsh WIP, but i lack domain knowledge to proceed :)
I poked this class a bit and here are couple of observations/questions:

  1. It is not very easy to stop deriving from NodeFactory.
    There are some places where methods are called through base class: HeaderNode which derives from ObjectNode and other base infrastructure: CompilationBuilder and Compilation.
  2. To split this class some approach is needed for initializing and passing around objects which currently are exposed as fields (f.e. "Import" ones are commonly used).
    I hached this by passing whole factory to new extracted class but it is indeed a hack.
    Also initialization process in AttachToDependencyGraph is complex and I am not sure if it can/should be split.
  3. What exactly are "Token collection and lookup engine" and "R2R header table collection management." ? The only one method that mentions "token" seems unused.

Fixes https://github.com/dotnet/corert/issues/6274

cc @nattress

@lkts lkts changed the title Codegen node factory cleanup WIP: Codegen node factory cleanup Oct 1, 2018
@trylek
Copy link
Copy Markdown
Member

trylek commented Oct 11, 2018

I believe this is a great step towards making the R2RCGNF more reasonable and less of a dumping ground for arbitrary code that didn't fit elsewhere. Let's hear what Simon has to say but to me your change looks good - I'm ready to approve it as soon as you remove the WIP prefix from the PR title. You will probably need to resolve some conflicts there - that's actually one more reason why it might be useful to just finish the review, merge the change in and possibly start another one if you see opportunities for additional cleanup; there's lots of traffic in this branch and maintaining an open PR for too long is often quite painful.

Thanks a lot Oleksandr for making these changes!

@@ -0,0 +1,39 @@
using System;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Each source file needs to have the copyright header added. Could you please copy-paste from another file to top here.

return info.Constructor;
}

Dictionary<ILCompiler.ReadyToRunHelper, ISymbolNode> _helperCache = new Dictionary<ILCompiler.ReadyToRunHelper, ISymbolNode>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Prepend with private

return ExternSymbol(helperId);
}

readonly Dictionary<MethodAndCallSite, ISymbolNode> _interfaceDispatchCells = new Dictionary<MethodAndCallSite, ISymbolNode>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Prepend with private

return ReadyToRunHelper(helperId, entity, signatureContext);
}

readonly Dictionary<MethodDesc, ISortableSymbolNode> _genericDictionaryCache = new Dictionary<MethodDesc, ISortableSymbolNode>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Prepend with private

return genericDictionary;
}

readonly Dictionary<TypeDesc, ISymbolNode> _constructedTypeSymbols = new Dictionary<TypeDesc, ISymbolNode>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Prepend with private

@nattress
Copy link
Copy Markdown
Contributor

Oleksandr this looks great - thanks for taking the time to organize this class. We are still discussing how we want this to look in the future but for now I'll gladly take this cleanup. I would leave things as they are in AttachToDependencyGraph in this PR.

For your question #3 above, could you point at where in the code you're referring?

@lkts lkts force-pushed the codegen-node-factory-cleanup branch from 8cd9a85 to 95d88dc Compare October 12, 2018 19:23
@lkts lkts changed the title WIP: Codegen node factory cleanup Initial codegen node factory cleanup Oct 12, 2018
@lkts
Copy link
Copy Markdown
Author

lkts commented Oct 12, 2018

Tomas, Simon, thank you for feedback. Merging changes one by one definitely is the right think to do. I had an idea to introduce something like CodegenContext which would be responsible for AttachToDependencyGraph and will be passed to factories but i didn`t look if it is possible.

For now I have done a pretty painful rebase, hope that everything is okay.

Regarding my third question - I was referring to the description of https://github.com/dotnet/corert/issues/6274 , third bullet point there.

@lkts
Copy link
Copy Markdown
Author

lkts commented Oct 12, 2018

@dotnet-bot test OSX10.12 Debug and CoreCLR tests

hm, how do i unWIP it?

@trylek
Copy link
Copy Markdown
Member

trylek commented Oct 12, 2018

Hmm, I hit that myself sometime ago, apparently there's some "smart" logic that WIP's your change whenever it finds WIP anywhere in the description, not just in the title. I'd try to edit the change description and leave out the reference to WIP; after that, you might need to retest the change to get rid of the dotnet bot still treating the change as WIP.

@lkts lkts force-pushed the codegen-node-factory-cleanup branch from 95d88dc to 1e3ae4c Compare October 13, 2018 07:20
@lkts
Copy link
Copy Markdown
Author

lkts commented Oct 13, 2018

Turns out commit messages turn on the WIP (along with title and labels). I guess I should use only title for WIPs in future as it is the most confortable way.

Upd: not sure what`s up with WASM test.

@trylek
Copy link
Copy Markdown
Member

trylek commented Oct 13, 2018

Don't worry about WASM, it's been broken half of the time with my and Simon's changes too. We'll need to take a look at some point but it's not Pri# 0 right now.


public new ReadyToRunCodegenNodeFactory NodeFactory { get; }

public ReadyToRunSymbolNodeFactory SymbolNodeFactory { get; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm wondering whether it might be more descriptive to call the new class "ReadyToRunHelperFactory".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

probably :)

: base(dependencyGraph, nodeFactory, roots, ilProvider, debugInformationProvider, devirtualizationManager, logger)
{
NodeFactory = nodeFactory;
SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is such a big hack. It will probably take several iterations to finish the transition, for now I believe this is just fine.

@@ -0,0 +1,39 @@
using System;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit - I'm not sure how much value there is in separating out this tiny class considering there are ten others like this in the node / helper factory but I don't have a strong opinion on this; perhaps you're right that longer term we would be better off pulling all these helpers out to separate classes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It is used in both factories, that`s why i extracted it.

@trylek trylek merged commit e4e11db into dotnet:r2r Oct 13, 2018
@lkts lkts deleted the codegen-node-factory-cleanup branch October 13, 2018 08:40
trylek pushed a commit to trylek/corert that referenced this pull request Oct 15, 2018
* Initial ReadyToRunCodegenNodeFactory cleanup

* Extract part of ReadyToRunCodegenNodeFactory to separate class

* Fixes after rebase

* Addressed code review feedback

* Fixed rebase issue

* Minor additional cleanup
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants