Skip to content

Question regarding stack size before each instruction #756

Answered by ltrzesniewski
m-carrasco asked this question in Q&A
Discussion options

You must be logged in to vote

I guess Cecil tries to aid the user to generate a legal output even if the input is illegal.

I believe so. Here's what ECMA-335 says in I.12.3.2.1:

The type state of the stack (the stack depth and types of each element on
the stack) at any given point in a program shall be identical for all possible control flow paths.
For example, a program that loops an unknown number of times and pushes a new element on
the stack at each iteration would be prohibited.

If you're interested, I wrote a simple stack depth checker based on Cecil's code here. It basically computes the stack size for each instruction, and fails if there's a mismatch. It's not pretty (I just wanted to check if another part…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@m-carrasco
Comment options

Answer selected by m-carrasco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants