dadhi / FastExpressionCompiler

Fast Compiler for C# Expression Trees and the lightweight LightExpression alternative. Diagnostic and code generation tools for the expressions.
MIT License
1.16k stars 82 forks source link

Diagnostics: calculate the stack population depth after each emit to expose the problematic cases #403

Open dadhi opened 6 months ago

dadhi commented 6 months ago

Using the OpCode.StackBehaviourPop and OpCode.StackBehaviourPush we may calculate the stack balance in the DEBUG Demit calls. See https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs,f10f1c9bbefdd170,references Also, we may calculate the balance in the PrintIL in tests. Then the value for System Compile and Fast Compile can be compared to see the discrepancies.