<div dir="ltr">On Tue, Jul 2, 2013 at 4:38 PM, B B <span dir="ltr">&lt;<a href="mailto:blackbox.dev.ml@gmail.com" target="_blank">blackbox.dev.ml@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Thank you for all the replies. </div><div>
Luite Stegeman - I was thinking that the LLVM IR code is optimized already or you can run LLVM IR optimization passes to get rid of such things. I think compiling with ghc -fllvm generates LLVM bitcode and then you can simply run emscripten on it to get Javascript - and it should work as expected.</div>
</div></blockquote><div><br></div><div style>Most of the optimizations that GHC does are on Core, so you also get those if you use Core or STG as the source. You do miss out on the later optimization passes (GHC optimizes Cmm with Hoopl, and LLVM optimizes again). We implement this in GHCJS ourselves, optimizing the generated JavaScript.</div>
<div style><br></div><div style>Since GHC itself is written in Haskell, it would be a good goal to compile simple Haskell programs first and make sure that the RTS is working (you&#39;ll need to compile the Cmm and C RTS files to LLVM). You can try to get the GHC Testsuite [1] running. The GHCJS testsuite [2] might also be useful, it contains much of the GHC Testsuite and a runner program that checks the JavaScript results against native Haskell.</div>
<div style><br></div><div style>Like i said in the previous post, the generated code is a bit weird: stacks are allocated dynamically, functions never return, there are only tail calls. Emscripten might have a hard time with this.</div>
<div><br></div><div style>[1] <a href="https://github.com/ghc/testsuite">https://github.com/ghc/testsuite</a></div><div style>[2] <a href="https://github.com/ghcjs/ghcjs/tree/master/test">https://github.com/ghcjs/ghcjs/tree/master/test</a></div>
</div></div></div>