Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ public MultiFileCompilationModuleGroup(TypeSystemContext context, IEnumerable<Mo

public sealed override bool ContainsType(TypeDesc type)
{
if (type is EcmaType ecmaType)
{
return IsModuleInCompilationGroup(ecmaType.EcmaModule);
}
if (type is InstantiatedType instantiatedType)
EcmaType ecmaType = type as EcmaType;

if (ecmaType == null)
return true;

if (!IsModuleInCompilationGroup(ecmaType.EcmaModule))
{
return ContainsType(instantiatedType.GetTypeDefinition());
return false;
}

return true;
}

Expand Down Expand Up @@ -100,7 +102,7 @@ public override bool CanHaveReferenceThroughImportTable
{
return false;
}
}
}
}

/// <summary>
Expand All @@ -125,7 +127,7 @@ public override bool ShouldPromoteToFullType(TypeDesc type)

public override bool PresenceOfEETypeImpliesAllMethodsOnType(TypeDesc type)
{
return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) &&
return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) &&
type.ConvertToCanonForm(CanonicalFormKind.Specific).IsCanonicalSubtype(CanonicalFormKind.Any);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics;

using ILCompiler.DependencyAnalysis;
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;

namespace ILCompiler
{
public class ReadyToRunSingleAssemblyCompilationModuleGroup : CompilationModuleGroup
{
private HashSet<ModuleDesc> _compilationModuleSet;

public ReadyToRunSingleAssemblyCompilationModuleGroup(TypeSystemContext context, IEnumerable<ModuleDesc> compilationModuleSet)
{
_compilationModuleSet = new HashSet<ModuleDesc>(compilationModuleSet);

// The fake assembly that holds compiler generated types is part of the compilation.
_compilationModuleSet.Add(context.GeneratedAssembly);
}

public sealed override bool ContainsType(TypeDesc type)
{
if (type is EcmaType ecmaType)
{
return IsModuleInCompilationGroup(ecmaType.EcmaModule);
}
if (type is InstantiatedType instantiatedType)
{
return ContainsType(instantiatedType.GetTypeDefinition());
}
return true;
}

public sealed override bool ContainsTypeDictionary(TypeDesc type)
{
return ContainsType(type);
}

public sealed override bool ContainsMethodBody(MethodDesc method, bool unboxingStub)
{
if (method.HasInstantiation)
return true;

return ContainsType(method.OwningType);
}

public sealed override bool ContainsMethodDictionary(MethodDesc method)
{
Debug.Assert(method.GetCanonMethodTarget(CanonicalFormKind.Specific) != method);
return ContainsMethodBody(method, false);
}

public sealed override ExportForm GetExportTypeForm(TypeDesc type)
{
return ExportForm.None;
}

public sealed override ExportForm GetExportTypeFormDictionary(TypeDesc type)
{
return ExportForm.None;
}

public sealed override ExportForm GetExportMethodForm(MethodDesc method, bool unboxingStub)
{
return ExportForm.None;
}

public override ExportForm GetExportMethodDictionaryForm(MethodDesc method)
{
return ExportForm.None;
}

private bool IsModuleInCompilationGroup(EcmaModule module)
{
return _compilationModuleSet.Contains(module);
}

public sealed override bool IsSingleFileCompilation
{
get
{
return false;
}
}

public sealed override bool ShouldReferenceThroughImportTable(TypeDesc type)
{
return false;
}

public override bool CanHaveReferenceThroughImportTable
{
get
{
return false;
}
}

public override bool ShouldProduceFullVTable(TypeDesc type)
{
return ConstructedEETypeNode.CreationAllowed(type);
}

public override bool ShouldPromoteToFullType(TypeDesc type)
{
return ShouldProduceFullVTable(type);
}

public override bool PresenceOfEETypeImpliesAllMethodsOnType(TypeDesc type)
{
return (type.HasInstantiation || type.IsArray) && ShouldProduceFullVTable(type) &&
type.ConvertToCanonForm(CanonicalFormKind.Specific).IsCanonicalSubtype(CanonicalFormKind.Any);
}
}
}
1 change: 1 addition & 0 deletions src/ILCompiler.ReadyToRun/src/ILCompiler.ReadyToRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<Compile Include="Compiler\DependencyAnalysis\ReadyToRun\TypesTableNode.cs" />
<Compile Include="Compiler\ReadyToRunCodegenCompilation.cs" />
<Compile Include="Compiler\ReadyToRunCodegenCompilationBuilder.cs" />
<Compile Include="Compiler\ReadyToRunSingleAssemblyCompilationModuleGroup.cs" />
<Compile Include="Compiler\ReadyToRunNodeMangler.cs" />
<Compile Include="JitInterface\CorInfoImpl.ReadyToRun.cs" />
<Compile Include="ObjectWriter\SectionBuilder.cs" />
Expand Down
11 changes: 9 additions & 2 deletions src/ILCompiler/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private int Run(string[] args)
}
}

if (_multiFile)
if (_multiFile || _isReadyToRunCodeGen)
{
List<EcmaModule> inputModules = new List<EcmaModule>();

Expand All @@ -376,7 +376,14 @@ private int Run(string[] args)
inputModules.Add(module);
}

compilationGroup = new MultiFileSharedCompilationModuleGroup(typeSystemContext, inputModules);
if (_isReadyToRunCodeGen)
{
compilationGroup = new ReadyToRunSingleAssemblyCompilationModuleGroup(typeSystemContext, inputModules);
}
else
{
compilationGroup = new MultiFileSharedCompilationModuleGroup(typeSystemContext, inputModules);
}
}
else
{
Expand Down