Re: abstract interpreter for GHC Core or STG

2021-06-14 Thread Csaba Hruska
IMO supercompilation is related to abstract interpretation. In fact an abstract interpreter can behave as a concrete interpreter until multiple program states merge into a single state. In that case the interpreter has to give up precision and introduce abstract values. This technique is called abs

Re: abstract interpreter for GHC Core or STG

2021-06-08 Thread Csaba Hruska
The external STG interpreter implements the RTS semantics and features, so if we apply the calculating correct compiler method to the external STG interpreter code then we should get an IR that will include the RTS code also. On Wed, Jun 9, 2021 at 12:21 AM Carter Schonwald wrote: > How would th

Re: abstract interpreter for GHC Core or STG

2021-06-08 Thread Carter Schonwald
How would this be used to generate the rts automatically? I’m intrigued / would like to understand what you’re envisioning design wise for that leg. On Tue, Jun 8, 2021 at 5:34 PM Csaba Hruska wrote: > Cmm is too low level, I've implemented the primops in haskell in a high > level way, including

Re: abstract interpreter for GHC Core or STG

2021-06-08 Thread Csaba Hruska
Cmm is too low level, I've implemented the primops in haskell in a high level way, including the out of line primops with the rts related parts (scheduler, io manager). see: https://github.com/grin-compiler/ghc-whole-program-compiler-project/blob/master/external-stg-interpreter/lib/Stg/Interpreter/

Re: abstract interpreter for GHC Core or STG

2021-06-08 Thread Carter Schonwald
The stm impl In ghcjs might be a helpful comparative example on that front. Though I guess more broadly does this necessitate having a model of the Cmm semantics for the out of line primops ? On Tue, Jun 8, 2021 at 5:10 AM Simon Peyton Jones via ghc-devs < ghc-devs@haskell.org> wrote: > I wonder

RE: abstract interpreter for GHC Core or STG

2021-06-08 Thread Simon Peyton Jones via ghc-devs
I wonder if there was an attempt in the past to create an abstract interpreter for GHC Core or STG to approximate the program runtime behaviour? No, not that I know of. Because of all the primops, concurrency, STM, etc, it would be something of a challenge. The AAM story could be interesting…

Re: abstract interpreter for GHC Core or STG

2021-06-07 Thread Csaba Hruska
Yes, I've read Thomas Schilling's PhD thesis (Trace-based Just-in-timeCompilation for Lazy Functional Programming Languages) a couple of times. My STG interpreter almost supports all kinds of primops that GHC does, and I plan to add the missing ones in the future. I'd like to use literally the sam

Re: abstract interpreter for GHC Core or STG

2021-06-07 Thread Carter Schonwald
Correction it was Thomas schilling !! And you can Google his Phd thesis trace based just in time compilation for lazy functional programming languages And the associated code is on his GitHub nominolo/ lambdachine though I think it was last touched 7 years ago On Mon, Jun 7, 2021 at 11:54 AM Cart

Re: abstract interpreter for GHC Core or STG

2021-06-07 Thread Carter Schonwald
I’m not aware of any currently. I would be curious about the now relatively old work that Max bolingbroke did for his PhD (I think it was sortah a ghc to Lua JIT?!?) An important question is : what questions do you want the abstract interpreter to suport? On Mon, Jun 7, 2021 at 10:19 AM Csaba Hr