Dictu
Dictu copied to clipboard
STACK_MAX is a constant
STACK_MAX is a constant and there is no checking in push() to see if we have hit the stack limit. This is for good reason, as push() happens so frequently, a branch in here would hit performance significantly, however this does mean the VM can run into undefined behaviour if the stack count out grows the hard constant. This should instead be a value based on the "worst case" amount of values worked out at compile time.
Microsoft's C/C++ compiler uses chkstck to handle such an event, I recommend you take a look at it:
https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-chkstk