
I'm reluctant to invest much effort in a hack, when we know we are going to create an SPT anyway. Let's just go for it! Even if there are no TypeReps in it yet.
Actually, I think that each entry in the SPT should have just two fields: something like
Key, Value
where "Key" is whatever we use as the "stable name" for the static value: a string, or something like that.
The "Value" is a full Haskell value, just a pointer into the heap (these are the new GC roots). The value has type Dynamic, or something very like it:
data Dynamic where
MkDyn :: TTypeRep a -> a -> Dynamic
Maybe the library Dynamic isn't quite what we need; e.g we may want to include the Key too:
data SptEntry where
SPT :: String -> TTypeRep a -> a -> SptEntry
But regardless, the SPT itself is a simple key/value table, and all the interesting structure in in the Values in Haskell-land.
Now all we need is
- To build top-level bindings for the SPT Entries.
These bindings are presumably created by the desugarer,
as it desugars uses of 'static'
- To collect them in an SPT
This is presumably done in a similar way to the mkModuleInit stuff
in StgCmm.codeGen
Simon
| -----Original Message-----
| From: 0xbadcode@gmail.com [mailto:0xbadcode@gmail.com] On Behalf Of
| Mathieu Boespflug
| Sent: 18 November 2014 18:03
| To: Simon Peyton Jones
| Cc: Facundo DomÃnguez; ghc-devs@haskell.org; Mathieu Boespflug
| Subject: Re: Garbage collection
|
| On 18 November 2014 16:59, Simon Peyton Jones