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 @@ -34,6 +34,11 @@ private void EnsureMap(NodeFactory factory)
if (body is ISpecialUnboxThunkNode unboxThunk && unboxThunk.IsSpecialUnboxingThunk)
continue;

// Bodies that are visible from outside should not be folded because we don't know
// if they're address taken.
if (factory.GetSymbolAlternateName(body) != null)
continue;

var key = new MethodInternKey(body, factory);
if (methodHash.TryGetValue(key, out MethodInternKey found))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

class BodyFoldingTest
{
[UnmanagedCallersOnly(EntryPoint = "FoldableMethod1")]
static void FoldableMethod1() { }

[UnmanagedCallersOnly(EntryPoint = "FoldableMethod2")]
static void FoldableMethod2() { }

class SimpleDelegateTargets
{
public static object Return1DelStatic() => new object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
<Compile Include="StackTraceMetadata.cs" />
<Compile Include="BodyFoldingTest.cs" />
</ItemGroup>

<ItemGroup>
<IlcArg Include="--export-unmanaged-entrypoints" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set IlcExportUnmanagedEntrypoints property to true instead of using the command line option directly?

It is what the other tests do:

<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I did it this way is because we're not really testing the thing is exported, just making sure linker doesn't error out.

If I use the property and we rename or delete the property, the test silently stops testing this. If it stays command line argument, the test build will fail if we ever rename or delete it.

But I can change it if you think it's not a risk worth mitigating.

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<Compile Include="StackTraceMetadata.cs" />
<Compile Include="BodyFoldingTest.cs" />
</ItemGroup>

<ItemGroup>
<IlcArg Include="--export-unmanaged-entrypoints" />
</ItemGroup>
</Project>