[Mono-devel-list] First CIL Regex performance result
Ben Maurer
bmaurer at users.sourceforge.net
Sat Feb 28 13:43:28 EST 2004
Ok, lemme add some of my own:
> IL_000d: ldc.i4 0
> IL_0012: add
x + 0 = x
Also, you have alot of code like:
> IL_0080: ldarg.0
> IL_0081: ldfld int32 [System]System.Text.RegularExpressions.CILMachineBase::scan_ptr
> IL_0086: ldarg.0
> IL_0087: ldfld int32 [System]System.Text.RegularExpressions.CILMachineBase::text_end
> IL_008c: blt IL_0096
I wonder if you should store these into locals, and then store them back
when you are done. Local storage should be much faster.
> IL_0069: ret
>
> //**** Branch Code
> IL_006a: ldarg.0
> IL_006b: callvirt instance void class [System]'System.Text.RegularExpressions.CILMachineBase'::'Checkpoint'()
> IL_0070: br IL_0080
>
> IL_0075: ldarg.0
> IL_0076: callvirt instance void class [System]'System.Text.RegularExpressions.CILMachineBase'::'Backtrack'()
> IL_007b: br IL_00c9
>
> //**** Eval Character 1
> IL_0080: ldarg.0
Ok, the arragnement here is really weird. If you move the block 6a-70 to
right above 80, you can avoid a branch.
For debugging purposes, some of your code is really complex and hard to
understand. I realize it is not designed to be read, but you are going
ot make it hard on yourself if you emit code like:
> IL_00a7: ldarg.0
> IL_00a8: dup
> IL_00a9: ldfld int32 [System]System.Text.RegularExpressions.CILMachineBase::scan_ptr
> IL_00ae: ldc.i4.1
> IL_00af: add
> IL_00b0: stfld int32 [System]System.Text.RegularExpressions.CILMachineBase::scan_ptr
It is much easier to read
> IL_00a7: ldarg.0
> IL_00a9: ldfld int32 [System]System.Text.RegularExpressions.CILMachineBase::scan_ptr
> IL_00ae: ldc.i4.1
> IL_00af: add
> ldarg.0
> IL_00b0: stfld int32 [System]System.Text.RegularExpressions.CILMachineBase::scan_ptr
>
> IL_00da: br IL_0128
> ...
> IL_0128: br IL_005f
That can be simplified.
> IL_002a: blt IL_0068
> IL_0063: br IL_0028
>
> IL_0068: ldc.i4.0
> IL_0069: ret
The only branch to 68 is the one in 2a. So you can just move the code up there.
I think this shoudl get you on your way. Once you get these done, the
code should be alot cleaner and easier to optimize.
-- ben
More information about the Mono-devel-list
mailing list