Stable name equality
Simon Peyton Jones
simonpj at microsoft.com
Tue Aug 21 07:38:56 UTC 2018
| > But is the reverse true? That is, can we be sure that two pointer-
| distinct stable name objects contain different indices?
|
| I believe so, yes. Each stable name table entry has a pointer to the
| linked stable name object. Calling makeStableName# checks whether the
| passed pointer already has a stable name, and, if so, returns the linked
| stable name object.
Actually I'm confused. Currently we have
data StableName a = StableName (StableName# a)
I believe (but there is no documentation to state) that the (StableName# a)
* Has kind (TYPE UnliftedRep)
* Is the index of the entry in the Stable Name Table
But if it's the index, why isn't it an IntRep? UnliftedRep is for pointers?
Moreover eqStableName# :: StableName# a -> StableName# b -> Bool
is directly implemented in the code generator (StgCmmPrim) by an equality
comparison.
If these things are correct, it would be great to write them down in a Note.
And if they are right, I'm now lost about what you question is. Equality is
/already/ implemented by direct equality comparison, no?
Simon
| -----Original Message-----
| From: David Feuer <david at well-typed.com>
| Sent: 20 August 2018 23:36
| To: ghc-devs at haskell.org; Simon Peyton Jones <simonpj at microsoft.com>
| Cc: David Feuer <david.feuer at gmail.com>; marlowsd at gmail.com
| Subject: Re: Stable name equality
|
| On Monday, August 20, 2018 11:56:44 AM EDT Simon Peyton Jones via ghc-
| devs wrote:
| > I defer to SimonM but IIRC each stable name corresponds to an entry in
| the stable-name table; the index in the table is the “stable” thing in a
| stable name. So I bet that comparison compares these indices.
| >
| > If two stable names are pointer-equal, they presumably contain the same
| index into the table.
| >
| > But is the reverse true? That is, can we be sure that two pointer-
| distinct stable name objects contain different indices?
|
| I believe so, yes. Each stable name table entry has a pointer to the
| linked stable name object. Calling makeStableName# checks whether the
| passed pointer already has a stable name, and, if so, returns the linked
| stable name object. The design seems a bit surprising to me, but it looks
| like that's actually how it works, at least for now. Each call locks the
| stable name table, so it shouldn't be possible to miss entry creation.
More information about the ghc-devs
mailing list