Replaces the CoreRT version so that we can avoid all the intrinsic expansion that would just cause trouble for R2R.
This commit is contained in:
Michal Strehovský 2018-09-26 22:05:54 +02:00 коммит произвёл GitHub
Родитель 8522f85ebc
Коммит 2ec61bf3ca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 84 добавлений и 7 удалений

Просмотреть файл

@ -19,19 +19,19 @@ namespace ILCompiler
{
public sealed class ReadyToRunCodegenCompilationBuilder : CompilationBuilder
{
private readonly string _inputFilePath;
private readonly EcmaModule _inputModule;
// These need to provide reasonable defaults so that the user can optionally skip
// calling the Use/Configure methods and still get something reasonable back.
private KeyValuePair<string, string>[] _ryujitOptions = Array.Empty<KeyValuePair<string, string>>();
private readonly string _inputFilePath;
private readonly EcmaModule _inputModule;
private readonly DependencyAnalysis.ReadyToRun.DevirtualizationManager _r2rDevirtualizationManager;
private ILProvider _ilProvider = new CoreRTILProvider();
private ILProvider _ilProvider = new ReadyToRunILProvider();
public ReadyToRunCodegenCompilationBuilder(CompilerTypeSystemContext context, CompilationModuleGroup group, string inputFilePath)
: base(context, group, new CoreRTNameMangler(new ReadyToRunNodeMangler(), false))
{
_inputFilePath = inputFilePath;
_r2rDevirtualizationManager = new DependencyAnalysis.ReadyToRun.DevirtualizationManager(group);
_devirtualizationManager = new DependencyAnalysis.ReadyToRun.DevirtualizationManager(group);
_inputModule = context.GetModuleFromPath(_inputFilePath);
((ReadyToRunCompilerContext)context).InitializeAlgorithm(_inputModule.MetadataReader.GetTableRowCount(TableIndex.TypeDef));
@ -75,7 +75,7 @@ namespace ILCompiler
public override ICompilation ToCompilation()
{
var interopStubManager = new CompilerGeneratedInteropStubManager(_compilationGroup, _context, new InteropStateManager(_context.GeneratedAssembly));
var interopStubManager = new EmptyInteropStubManager(_compilationGroup, _context, new InteropStateManager(_context.GeneratedAssembly));
ModuleTokenResolver moduleTokenResolver = new ModuleTokenResolver(_compilationGroup);
SignatureContext signatureContext = new SignatureContext(moduleTokenResolver, _inputModule);
@ -123,7 +123,7 @@ namespace ILCompiler
_ilProvider,
_debugInformationProvider,
_logger,
_r2rDevirtualizationManager,
_devirtualizationManager,
jitConfig,
_inputFilePath);
}

Просмотреть файл

@ -0,0 +1,76 @@
// 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 Internal.TypeSystem;
using Internal.TypeSystem.Ecma;
using Internal.IL.Stubs;
using Debug = System.Diagnostics.Debug;
namespace Internal.IL
{
public sealed class ReadyToRunILProvider : ILProvider
{
/// <summary>
/// Provides method bodies for intrinsics recognized by the compiler.
/// It can return null if it's not an intrinsic recognized by the compiler,
/// but an intrinsic e.g. recognized by codegen.
/// </summary>
private MethodIL TryGetIntrinsicMethodIL(MethodDesc method)
{
return null;
}
/// <summary>
/// Provides method bodies for intrinsics recognized by the compiler that
/// are specialized per instantiation. It can return null if the intrinsic
/// is not recognized.
/// </summary>
private MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc method)
{
return null;
}
public override MethodIL GetMethodIL(MethodDesc method)
{
if (method is EcmaMethod)
{
if (method.IsIntrinsic)
{
MethodIL result = TryGetIntrinsicMethodIL(method);
if (result != null)
return result;
}
MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)method);
if (methodIL != null)
return methodIL;
return null;
}
else if (method is MethodForInstantiatedType || method is InstantiatedMethod)
{
// Intrinsics specialized per instantiation
if (method.IsIntrinsic)
{
MethodIL methodIL = TryGetPerInstantiationIntrinsicMethodIL(method);
if (methodIL != null)
return methodIL;
}
var methodDefinitionIL = GetMethodIL(method.GetTypicalMethodDefinition());
if (methodDefinitionIL == null)
return null;
return new InstantiatedMethodIL(method, methodDefinitionIL);
}
else
{
return null;
}
}
}
}

Просмотреть файл

@ -81,6 +81,7 @@
<Compile Include="Compiler\ReadyToRunNodeMangler.cs" />
<Compile Include="Compiler\ReadyToRunSingleAssemblyCompilationModuleGroup.cs" />
<Compile Include="Compiler\ReadyToRunTableManager.cs" />
<Compile Include="IL\ReadyToRunILProvider.cs" />
<Compile Include="JitInterface\CorInfoImpl.ReadyToRun.cs" />
<Compile Include="ObjectWriter\SectionBuilder.cs" />
<Compile Include="ObjectWriter\R2RPEBuilder.cs" />