Does Anybody know the article about details or开发者_如何学Go memory layout for an exception handle on a frame of the stack?
The implementation details are very well hidden. Neither Brumme's blog nor the Rotor source code give a ready answer. One thing I know is that the try statement doesn't generate any code. That leaves few possible approaches. I think it is done the same way as SEH in 64-bit Windows.
I believe the JIT compiler generates a table of code addresses with a function pointer to an exception filter that's called when an exception is processed. The throw statement invokes a stack walk that looks at the method return addresses. The table maps a return address to the corresponding exception filter. The exception filter decides whether the exception matches a catch clause in the method. And transfers control to the code in the catch clause. Notable is that the Visual Basic Catch When statement (not available in C#) is a good match with the way SEH is implemented in Windows.
I have no proof of this nor do I know any authoritative source. It is merely a likely way it could work.
精彩评论