-
Notifications
You must be signed in to change notification settings - Fork 0
Instruction Simplifier
BlazingTwist edited this page Dec 19, 2022
·
5 revisions
To improve patch reliability, all CodeInstructions will be simplified when testing for equality.
This table shows all simplifications:
Simplified | Original |
---|---|
Ldarg_S <arg> | Ldarg <arg> Ldarg_0 Ldarg_1 Ldarg_2 Ldarg_3 |
Ldloc_S <local> | Ldloc <local> Ldloc_0 Ldloc_1 Ldloc_2 Ldloc_3 |
Stloc_S <local> | Stloc <local> Stloc_0 Stloc_1 Stloc_2 Stloc_3 |
Ldc_I4_S <i4> | Ldc_I4 <i4> Ldc_I4_0 Ldc_I4_1 Ldc_I4_2 Ldc_I4_3 Ldc_I4_4 Ldc_I4_5 Ldc_I4_6 Ldc_I4_7 Ldc_I4_8 Ldc_I4_M1 |
Leave_S | Leave |
Br_S | Br |
Brfalse_S | Brfalse |
Brtrue_S | Brtrue |
Beq_S | Beq |
Bne_Un_S | Bne_Un |
Bge_S | Bge Bge_Un Bge_Un_S |
Ble_S | Ble Ble_Un Ble_Un_S |
Bgt_S | Bgt Bgt_Un Bgt_Un_S |
Blt_S | Blt Blt_Un Blt_Un_S |
Call | Callvirt Calli |
That means, for example, that new CodeInstruction(OpCodes.Ldarg_1)
and new CodeInstruction(OpCodes.Ldarg, 1)
will be treated as equal.
There is one more rule for comparing two CodeInstructions.
Let's call the instructions we're searching on program
and the instructions we're searching for search
.
null
s in program-Instructions only match null
s in search-Instructions.
But null
s in search-Instructions match anything in program-Instructions.
For example, these Instructions are treated as equal:
Program | Search |
---|---|
Ldfld <field> | Ldfld <field> |
Ldfld <field> | Ldfld null |
Ldfld <field> | null <field> |
Ldfld <field> | null null |
But these are not equal:
Program | Search |
---|---|
Ldfld null | Ldfld <field> |
null <field> | Ldfld <field> |
null null | Ldfld <field> |
Made with ❤️ by BlazingTwist
If you like my work and wish to support me, a
goes a long way