diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2017-06-15 05:05:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 05:05:12 +0300 |
commit | c81b2daed7a1afc1152ac6f7f4d8646e55682236 (patch) | |
tree | 706ce0db8a3a2c1626fc2f4baa792de17fb3d0a9 /src/ILCompiler.DependencyAnalysisFramework | |
parent | 962401ec638db2073d16d45eb8e0b1a3167452ba (diff) |
Enable IL scanner and use it to provide VTable information (#3884)
This exposes a command line switch to enable IL scanner. When IL scanner is enabled, it determines the shape of all VTables to be used during compilation, allowing codegen to generate inline vtable lookups (instead of calling an assembly helper that does the lookup).
* Factoring of Compilation and ILScanner so that they both can provide lists of compiled methods and generated EETypes
* `IMethodBodyNode` to mark the node that represents a method body in a given compilation.
* Diff the results of scanning and compilation phases to find potential issues in the scanner.
* Native layout is asking for vtables of RuntimeDetermined things. Switching it over to ask for the canon versions.
Known analysis discrepancies:
* SIMD intrinsics not getting recognized as intrinsics in the scanner. There's just too many of them. Worked around by ignoring all scan/compilation diffs in the SIMD module.
* Type system entities injected by interop/reflection not surviving across scan/compile phases. For now, ignoring them under an active issue (#3873)
Diffstat (limited to 'src/ILCompiler.DependencyAnalysisFramework')
3 files changed, 16 insertions, 3 deletions
diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs index 446b51ff1..d0aaf7a6d 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzer.cs @@ -87,8 +87,7 @@ namespace ILCompiler.DependencyAnalysisFramework { if (!_markingCompleted) { - _markingCompleted = true; - ComputeMarkedNodes(); + throw new InvalidOperationException(); } return _markedNodesFinal; @@ -242,8 +241,11 @@ namespace ILCompiler.DependencyAnalysisFramework } while (_markStack.Count != 0); } - private void ComputeMarkedNodes() + public override void ComputeMarkedNodes() { + if (_markingCompleted) + return; + do { // Run mark stack algorithm as much as possible @@ -265,6 +267,7 @@ namespace ILCompiler.DependencyAnalysisFramework _markedNodesFinal = _markedNodes.ToImmutableArray(); _markedNodes = null; + _markingCompleted = true; } private bool AddToMarkStack(DependencyNodeCore<DependencyContextType> node, string reason, DependencyNodeCore<DependencyContextType> reason1, DependencyNodeCore<DependencyContextType> reason2) diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs index 809db8713..56878094d 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyAnalyzerBase.cs @@ -40,6 +40,7 @@ namespace ILCompiler.DependencyAnalysisFramework /// <summary> /// Return the marked node list. Do not modify this list, as it will cause unexpected behavior. + /// Call <see cref="ComputeMarkedNodes"/> to compute the list first. /// </summary> public abstract ImmutableArray<DependencyNodeCore<DependencyContextType>> MarkedNodeList { @@ -47,6 +48,12 @@ namespace ILCompiler.DependencyAnalysisFramework } /// <summary> + /// Computes the list of marked nodes. This is a no-op if the marked nodes are already computed. + /// The list is available as <see cref="MarkedNodeList"/>. + /// </summary> + public abstract void ComputeMarkedNodes(); + + /// <summary> /// This event is triggered when a node is added to the graph. /// </summary> public abstract event Action<DependencyNodeCore<DependencyContextType>> NewMarkedNode; diff --git a/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs b/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs index 53a0f7690..ebf9000db 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs @@ -163,6 +163,9 @@ namespace ILCompiler.DependencyAnalysisFramework.Tests get { List<string> liveNodes = new List<string>(); + + _analyzer.ComputeMarkedNodes(); + foreach (var node in _analyzer.MarkedNodeList) { liveNodes.Add(((TestNode)node).Data); |