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

Interface Dispatch #1848

Merged
merged 1 commit into from
Sep 16, 2016
Merged

Interface Dispatch #1848

merged 1 commit into from
Sep 16, 2016

Conversation

A-And
Copy link
Contributor

@A-And A-And commented Sep 14, 2016

Interface Dispatch implementation


if (entrypoint != null)
{
OutputMainMethodStub(entrypoint);
}
// Stub for main method
Copy link
Member

Choose a reason for hiding this comment

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

I have moved this code to separate OutputMainMethodStub to make it better factored. Could you please keep it in separate function?

Out.Write(sb.ToString());
sb.Clear();

Out.Write(methodImplementations.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

Could you please keep the refactoring that I have done - that avoids building one huge string out of all method implementations?

It is a lot cycles wasted by copying all method implementations into a single string. It is better to write the individual implementations into the stream directly.

Out.Write(methodTables.ToString());
Out.Write(optionalFields.ToString());
definitions.Append(forwardDefinitions.ToString());
forwardDefinitions.Clear();
Copy link
Member

Choose a reason for hiding this comment

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

These Clear calls are unnecessary because of the builder is not reused.

return sb.ToString();
}

private String GetInterfaceDispatchHelper()
{
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem to be used. Is this left-over method?

@A-And A-And force-pushed the InterfDispatch branch 2 times, most recently from 71eadf3 to 954e516 Compare September 14, 2016 21:24
@@ -900,7 +889,7 @@ private String GetCodeForNodeStruct(List<NodeDataSection> nodeDataDivs, Dependen
return nodeStructDecl.ToString();
}

private void AppendFormattedByteArray(CppGenerationBuffer sb, byte[] array, int startIndex, int endIndex)
private void GetFormattedByteArray(byte[] array, int startIndex, int endIndex, CppGenerationBuffer sb)
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to keep the original name - it better expresses what the method does.

Also, you can make the method static while you are on it.

@@ -1239,8 +1285,11 @@ public void OutputCode(IEnumerable<DependencyNode> nodes, MethodDesc entrypoint,
_threadStatics.Indent();
_gcThreadStatics = new CppGenerationBuffer();
_gcThreadStatics.Indent();
var methodImplementations = new CppGenerationBuffer();
Copy link
Member

Choose a reason for hiding this comment

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

Unused.

Out.Write(sb.ToString());
}

public void OutputCode(IEnumerable<DependencyNode> nodes, MethodDesc entrypoint, NodeFactory factory)
{
var sb = new CppGenerationBuffer();
Copy link
Member

Choose a reason for hiding this comment

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

Unused - it looks like all changes in this function should be undone.

@A-And A-And force-pushed the InterfDispatch branch 2 times, most recently from d3e0f69 to de8ff17 Compare September 15, 2016 18:44
@A-And
Copy link
Contributor Author

A-And commented Sep 15, 2016

@jkotas @MichalStrehovsky Cleaned up. Could you take another look? (force pushing to fix build errors caused a commit to disappear, so the comments on the diffs are not current)

private void AddWellKnownTypes(DependencyAnalysisFramework.DependencyAnalyzerBase<NodeFactory> graph)
{

AddWellKnownType(WellKnownType.Void, graph);
Copy link
Member

Choose a reason for hiding this comment

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

Did you look into finding a way to not duplicate the list from _wellKnownTypeNodes from CppWriter in here? I dislike that we're setting a precedent here to root a bunch of things without explanation.

(I assume _wellKnownTypeNodes is the reason why we need this rooting in the first place.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_wellKnownTypeNodes was a workaround for not rooting well-known types before. All of the well-known types are not always constructed, so their VTables isn't emitted (which we need for the C++ to compile). Instead of manually rooting another approach might be manually requesting a constructed type node?

Copy link
Member

Choose a reason for hiding this comment

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

Can you put a TODO on line 56 (the empty line) to unify the list here with the list in CppWriter? This should be in a central location but I don't have time to think about where.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM - modulo a few minor comments

private void OutputTypeNode(IEETypeNode typeNode, NodeFactory factory, CppGenerationBuffer forwardDefinitions, CppGenerationBuffer typeDefinitions, CppGenerationBuffer methodTable)
{
if (_emittedTypes == null)
{
_emittedTypes = new HashSet<TypeDesc>();
}
if (!_emittedTypes.Contains(typeNode.Type))
Copy link
Member

Choose a reason for hiding this comment

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

This check is redundant - done again a few lines later. (Also, it would look better to have the early out as before so that most of the function does not need to be indented.)

@@ -1265,9 +1320,9 @@ public void OutputCode(IEnumerable<DependencyNode> nodes, MethodDesc entrypoint,
if (entrypoint != null)
{
OutputMainMethodStub(entrypoint);
Copy link
Member

Choose a reason for hiding this comment

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

Nit - unnecessary line

Out.Dispose();
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit - no newline at end of file

@@ -1021,7 +1076,7 @@ private void ImportCall(ILOpcode opcode, int token)

PushExpression(StackValueKind.NativeInt, sb.ToString());
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit - extra space

@@ -593,7 +593,7 @@ public void AttachToDependencyGraph(DependencyAnalysisFramework.DependencyAnalyz

_compilationModuleGroup.AddCompilationRoots(new RootingServiceProvider(graph, this));
}

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Unnecessary white space change.

Interface Dispatch implementation

Interface Dispatch

Interface Dispatch
@jkotas jkotas merged commit c6a2b27 into dotnet:master Sep 16, 2016
@A-And A-And deleted the InterfDispatch branch September 16, 2016 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants