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
17 changes: 15 additions & 2 deletions src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ public override MethodIL GetMethodIL(MethodDesc method)
if (wrappedIL == null)
return null;

return new AsyncMethodIL(asyncVariantImpl, wrappedIL);
return wrappedIL is EcmaMethodIL ecmaIL
? new EcmaAsyncMethodIL(asyncVariantImpl, ecmaIL)
: new AsyncMethodIL(asyncVariantImpl, wrappedIL);
}
else
{
Expand All @@ -378,7 +380,7 @@ public override MethodIL GetMethodIL(MethodDesc method)
}
}

private sealed class AsyncMethodIL : MethodIL
private class AsyncMethodIL : MethodIL
{
private readonly AsyncMethodVariant _variant;
private readonly MethodIL _wrappedIL;
Expand All @@ -398,5 +400,16 @@ public AsyncMethodIL(AsyncMethodVariant variant, MethodIL wrappedIL)
public override bool IsInitLocals => _wrappedIL.IsInitLocals;
public override int MaxStack => _wrappedIL.MaxStack;
}

private sealed class EcmaAsyncMethodIL : AsyncMethodIL, IEcmaMethodIL
{
public EcmaAsyncMethodIL(AsyncMethodVariant variant, EcmaMethodIL wrappedIL)
: base(variant, wrappedIL)
{
Module = wrappedIL.Module;
}

public IEcmaModule Module { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method)
debugInfo = new SubstitutedDebugInformation(debugInfo, sequencePoints.ToArray());
}

// We only optimize EcmaMethods because there we can find out the highest string token RID
// We only optimize IL backed by an ECMA module because we can find the highest string token RID
// in use.
ArrayBuilder<string> newStrings = default;
if (hasGetResourceStringCall && method.GetMethodILDefinition() is EcmaMethodIL ecmaMethodIL)
if (hasGetResourceStringCall && method.GetMethodILDefinition() is IEcmaMethodIL ecmaMethodIL)
{
// We're going to inject new string tokens. Start where the last token of the module left off.
// We don't need this token to be globally unique because all token resolution happens in the context
Expand Down Expand Up @@ -1182,7 +1182,7 @@ public override object GetObject(int token, NotFoundBehavior notFoundBehavior)
{
// If this is a string token, it could be one of the new string tokens we injected.
if ((token >>> 24) == TokenTypeString
&& _wrappedMethodIL.GetMethodILDefinition() is EcmaMethodIL ecmaMethodIL)
&& _wrappedMethodIL.GetMethodILDefinition() is IEcmaMethodIL ecmaMethodIL)
{
int rid = token & 0xFFFFFF;
int maxRealTokenRid = ecmaMethodIL.Module.MetadataReader.GetHeapSize(HeapIndex.UserString);
Expand Down
Loading