On 10/19/07, Daniel Grunwald <[EMAIL PROTECTED]> wrote:
> To check how my optimizer works, I disassembled both the non-optimized
> and the optimized assembly and looked at the diff between the files.
> There I was seeing that Cecil nearly always overestimated .maxstack, so
> I took a look at the implementation and saw that it didn't handle
> branches like my variable tracking implementation had to. Then I created
> that test case manually to show that Cecil's calculation is not correct.

> I just patched Cecil to calculate .maxstack exactly (using the
> GetPushDelta/GetPopDelta methods from Cecil.FlowAnalysis), the patch is
> attached.
> Now the stack count is reduced correctly for StackBehaviour.Varpop based
> on the number of parameters the called method has.

Niiice, thanks! I'll change a few bits and check it later today.

> Note that my patch uses Debug.Assert to detect invalid IL, and might
> throw a NotImplementedException if it encounters an instruction where it
> cannot determine the PushDelta/PopDelta.

Am thinking a NotSupported or InvalidOperation should do.

> That said, I finally managed to use my optimizer on SharpDevelop's
> ICSharpCode.NRefactory - and all unit tests still pass. (I had to fix
> several optimization bugs until that was the case)

That's a freaking amazing news.

How do you plan to release it? license?

> Short forms can make a significant difference in assembly size, so can
> we get a simply MethodBody.ToShortForms() method that automatically
> takes care when short forms are valid?

I already have a patch for that in the pool, provided by Carlo. I'll
refactor and check it in later today as well.

-- 
Jb Evain  <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to