From 3af8f77411689fb95816e3c5accd631186b4b635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Rylek?= Date: Thu, 19 Mar 2020 00:59:40 +0100 Subject: [PATCH] Add support for previously missing helper Check_FieldOffset (#33729) This failure crashes Crossgen2 build of several framework assemblies without the large version bubble. I discovered this during my work on composite build against shared framework where we newly introduce the notion of two separate large bubbles (app vs. framework). Thanks Tomas --- .../ReadyToRun/FieldFixupSignature.cs | 5 +++++ .../ReadyToRunSymbolNodeFactory.cs | 15 +++++++++++++++ .../JitInterface/CorInfoImpl.ReadyToRun.cs | 5 ++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/FieldFixupSignature.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/FieldFixupSignature.cs index 32cae03ba4016..88abad8269ac0 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/FieldFixupSignature.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/FieldFixupSignature.cs @@ -40,6 +40,11 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) EcmaModule targetModule = factory.SignatureContext.GetTargetModule(_fieldDesc); SignatureContext innerContext = dataBuilder.EmitFixup(factory, _fixupKind, targetModule, factory.SignatureContext); + if (_fixupKind == ReadyToRunFixupKind.Check_FieldOffset) + { + dataBuilder.EmitInt(_fieldDesc.Offset.AsInt); + } + dataBuilder.EmitFieldSignature(_fieldDesc, innerContext); } diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs index 735ada49e6191..30191aad4e973 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs @@ -80,6 +80,14 @@ private void CreateNodeCaches() ); }); + _checkFieldOffsetCache = new NodeCache(key => + { + return new PrecodeHelperImport( + _codegenNodeFactory, + new FieldFixupSignature(ReadyToRunFixupKind.Check_FieldOffset, key) + ); + }); + _interfaceDispatchCells = new NodeCache(cellKey => { return new DelayLoadHelperMethodImport( @@ -376,6 +384,13 @@ public ISymbolNode FieldOffset(FieldDesc fieldDesc) return _fieldOffsetCache.GetOrAdd(fieldDesc); } + private NodeCache _checkFieldOffsetCache; + + public ISymbolNode CheckFieldOffset(FieldDesc fieldDesc) + { + return _checkFieldOffsetCache.GetOrAdd(fieldDesc); + } + private NodeCache _fieldBaseOffsetCache; public ISymbolNode FieldBaseOffset(TypeDesc typeDesc) diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 62f8e3333a0c2..08c0b884e5c85 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -2126,7 +2126,10 @@ private void EncodeFieldBaseOffset(FieldDesc field, CORINFO_FIELD_INFO* pResult, { if (pMT.IsValueType) { - throw new NotImplementedException("https://github.com/dotnet/runtime/issues/32630: ENCODE_CHECK_FIELD_OFFSET: root field check import"); + // ENCODE_CHECK_FIELD_OFFSET + pResult->offset = 0; + pResult->fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INSTANCE_WITH_BASE; + pResult->fieldLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.CheckFieldOffset(field)); } else {