STG to JavaScript translation

Simon Peyton-Jones simonpj at microsoft.com
Thu Sep 20 02:42:12 EDT 2007


| > For example:
| >
| > f =
| >   let g = (THUNK h x)
| >   in (CONS g y)
| >
| > Is this exactly the same as (right variant following the paper)
| >
| > f =
| >   let g = (THUNK h x)
| >   in let freshvar = (CONS g y)
| >       in freshvar

Yes that's right.  The only problem with the latter is that it's not syntactically apparent that 'freshvar' is a value, and hence can be returned immediately rather than entered.  But one can solve that by maintaining an environment telling static info about in-scope variables, which the code gen needs to do anyway.

| > And the second question is how does constructor tag is passed to case
| > when non-vector return is used? In register? In constructor closure?
| > Are there any cases when closure is not build for constructor
| > application? What the case binder is bound to if there is no closure
| > for constructor application?

Read our paper "Faster laziness using dynamic pointer tagging"!  It's new (ICFP'07)
http://research.microsoft.com/~simonpj/papers/ptr-tag/index.htm

simon


More information about the Glasgow-haskell-users mailing list