Re: STG to JavaScript translation
On 9/20/07, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote: > > | Cool, is it implemented in 2.8? Function tagging seems promising for > | performance. But it isn't implementable in JavaScript :) > > I think it'll be in GHC 6.8. > I've meant 6.8 :) -- vir http://vir.comtv.ru/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: STG to JavaScript translation
| Cool, is it implemented in 2.8? Function tagging seems promising for | performance. But it isn't implementable in JavaScript :) I think it'll be in GHC 6.8. | I have one more question. There are know calls (saturated | applications) and unknown calls in STG. Is this information is encoded | in GHC's STG datatype or should I maintain my own table of known | functions. You need to keep your own table S ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
> 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 > Cool, is it implemented in 2.8? Function tagging seems promising for performance. But it isn't implementable in JavaScript :) I have one more question. There are know calls (saturated applications) and unknown calls in STG. Is this information is encoded in GHC's STG datatype or should I maintain my own table of known functions. -- vir http://vir.comtv.ru/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: STG to JavaScript translation
| > 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 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
On Thu, Sep 20, 2007 at 06:13:38AM +0400, Victor Nazarov wrote: > I still have some questions regarding the GHC internals. > There is a description of STG language in the "Making a Fast Curry: > Push/Enter vs. Eval/Apply for Higher-oder Languages" (2004) by Simon > Marlow and Simon Peyton Jones paper. In this description the > constructor application (CONS closure) can only appear on the right > hand side of the bindings. This is totally reasonable if "let" is the > only construct that allocates objects. But in the GHC's StgSyn.hs any > expression can be constructor application. How does constructor > applications are compiled? Are they implicitly transformed to let? > 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 > > ? > > 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? The StgSyn type *declaration* allows this stuff. In actual use, it's always kept in, and expected to be in, A-normal form. The Simons have said that much of GHC is sadly written as though it was written in a dynamically typed language and then shoddily ported to Haskell; types do NOT describe ghc's data, to borrow one of Conor's catchphrases. (I can't find the original) Stefan signature.asc Description: Digital signature ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
STG to JavaScript translation
I still have some questions regarding the GHC internals. There is a description of STG language in the "Making a Fast Curry: Push/Enter vs. Eval/Apply for Higher-oder Languages" (2004) by Simon Marlow and Simon Peyton Jones paper. In this description the constructor application (CONS closure) can only appear on the right hand side of the bindings. This is totally reasonable if "let" is the only construct that allocates objects. But in the GHC's StgSyn.hs any expression can be constructor application. How does constructor applications are compiled? Are they implicitly transformed to let? 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 ? 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? -- vir http://vir.comtv.ru/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
I still have some questions regarding the GHC internals. There is a description of STG language in the "Making a Fast Curry: Push/Enter vs. Eval/Apply for Higher-oder Languages" (2004) by Simon Marlow and Simon Peyton Jones paper. In this description the constructor application (CONS closure) can only appear on the right hand side of the bindings. This is totally reasonable if "let" is the only construct that allocates objects. But in the GHC's StgSyn.hs any expression can be constructor application. How does constructor applications are compiled? Are they implicitly transformed to let? 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 ? 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? -- vir http://vir.comtv.ru/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
On Mon, 17 Sep 2007, Neil Mitchell wrote: > Hi > > > case e of b { pati -> rhsi } > > > > * evaluates 'e', > > * binds the resulting value to 'b', > > * performs case analysis on the result to find which alternative to choose > > * binds the variables of the pattern to the components of the value > > The Yhc.Core translator converts this to: > > let b = e in case b of { pati -> rhsi } > > I'm not sure if that would be a clearer form for you to work with, as > it is closer to standard Haskell. > Definitely not, let allocates. -- [EMAIL PROTECTED] There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
Hi > case e of b { pati -> rhsi } > > * evaluates 'e', > * binds the resulting value to 'b', > * performs case analysis on the result to find which alternative to choose > * binds the variables of the pattern to the components of the value The Yhc.Core translator converts this to: let b = e in case b of { pati -> rhsi } I'm not sure if that would be a clearer form for you to work with, as it is closer to standard Haskell. Thanks Neil ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: STG to JavaScript translation
case e of b { pati -> rhsi } * evaluates 'e', * binds the resulting value to 'b', * performs case analysis on the result to find which alternative to choose * binds the variables of the pattern to the components of the value This is described in the GHC commentary: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType does that help? Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On | Behalf Of Victor Nazarov | Sent: 17 September 2007 11:48 | To: glasgow-haskell-users@haskell.org | Subject: STG to JavaScript translation | | Hello. | I'm working on the translation of GHC's STG language to | JavaScript. I've started my implementation, but I've got stuck with | the STG case statements. The problem is the binder in case expression. | | StgCase expr livevars liverhsvars bndr srt alttype alts | | Operationally, I need to save continuation and evaluate expr | expression, but I have no idea what to do with the bndr. It seems to | me that I need to build a closure binded by bndr with the body of | expr evaluate it, update it, and use it in RHSs of alternatives. | But It seems that this behavior isn't intended by GHC. Can you explain briefly | how GHC implements this binder and what this binder points to. | | Here are some notes about Dmitries last year activity and my activity: | http://haskell.org/haskellwiki/STG_in_Javascript | | -- | vir | http://vir.comtv.ru/ | ___ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
Victor Nazarov wrote: Hello. I'm working on the translation of GHC's STG language to JavaScript. I've started my implementation, but I've got stuck with the STG case statements. The problem is the binder in case expression. StgCase expr livevars liverhsvars bndr srt alttype alts Operationally, I need to save continuation and evaluate expr expression, but I have no idea what to do with the bndr. It seems to me that I need to build a closure binded by bndr with the body of expr evaluate it, update it, and use it in RHSs of alternatives. But It seems that this behavior isn't intended by GHC. Can you explain briefly how GHC implements this binder and what this binder points to. It should be easy to implement: the value of expr is bound to bndr within the alternatives. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: STG to JavaScript translation
Hi Are you aware that Dimitry is still working on ycr2js - and has made great progress. There are details available in The Monad Reader, issue 7 (http://www.haskell.org/haskellwiki/The_Monad.Reader) Thanks Neil On 9/17/07, Victor Nazarov <[EMAIL PROTECTED]> wrote: > Hello. > I'm working on the translation of GHC's STG language to > JavaScript. I've started my implementation, but I've got stuck with > the STG case statements. The problem is the binder in case expression. > > StgCase expr livevars liverhsvars bndr srt alttype alts > > Operationally, I need to save continuation and evaluate expr > expression, but I have no idea what to do with the bndr. It seems to > me that I need to build a closure binded by bndr with the body of > expr evaluate it, update it, and use it in RHSs of alternatives. > But It seems that this behavior isn't intended by GHC. Can you explain briefly > how GHC implements this binder and what this binder points to. > > Here are some notes about Dmitries last year activity and my activity: > http://haskell.org/haskellwiki/STG_in_Javascript > > -- > vir > http://vir.comtv.ru/ > ___ > Glasgow-haskell-users mailing list > Glasgow-haskell-users@haskell.org > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
STG to JavaScript translation
Hello. I'm working on the translation of GHC's STG language to JavaScript. I've started my implementation, but I've got stuck with the STG case statements. The problem is the binder in case expression. StgCase expr livevars liverhsvars bndr srt alttype alts Operationally, I need to save continuation and evaluate expr expression, but I have no idea what to do with the bndr. It seems to me that I need to build a closure binded by bndr with the body of expr evaluate it, update it, and use it in RHSs of alternatives. But It seems that this behavior isn't intended by GHC. Can you explain briefly how GHC implements this binder and what this binder points to. Here are some notes about Dmitries last year activity and my activity: http://haskell.org/haskellwiki/STG_in_Javascript -- vir http://vir.comtv.ru/ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users