dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.22k stars 4.72k forks source link

ILDAsm and ILAsm don't handle the `no.` prefix #72695

Open MichalPetryka opened 2 years ago

MichalPetryka commented 2 years ago

Description

ILAsm currently errors out when encountering IL containing the no. prefix, while ILDAsm disassemblers it into output that isn't valid.

Reproduction Steps

For ILDAsm: Create an assembly containing no. with some value (possible with Cecil) and try to disassemble it.

For ILAsm: Try to assemble:

ldarg.0
ldc.i4.0
no. 0x06
ldelem.u1
ret

Expected behavior

Both are correctly handled.

Actual behavior

ILDasm gives this for no. with 0x06:

ldarg.0
ldc.i4.0
unused
ldloc.0
ldelem.u1
ret

ILAsm errors out with error : syntax error at token 'no' in: IL_0002: no. 0x02.

Regression?

VS ILDasm seems to have the same behaviour.

Known Workarounds

Using Cecil to create the instruction.

Configuration

.Net 7-preview 6 ILDasm & ILAsm

Other information

Fixing this is required for creation of tests for eventual runtime support for the instruction which is tracked by #10112.

ghost commented 2 years ago

Tagging subscribers to this area: @JulieLeeMSFT See info in area-owners.md if you want to be subscribed.

Issue Details
### Description ILAsm currently errors out when encountering IL containing the `no.` prefix, while ILDAsm disassemblers it into output that isn't valid. ### Reproduction Steps For ILDAsm: Create an assembly containing `no.` with some value (possible with Cecil) and try to disassemble it. For ILAsm: Try to assemble: ```cil ldarg.0 ldc.i4.0 no. 0x06 ldelem.u1 ret ``` ### Expected behavior Both are correctly handled. ### Actual behavior ILDasm gives for `no.` with 0x06: ```cil ldarg.0 ldc.i4.0 unused ldloc.0 delem.u1 ret ``` ILAsm errors out with `error : syntax error at token 'no' in: IL_0002: no. 0x02`. ### Regression? VS ILDasm seems to have the same behaviour. ### Known Workarounds Using Cecil to create the instruction. ### Configuration .Net 7-preview 6 ILDasm & ILAsm ### Other information Fixing this is required for creation of tests for eventual runtime support for the instructions with is tracked by #10112.
Author: MichalPetryka
Assignees: -
Labels: `area-ILTools-coreclr`
Milestone: -
jkotas commented 2 years ago

Nothing in current .NET supports the no. prefix.

AaronRobinsonMSFT commented 2 years ago

/cc @TIHan

JosieBigler commented 2 years ago

Just to give context.

From the EMCA 335 6th edition Specification page 318.

This prefix (no.) indicates that the subsequent instruction need not perform the specified fault check
when it is executed. The byte that follows the instruction code indicates which checks can
optionally be skipped. This instruction is not verifiable.
JulieLeeMSFT commented 3 months ago

We will not have time to work on this in .NET 9. Moving to .NET 10.