VB.NET and .maxstack

  • Thread starter Thread starter Kjetil Kristoffer Solberg
  • Start date Start date
K

Kjetil Kristoffer Solberg

Why is it that the VB.NET compiler outputs an incorrect .maxstack CIL
directive? It
seems like they always set it to 8. Even though the correct value should be
1 or 2 for
example.


regards
Kjetil Kristoffer Solberg
 
Hi
It's a "feature", and I recall it's mentioned somewhere on the Microsoft
site. I have a feeling that the C# compiler actually determines the correct
..maxstack value, whereas vbc just defaults to 8 unless a deeper stack is
required. I'm not sure this makes any difference to performance though, but
I'm sure someone will correct me on this :-)

Cheers,
Alex Clark
 
But this could become a problem. I can see that since you know how the
MS-CLR-JIT compiler
and verifier works, you can do this. But, lets say you're on a different
platform that has a different
implementation of the JIT-Compiler and verifier. This implementation could
throw an exception
when the .maxstack directive is incorrect, leaving your application useless
on that platform.

regards
Kjetil Kristoffer Solberg
 
Hi,

I suspect MS probably included a clause in the CLS of something like "To be
fully CLR compliant, the JIT-Compiler should not check to see if the
..maxstack value is accurate." This would cover their back in that type of
scenario.

;-)

Cheers,
Alex
 
Its used for analysis and verification of the program, not for runtime. As
long as the .Maxstack is greater than actual stack size, the program is
verifiable, so it doesn't hurt with default of 8. If it was less than the
actual stack size then the program is unverifiable and can be rejected by
the runtime implementation in the verification process.

Its discussed in the specifications of CLI.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top