How does short circuit evaluation work in MSIL
Question
How does the short circuit evaluation work in the msil interpreter? Does the And instruction contain information about where to jump to if false, and same for the Or with true?
Solution
No - the IL instructions for And and Or actually perform bitwise operations on the top two operands on the stack. If a high level language uses short circuit evaluation, it is compiled down to explicit branching operations at the IL level and doesn't rely on the And instruction at all. Use a tool like Reflector to see the actual IL produced by the compiler in question.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow