[GHC] #7662: Improve GC of mutable objects
GHC
ghc-devs at haskell.org
Thu Jul 14 20:25:18 UTC 2016
#7662: Improve GC of mutable objects
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: ⊥
Component: Runtime System | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by dobenour):
MLton does manage to unpack refs in records though. I think that it can
be done in general IF you either:
- support interior pointers in the GC (which GHC probably doesn't).
- represent mutable refs as "fat pointers", consisting of both a pointer
to the object being mutated and a pointer to the cell within the object.
In this case
{{{#!hs
data SomeType = SomeType { x :: {-# UNPACK #-} !(IORef Int)
, y :: {-# UNPACK #-} !Char
}
getRef :: SomeType -> IORef Int
getRef = x
}}}
`x (v :: SomeType)` would produce an object that contains a pointer to `v`
(for the GC) and a pointer to field `x` of `v` (used to mutate `x`).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7662#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list