Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Fix assertion due to remorph #110516

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0cbf3a2
Try fixing remorph issue
hez2010 Dec 6, 2024
8e63d8d
Delete unused static field from List (#110515)
stephentoub Dec 9, 2024
f7fad34
Remove some RuntimeExport/RuntimeImport indirections (#110437)
MichalStrehovsky Dec 9, 2024
9df306f
Fix linux-armel build (#110514)
am11 Dec 9, 2024
d9f5ee4
[wasi] bump wasmtime to 27 (#110524)
pavelsavara Dec 9, 2024
4525619
[debugger] Fix a step that becomes a go (#110484)
thaystg Dec 9, 2024
df70878
fix profiling env var names in profiling.md (#109764)
loadingcn Dec 9, 2024
6ade56a
Change assertion in IPGlobalProperties_DomainName_ReturnsEmptyStringW…
antonfirsov Dec 9, 2024
1c960dd
Added a fix for the build failure when STRESS_DYNAMIC_HEAP_COUNT is d…
mrsharm Dec 9, 2024
6fdfb78
[cdac] Handle no method def token when trying to get the IL version s…
elinor-fung Dec 9, 2024
a08711c
Normalization APIs using the spans (#110465)
tarekgh Dec 9, 2024
511b2e0
Fix test under JIT stress (#110538)
AaronRobinsonMSFT Dec 10, 2024
810bad5
JIT: extract BBJ_COND to BBJ_ALWAYS profile repair as utility (#110494)
AndyAyersMS Dec 10, 2024
cf92a64
Speed up surrogate validation in HttpUtility (#110478)
MihaZupan Dec 10, 2024
69229cd
Don't wait for finalizers in 'IReferenceTrackerHost::ReleaseDisconnec…
Sergio0694 Dec 10, 2024
dede4f9
[cdac] Fix calculation of `MethodDesc` optional slot addresses (#110491)
elinor-fung Dec 10, 2024
c3e071c
[dac] Make `GetObjectStringData` return the needed buffer element cou…
elinor-fung Dec 10, 2024
7b1214b
Remove ld_classic in 16+ (#110542)
agocke Dec 10, 2024
43c5fac
Fix AV error in DAC on Linux/MacOS - issue #109877 (#110557)
mikem8361 Dec 10, 2024
40014b6
[browser] fix code gen overflow (#110539)
pavelsavara Dec 10, 2024
5d539a2
Disable `HybridGlobalization` tests for WASM on CI (#110526)
ilonatommy Dec 10, 2024
0bb7432
JIT: Include more edges in `BlockDominancePreds` (#110531)
jakobbotsch Dec 10, 2024
e0f70cc
[mono][interp] Remove no_inlining functionality for dead bblocks (#11…
BrzVlad Dec 10, 2024
bbe9a9d
Enable more ILLinker skipped tests on native AOT (#110353)
MichalStrehovsky Dec 10, 2024
5750272
JIT: Avoid comparing regnums in `GenTreeHWIntrinsic::Equals` (#110535)
jakobbotsch Dec 10, 2024
2071313
fix FastOpen compilation (#110561)
wfurt Dec 10, 2024
f430ffa
Remove duplicate IsAscii check in string.IsNormalized (#110576)
MihaZupan Dec 10, 2024
c7fc667
Remove Helper Method Frames (HMF) from Reflection (#110481)
AaronRobinsonMSFT Dec 10, 2024
df0eaa2
Speed up surrogate validation in string.Normalize (#110574)
MihaZupan Dec 10, 2024
836b868
Use holding thread id in AwareLock to avoid orphaned lock crash (#107…
eduardo-vp Dec 10, 2024
6d18e0d
Cleanup some dead code (#110579)
huoyaoyuan Dec 11, 2024
2579b1e
Revert "[browser] fix code gen overflow (#110539)" (#110599)
jkotas Dec 11, 2024
8708c3d
Share threadpool configuration (#110469)
MichalStrehovsky Dec 11, 2024
d564cb3
Ensure that we don't try and optimize masks for promoted fields (#110…
tannergooding Dec 11, 2024
22001f7
[cDAC] SOSDacImpl::GetMethodDescData DynamicMethodObject (#110545)
max-charlamb Dec 11, 2024
ff171c4
Fix comments in AggregateException.GetBaseException() (#107743)
epsitec Dec 11, 2024
9652163
[browser] Remove WASM `HybridGlobalization` from library tests, WBT a…
ilonatommy Dec 11, 2024
d97abb1
fix wrong arguments order in CrlCacheExpired call (#110457)
Alex4414 Dec 11, 2024
fe9a96a
Fix TensorExtensions.StdDev (#110392)
lilinus Dec 11, 2024
0181b15
Use FLS detach as thread termination notification on windows. (#110589)
VSadov Dec 11, 2024
2692fc5
[Profiler] Avoid Recursive ThreadStoreLock in Profiling Thread Enumer…
mdh1418 Dec 11, 2024
097ed73
Remove HttpMetricsEnrichmentContext caching (#110580)
MihaZupan Dec 11, 2024
ab2fa84
[NRBF] Reduce the most time-consuming test case to avoid timeouts for…
adamsitnik Dec 12, 2024
ae492ef
All `WasmBuildTests` use static project from assets or `dotnet new`, …
ilonatommy Dec 12, 2024
8c80358
[Mono]: Update Mono diagnostic docs. (#110621)
lateralusX Dec 12, 2024
124986b
Update dependencies from dotnet/roslyn (#110105)
am11 Dec 12, 2024
b0f79a4
[Mono]: Fix Mono profiler EventPipe provider instrumentation feature.…
lateralusX Dec 12, 2024
add0aa3
SPMI: Avoid duplicate example diffs in diffs summary (#110619)
jakobbotsch Dec 12, 2024
0c0281e
[browser] fix code gen overflow - reapply (#110606)
pavelsavara Dec 12, 2024
432af20
JIT: Remove `VisitLoopBlocksLexical` utility (#110490)
amanasifkhalid Dec 12, 2024
80b8de7
Fix crash when pTargetMD is null (#110650)
thaystg Dec 12, 2024
57e0e9c
[main] Update dependencies from dotnet/roslyn (#110084)
dotnet-maestro[bot] Dec 12, 2024
c0e3f59
JIT: Fix reporting of tier name metadata (#110610)
jakobbotsch Dec 12, 2024
b3d059f
More WriteGather fixes (#109826)
adamsitnik Dec 12, 2024
c39d942
[cdac] Always re-read global pointers in GetUsefulGlobals (#110633)
elinor-fung Dec 12, 2024
3955bc8
Correct arm64 SignExtension (#110635)
mikelle-rogers Dec 12, 2024
46946fe
Delete .GuardCF library build (#110671)
MichalStrehovsky Dec 13, 2024
32acefa
[browser] NativeAOT-LLVM support in browser-bench (#110611)
maraf Dec 13, 2024
cb8d141
JIT: Remove always-true `fgCanRelocateEHRegions` (#110612)
jakobbotsch Dec 13, 2024
a4ca48f
[wasm] Add bench output log, to the file and to the console (#110669)
radekdoulik Dec 13, 2024
34cf5bc
JIT: Add an "init BB" invariant (#110404)
jakobbotsch Dec 13, 2024
d7cc790
Remove FabricBot from area-owners.md (#110525)
akoeplinger Dec 13, 2024
15e01d4
JIT: Spill newarr into temp (#110518)
hez2010 Dec 13, 2024
07e85b6
[cdac] Fix ISOSDacInterface13.TraverseLoaderHeap parameter type (#110…
elinor-fung Dec 13, 2024
05d687e
[cdac] Handle non-IL method descs in `RuntimeTypeSystem_1.GetMethodCl…
elinor-fung Dec 13, 2024
97f8570
[cDAC] Implement GCCover portion of SOSDacImpl::GetMethodDescData (#1…
max-charlamb Dec 13, 2024
f1b1f3d
Remove unused Precode::IsCorrectMethodDesc (#110703)
elinor-fung Dec 13, 2024
1502947
JIT: capture class types when spilling a GDV arg (#110675)
AndyAyersMS Dec 14, 2024
fd3c397
[cdac] Clear cached data as part of IXCLRDataProcess::Flush (#110700)
elinor-fung Dec 14, 2024
f52248f
Improve codegen for Vector512.ExtractMostSignificatBits (#110662)
tannergooding Dec 14, 2024
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
Prev Previous commit
Next Next commit
[cdac] Fix calculation of MethodDesc optional slot addresses (#110491)
The cDAC was assuming that the additional data after a MethodDesc were each just pointers. That is only true for the non-vtable slot and native code slot, not method impl. This change includes the size of those additional slots in the data descriptor and uses them when computing the addresses those optional slots.

As part of this, I pulled out shared helpers around dealing with optional slots for use by `MethodValidation` and `RuntimeTypeSystem_1`.
  • Loading branch information
elinor-fung authored and hez2010 committed Dec 14, 2024
commit dede4f9256526e4bf7733d208f9ad25e7c656bce
12 changes: 12 additions & 0 deletions src/coreclr/debug/runtimeinfo/datadescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,18 @@ CDAC_TYPE_FIELD(MethodDescChunk, /*uint8*/, Count, cdac_data<MethodDescChunk>::C
CDAC_TYPE_FIELD(MethodDescChunk, /*uint16*/, FlagsAndTokenRange, cdac_data<MethodDescChunk>::FlagsAndTokenRange)
CDAC_TYPE_END(MethodDescChunk)

CDAC_TYPE_BEGIN(NonVtableSlot)
CDAC_TYPE_SIZE(sizeof(MethodDesc::NonVtableSlot))
CDAC_TYPE_END(NonVtableSlot)

CDAC_TYPE_BEGIN(MethodImpl)
CDAC_TYPE_SIZE(sizeof(MethodImpl))
CDAC_TYPE_END(MethodImpl)

CDAC_TYPE_BEGIN(NativeCodeSlot)
CDAC_TYPE_SIZE(sizeof(MethodDesc::NativeCodeSlot))
CDAC_TYPE_END(NativeCodeSlot)

CDAC_TYPE_BEGIN(InstantiatedMethodDesc)
CDAC_TYPE_SIZE(sizeof(InstantiatedMethodDesc))
CDAC_TYPE_FIELD(InstantiatedMethodDesc, /*pointer*/, PerInstInfo, cdac_data<InstantiatedMethodDesc>::PerInstInfo)
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,10 +1853,8 @@ class MethodDesc
//
// Optional MethodDesc slots appear after the end of base MethodDesc in this order:
//

// class MethodImpl; // Present if HasMethodImplSlot() is true

typedef PCODE NonVtableSlot; // Present if HasNonVtableSlot() is true
// class MethodImpl; // Present if HasMethodImplSlot() is true
typedef PCODE NativeCodeSlot; // Present if HasNativeCodeSlot() is true

// Stub Dispatch code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ public enum DataType
HashMap,
Bucket,
UnwindInfo,
NonVtableSlot,
MethodImpl,
NativeCodeSlot,
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,45 +143,14 @@ private static uint ComputeToken(Target target, Data.MethodDesc desc, Data.Metho
public TargetPointer CodeData => _desc.CodeData;
public bool IsIL => Classification == MethodClassification.IL || Classification == MethodClassification.Instantiated;

public bool HasNativeCodeSlot => HasFlags(MethodDescFlags_1.MethodDescFlags.HasNativeCodeSlot);
internal bool HasNonVtableSlot => HasFlags(MethodDescFlags_1.MethodDescFlags.HasNonVtableSlot);
internal bool HasMethodImpl => HasFlags(MethodDescFlags_1.MethodDescFlags.HasMethodImpl);
internal bool HasNonVtableSlot => MethodDescOptionalSlots.HasNonVtableSlot(_desc.Flags);
internal bool HasNativeCodeSlot => MethodDescOptionalSlots.HasNativeCodeSlot(_desc.Flags);

internal bool HasStableEntryPoint => HasFlags(MethodDescFlags_1.MethodDescFlags3.HasStableEntryPoint);
internal bool HasPrecode => HasFlags(MethodDescFlags_1.MethodDescFlags3.HasPrecode);

#region Additional Pointers
private int AdditionalPointersHelper(MethodDescFlags_1.MethodDescFlags extraFlags)
=> int.PopCount(_desc.Flags & (ushort)extraFlags);

// non-vtable slot, native code slot and MethodImpl slots are stored after the MethodDesc itself, packed tightly
// in the order: [non-vtable; methhod impl; native code].
internal int NonVtableSlotIndex => HasNonVtableSlot ? 0 : throw new InvalidOperationException("no non-vtable slot");
internal int MethodImplIndex
{
get
{
if (!HasMethodImpl)
{
throw new InvalidOperationException("no method impl slot");
}
return AdditionalPointersHelper(MethodDescFlags_1.MethodDescFlags.HasNonVtableSlot);
}
}
internal int NativeCodeSlotIndex
{
get
{
if (!HasNativeCodeSlot)
{
throw new InvalidOperationException("no native code slot");
}
return AdditionalPointersHelper(MethodDescFlags_1.MethodDescFlags.HasNonVtableSlot | MethodDescFlags_1.MethodDescFlags.HasMethodImpl);
}
}

internal int AdditionalPointersCount => AdditionalPointersHelper(MethodDescFlags_1.MethodDescFlags.MethodDescAdditionalPointersMask);
#endregion Additional Pointers
internal TargetPointer GetAddressOfNonVtableSlot() => MethodDescOptionalSlots.GetAddressOfNonVtableSlot(Address, Classification, _desc.Flags, _target);
internal TargetPointer GetAddressOfNativeCodeSlot() => MethodDescOptionalSlots.GetAddressOfNativeCodeSlot(Address, Classification, _desc.Flags, _target);

internal bool IsLoaderModuleAttachedToChunk => HasFlags(MethodDescChunkFlags.LoaderModuleAttachedToChunk);

Expand Down Expand Up @@ -994,48 +963,10 @@ bool IRuntimeTypeSystem.HasNativeCodeSlot(MethodDescHandle methodDesc)
return md.HasNativeCodeSlot;
}

internal static DataType GetMethodClassificationDataType(MethodClassification classification)
=> classification switch
{
MethodClassification.IL => DataType.MethodDesc,
MethodClassification.FCall => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.PInvoke => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.EEImpl => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Array => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Instantiated => DataType.InstantiatedMethodDesc,
MethodClassification.ComInterop => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Dynamic => DataType.DynamicMethodDesc,
_ => throw new InvalidOperationException($"Unexpected method classification 0x{classification:x2} for MethodDesc")
};

private uint MethodDescAdditionalPointersOffset(MethodDesc md)
{
// See MethodDesc::GetBaseSize and s_ClassificationSizeTable
// sizeof(MethodDesc), mcIL
// sizeof(FCallMethodDesc), mcFCall
// sizeof(NDirectMethodDesc), mcPInvoke
// sizeof(EEImplMethodDesc), mcEEImpl
// sizeof(ArrayMethodDesc), mcArray
// sizeof(InstantiatedMethodDesc), mcInstantiated
// sizeof(CLRToCOMCallMethodDesc), mcComInterOp
// sizeof(DynamicMethodDesc) mcDynamic
MethodClassification cls = md.Classification;
DataType type = GetMethodClassificationDataType(cls);
return _target.GetTypeInfo(type).Size ?? throw new InvalidOperationException($"size of MethodDesc not known");
}

TargetPointer IRuntimeTypeSystem.GetAddressOfNativeCodeSlot(MethodDescHandle methodDesc)
{
MethodDesc md = _methodDescs[methodDesc.Address];
uint offset = MethodDescAdditionalPointersOffset(md);
offset += (uint)(_target.PointerSize * md.NativeCodeSlotIndex);
return methodDesc.Address + offset;
}
private TargetPointer GetAddressOfNonVtableSlot(TargetPointer methodDescPointer, MethodDesc md)
{
uint offset = MethodDescAdditionalPointersOffset(md);
offset += (uint)(_target.PointerSize * md.NonVtableSlotIndex);
return methodDescPointer.Value + offset;
return md.GetAddressOfNativeCodeSlot();
}

TargetCodePointer IRuntimeTypeSystem.GetNativeCode(MethodDescHandle methodDescHandle)
Expand All @@ -1047,30 +978,30 @@ TargetCodePointer IRuntimeTypeSystem.GetNativeCode(MethodDescHandle methodDescHa
// When profiler is enabled, profiler may ask to rejit a code even though we
// we have ngen code for this MethodDesc. (See MethodDesc::DoPrestub).
// This means that *ppCode is not stable. It can turn from non-zero to zero.
TargetPointer ppCode = ((IRuntimeTypeSystem)this).GetAddressOfNativeCodeSlot(methodDescHandle);
TargetPointer ppCode = md.GetAddressOfNativeCodeSlot();
TargetCodePointer pCode = _target.ReadCodePointer(ppCode);
return CodePointerUtils.CodePointerFromAddress(pCode.AsTargetPointer, _target);
}

if (!md.HasStableEntryPoint || md.HasPrecode)
return TargetCodePointer.Null;

return GetStableEntryPoint(methodDescHandle.Address, md);
return GetStableEntryPoint(md);
}

private TargetCodePointer GetStableEntryPoint(TargetPointer methodDescAddress, MethodDesc md)
private TargetCodePointer GetStableEntryPoint(MethodDesc md)
{
// TODO(cdac): _ASSERTE(HasStableEntryPoint());
// TODO(cdac): _ASSERTE(!IsVersionableWithVtableSlotBackpatch());
Debug.Assert(md.HasStableEntryPoint);

return GetMethodEntryPointIfExists(methodDescAddress, md);
return GetMethodEntryPointIfExists(md);
}

private TargetCodePointer GetMethodEntryPointIfExists(TargetPointer methodDescAddress, MethodDesc md)
private TargetCodePointer GetMethodEntryPointIfExists(MethodDesc md)
{
if (md.HasNonVtableSlot)
{
TargetPointer pSlot = GetAddressOfNonVtableSlot(methodDescAddress, md);
TargetPointer pSlot = md.GetAddressOfNonVtableSlot();
return _target.ReadCodePointer(pSlot);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ internal static class MethodDescFlags_1
internal enum MethodDescFlags : ushort
{
ClassificationMask = 0x7,
#region Additional pointers
// The below flags each imply that there's an extra pointer-sized piece of data after the MethodDesc in the MethodDescChunk
#region Optional slots
// The below flags each imply that there's an extra pointer-size-aligned piece of data after the MethodDesc in the MethodDescChunk
HasNonVtableSlot = 0x0008,
HasMethodImpl = 0x0010,
HasNativeCodeSlot = 0x0020,
// Mask for the above flags
MethodDescAdditionalPointersMask = 0x0038,
#endregion Additional pointers
#endregion Optional slots
}

[Flags]
Expand All @@ -35,5 +33,4 @@ internal enum MethodDescEntryPointFlags : byte
{
TemporaryEntryPointAssigned = 0x04,
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;

namespace Microsoft.Diagnostics.DataContractReader.RuntimeTypeSystemHelpers;

// Non-vtable slot, native code slot, and MethodImpl slots are stored after the MethodDesc itself, packed tightly
// in the order: [non-vtable; method impl; native code].
internal static class MethodDescOptionalSlots
{
internal static bool HasNonVtableSlot(ushort flags)
=> (flags & (ushort)MethodDescFlags_1.MethodDescFlags.HasNonVtableSlot) != 0;

internal static bool HasMethodImpl(ushort flags)
=> (flags & (ushort)MethodDescFlags_1.MethodDescFlags.HasMethodImpl) != 0;

internal static bool HasNativeCodeSlot(ushort flags)
=> (flags & (ushort)MethodDescFlags_1.MethodDescFlags.HasNativeCodeSlot) != 0;

internal static TargetPointer GetAddressOfNonVtableSlot(TargetPointer methodDesc, MethodClassification classification, ushort flags, Target target)
{
uint offset = StartOffset(classification, target);
offset += NonVtableSlotOffset(flags);
return methodDesc + offset;
}

internal static TargetPointer GetAddressOfNativeCodeSlot(TargetPointer methodDesc, MethodClassification classification, ushort flags, Target target)
{
uint offset = StartOffset(classification, target);
offset += NativeCodeSlotOffset(flags, target);
return methodDesc + offset;
}

// Offset from the MethodDesc address to the start of its optional slots
private static uint StartOffset(MethodClassification classification, Target target)
{
// See MethodDesc::GetBaseSize and s_ClassificationSizeTable
// sizeof(MethodDesc), mcIL
// sizeof(FCallMethodDesc), mcFCall
// sizeof(NDirectMethodDesc), mcPInvoke
// sizeof(EEImplMethodDesc), mcEEImpl
// sizeof(ArrayMethodDesc), mcArray
// sizeof(InstantiatedMethodDesc), mcInstantiated
// sizeof(CLRToCOMCallMethodDesc), mcComInterOp
// sizeof(DynamicMethodDesc) mcDynamic
DataType type = classification switch
{
MethodClassification.IL => DataType.MethodDesc,
MethodClassification.FCall => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.PInvoke => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.EEImpl => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Array => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Instantiated => DataType.InstantiatedMethodDesc,
MethodClassification.ComInterop => throw new NotImplementedException(), //TODO[cdac]:
MethodClassification.Dynamic => DataType.DynamicMethodDesc,
_ => throw new InvalidOperationException($"Unexpected method classification 0x{classification:x2} for MethodDesc")
};
return target.GetTypeInfo(type).Size ?? throw new InvalidOperationException($"size of MethodDesc not known");
}

// Offsets are from the start of optional slots data (so right after the MethodDesc), obtained via StartOffset
private static uint NonVtableSlotOffset(ushort flags)
{
if (!HasNonVtableSlot(flags))
throw new InvalidOperationException("no non-vtable slot");

return 0u;
}

private static uint MethodImplOffset(ushort flags, Target target)
{
if (!HasMethodImpl(flags))
throw new InvalidOperationException("no method impl slot");

return HasNonVtableSlot(flags) ? (uint)target.PointerSize : 0;
}

private static uint NativeCodeSlotOffset(ushort flags, Target target)
{
if (!HasNativeCodeSlot(flags))
throw new InvalidOperationException("no native code slot");

uint offset = 0;
if (HasNonVtableSlot(flags))
offset += target.GetTypeInfo(DataType.NonVtableSlot).Size!.Value;

if (HasMethodImpl(flags))
offset += target.GetTypeInfo(DataType.MethodImpl).Size!.Value;

return offset;
}
}
Loading