Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2017-06-12 21:47:56 +0300
committerGitHub <noreply@github.com>2017-06-12 21:47:56 +0300
commit717b4dbf806252d1847b5fdfed86859af15e2894 (patch)
treea8f3604d4680302818862e954d8c396918067e78 /src/ILCompiler.CppCodeGen
parent566051d731c0191eed1c674fecd5fbbe9823738d (diff)
Allow an external optimizer to specify VTable layout (#3854)
Adds an extensibility point to the `CompilationBuilder` that allows specifying how vtables should be built. We currently have two strategies: eagerly built VTables (where we just put all the virtual methods that the type specifies in the metadata into the VTable), and lazily built vtables (where we track virtual method usage during the compilation and only generate vtable slots for methods that were actually used). The advantage of the former is that we know the slot assignment very early on and can inline it into the codegen. The advantage of the latter is natural reduction of the amount of code we compile. I'm adding an option to specify optional optimization data that can be used instead of the lazily built strategy and making it possible for the IL scanner to generate this data. This way we can have an option where we both have the natural reduction in the amount of generated code, and also the inlining of slot numbers in codegen (that part depends on #3773 to light up.
Diffstat (limited to 'src/ILCompiler.CppCodeGen')
-rw-r--r--src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs2
-rw-r--r--src/ILCompiler.CppCodeGen/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs5
-rw-r--r--src/ILCompiler.CppCodeGen/src/CppCodeGen/CppWriter.cs2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs b/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs
index 7ea68e212..3f56e757c 100644
--- a/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs
+++ b/src/ILCompiler.CppCodeGen/src/Compiler/CppCodegenCompilationBuilder.cs
@@ -29,7 +29,7 @@ namespace ILCompiler
public override ICompilation ToCompilation()
{
- CppCodegenNodeFactory factory = new CppCodegenNodeFactory(_context, _compilationGroup, _metadataManager, _nameMangler);
+ CppCodegenNodeFactory factory = new CppCodegenNodeFactory(_context, _compilationGroup, _metadataManager, _nameMangler, _vtableSliceProvider);
DependencyAnalyzerBase<NodeFactory> graph = CreateDependencyGraph(factory);
return new CppCodegenCompilation(graph, factory, _compilationRoots, _logger, _config);
diff --git a/src/ILCompiler.CppCodeGen/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs b/src/ILCompiler.CppCodeGen/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs
index 3eaf2ae2a..2a0e66acb 100644
--- a/src/ILCompiler.CppCodeGen/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs
+++ b/src/ILCompiler.CppCodeGen/src/Compiler/DependencyAnalysis/CppCodegenNodeFactory.cs
@@ -10,8 +10,9 @@ namespace ILCompiler.DependencyAnalysis
{
public sealed class CppCodegenNodeFactory : NodeFactory
{
- public CppCodegenNodeFactory(CompilerTypeSystemContext context, CompilationModuleGroup compilationModuleGroup, MetadataManager metadataManager, NameMangler nameMangler)
- : base(context, compilationModuleGroup, metadataManager, nameMangler, new LazyGenericsDisabledPolicy())
+ public CppCodegenNodeFactory(CompilerTypeSystemContext context, CompilationModuleGroup compilationModuleGroup, MetadataManager metadataManager,
+ NameMangler nameMangler, VTableSliceProvider vtableSliceProvider)
+ : base(context, compilationModuleGroup, metadataManager, nameMangler, new LazyGenericsDisabledPolicy(), vtableSliceProvider)
{
}
diff --git a/src/ILCompiler.CppCodeGen/src/CppCodeGen/CppWriter.cs b/src/ILCompiler.CppCodeGen/src/CppCodeGen/CppWriter.cs
index 53e9e892d..5e5069a63 100644
--- a/src/ILCompiler.CppCodeGen/src/CppCodeGen/CppWriter.cs
+++ b/src/ILCompiler.CppCodeGen/src/CppCodeGen/CppWriter.cs
@@ -1109,7 +1109,7 @@ namespace ILCompiler.CppCodeGen
{
OutputTypeFields(typeDefinitions, nodeType);
- IReadOnlyList<MethodDesc> virtualSlots = _compilation.NodeFactory.VTable(nodeType).Slots;
+ IReadOnlyList<MethodDesc> virtualSlots = _compilation.NodeFactory.VTable(nodeType.GetClosestDefType()).Slots;
int baseSlots = 0;
var baseType = nodeType.BaseType;