Skip to content

exclude UTF8 string marshallers from cg2 #55624

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

Merged
merged 3 commits into from
Jul 15, 2021
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
14 changes: 14 additions & 0 deletions src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,12 @@ internal override bool CleanupRequired

internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter)
{
#if READYTORUN
throw new NotSupportedException();
#else
codeStream.Emit(ILOpcode.call, emitter.NewToken(
Context.GetHelperEntryPoint("InteropHelpers", "CoTaskMemFree")));
#endif
}

protected override void TransformManagedToNative(ILCodeStream codeStream)
Expand Down Expand Up @@ -1536,12 +1540,16 @@ protected override void TransformManagedToNative(ILCodeStream codeStream)
}
else
{
#if READYTORUN
throw new NotSupportedException();
#else
var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeBuffer");
LoadManagedValue(codeStream);

codeStream.Emit(ILOpcode.call, emitter.NewToken(helper));

StoreNativeValue(codeStream);
#endif
}
}

Expand Down Expand Up @@ -1597,8 +1605,12 @@ internal override bool CleanupRequired

internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter)
{
#if READYTORUN
throw new NotSupportedException();
#else
codeStream.Emit(ILOpcode.call, emitter.NewToken(
Context.GetHelperEntryPoint("InteropHelpers", "CoTaskMemFree")));
#endif
}

protected override void TransformManagedToNative(ILCodeStream codeStream)
Expand Down Expand Up @@ -1752,6 +1764,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream)
}
}

#if !READYTORUN
class UTF8StringMarshaller : Marshaller
{
internal override bool CleanupRequired
Expand Down Expand Up @@ -1806,6 +1819,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream)
codeStream.EmitLabel(lNullCheck);
}
}
#endif

class SafeHandleMarshaller : Marshaller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ protected static Marshaller CreateMarshaller(MarshallerKind kind)
return new BooleanMarshaller();
case MarshallerKind.AnsiString:
return new AnsiStringMarshaller();
case MarshallerKind.UTF8String:
return new UTF8StringMarshaller();
case MarshallerKind.SafeHandle:
return new SafeHandleMarshaller();
case MarshallerKind.UnicodeString:
Expand Down