[erlang-questions] HiPE for Windows?

David Hopwood david.hopwood@REDACTED
Sat Dec 29 06:10:02 CET 2007


I wrote:
[...]
> I don't think it's possible for a VEH handler to actually switch the
> stack and then continue normal exception processing (because it must
> return on the same stack in order to do that). However, there are at
> least two possible workarounds:
> 
> 1. Use only VEH to replace signals. In that case the vectored handler
>    can switch the stack and then call the "signal handler" itself,
>    bypassing Structured Exception Handling entirely. I think that
>    Sun's Hotspot JVM on Win64-Itanium, and Apache's Harmony JVM, use
>    this approach.
> 
>    Note that this prevents the Erlang emulator itself from using SEH.
>    I don't know whether that is a problem or not. Linked-in drivers can
>    still use SEH, because they run with a larger stack (I assume, since
>    they will not have the stack checks inserted by HiPE), and the VEH
>    handler can detect this case and continue normal exception processing.
> 
> 2. Save the stack area that could be trashed by the signal handler,
>    and have the signal handler restore it just before resuming. For the
>    multi-threaded emulator, it would also be necessary to stop all other
>    threads (or make sure that they will not access the area that could be
>    trashed).

Approach 2 assumes that all exception handlers finish by executing the code
to restore the stack, which is probably not a desirable assumption. Instead,
the VEH handler could set the return IP to code that restores the stack,
and then jumps to the original return IP.

In any case, approach 1 is probably simpler, and the fact that at least two
other language implementations use it is encouraging.

-- 
David Hopwood



More information about the erlang-questions mailing list