[erlang-questions] HiPE for Windows?

Mikael Pettersson mikpe@REDACTED
Fri Dec 28 17:39:29 CET 2007


On Fri, 28 Dec 2007 09:45:25 +1100, Benjamin Tolputt wrote:
>Mikael Pettersson wrote:
>> There are no plans for a Win32 version of HiPE, due to a
>> combination of technical issues and lack of interest.
>> HiPE works fine on Linux, Solaris, and at least some of the *BSDs.
>Do you know what these problems are and/or where people (such as myself)
>can look at them? I've played with (the code of) JIT compilers on
>Windows and haven't come across show-stoppers before.

Asynchronously called functions on the current ESP/RSP stack.

Unix signal handlers are by default invoked on the thread's
current stack, but they can be redirected to a separate stack
using SA_ONSTACK and sigaltstack().

It's my understanding, from reading papers on various systems
ported to or developed for Win32, that Win32 (a) will call
functions asynchronously on the current stack, and (b) does
not provide an altstack-like mechanism.

Why is this a problem?

Because the stack is managed by the HiPE compiler and runtime
system. It starts small and only grows in response to explicit
stack overflow checks inserted by the HiPE compiler.

Running alien code on the current native stack simply isn't safe.

I know of two workarounds, neither of which is attractive:
1. Make stacks larger with at least a page's worth of "slack"
   at the bottom for asynchronously invoked alien code.
   Drawback: Erlang processes are supposed to be light-weight,
   with this "solution" they aren't any more, which negatively
   affects Erlang's ability to have many thousands of processes
   around.
2. Don't use ESP/RSP for the Erlang stack in native code.
   Drawback 1: Loses a general-purpose register on the register-
   starved x86. Doubleplusungood.
   Drawback 2: Loses use of the processor's return stack branch
   predictor, which makes function calls much more expensive.
   Remember, Erlang isn't Fortran, there are lots and lots of
   calls to smallish functions.
   Drawback 3: More instructions needed to implement call and
   return sequences, again making function calls more expensive.

There are superior alternative platforms for servers (just about
any *NIX-like OS), so I don't consider the lack of HiPE for Win32
to be a critical problem.

/Mikael



More information about the erlang-questions mailing list