This repository was archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 503
Add ReadyToRunSingleAssemblyCompilationModuleGroup based on MultiFileCompilationModuleGroup #6135
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
src/ILCompiler.ReadyToRun/src/Compiler/ReadyToRunSingleAssemblyCompilationModuleGroup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since multi-file is independent from ready-to-run, please pull the ready-to-run piece up out of the
if (_multifile)block.