Re: DataCon tag value convention

2020-02-12 Thread Csaba Hruska
Ok, but what I am curious about if the tag in the info table could be
globally unique?

On Wed, Feb 12, 2020 at 9:01 PM Vladislav Zavialov 
wrote:

> The globally unique tag for data constructors already exists, it’s a
> pointer to the StgInfoTable. You can observe it using getClosureRaw from
> GHC.HeapView
>
> Example:
>
> Prelude GHC.HeapView> getClosureRaw Nothing
> (0x000107fd8e38,[4429024840,4429024752],[])
>
> Here, the globally unique tag is 0x000107fd8e38.
>
> Note that newtype constructors do not get their own tag because newtypes
> guarantee that they do not change the underlying representation of data.
>
> I’ve discovered the existence of such a tag only recently (Alexander
> Vershilov pointed it out to me), so I cannot say if it’s a reliable way to
> identify data constructors. For example, it is definitely not stable across
> several runs of the same binary. However, within a single run, it seems to
> work.
>
> - Vlad
>
> > On 12 Feb 2020, at 21:57, Csaba Hruska  wrote:
> >
> > Hello,
> >
> > In theory could GHC codegen work if every data constructor in the whole
> program  have a globally unique tag value instead of starting from 1 for
> each algebraic data type?
> > Would this break any GHC design decision?
> >
> > Regards,
> > Csaba
> > ___
> > ghc-devs mailing list
> > ghc-devs@haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: DataCon tag value convention

2020-02-12 Thread Vladislav Zavialov
The globally unique tag for data constructors already exists, it’s a pointer to 
the StgInfoTable. You can observe it using getClosureRaw from GHC.HeapView

Example:

Prelude GHC.HeapView> getClosureRaw Nothing
(0x000107fd8e38,[4429024840,4429024752],[])

Here, the globally unique tag is 0x000107fd8e38.

Note that newtype constructors do not get their own tag because newtypes 
guarantee that they do not change the underlying representation of data.

I’ve discovered the existence of such a tag only recently (Alexander Vershilov 
pointed it out to me), so I cannot say if it’s a reliable way to identify data 
constructors. For example, it is definitely not stable across several runs of 
the same binary. However, within a single run, it seems to work.

- Vlad

> On 12 Feb 2020, at 21:57, Csaba Hruska  wrote:
> 
> Hello,
> 
> In theory could GHC codegen work if every data constructor in the whole 
> program  have a globally unique tag value instead of starting from 1 for each 
> algebraic data type?
> Would this break any GHC design decision?
> 
> Regards,
> Csaba
> ___
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: DataCon tag value convention

2020-02-12 Thread Csaba Hruska
Ok, fair enough.
Would it break anything else? (i.e. coercions)

On Wed, Feb 12, 2020 at 8:34 PM Sebastian Graf  wrote:

> You probably couldn't do pointer tagging
> 
> anymore, which is probably a substantial performance loss.
>
> Am Mi., 12. Feb. 2020 um 19:58 Uhr schrieb Csaba Hruska <
> csaba.hru...@gmail.com>:
>
>> Hello,
>>
>> In theory could GHC codegen work if every data constructor in the whole
>> program  have a globally unique tag value instead of starting from 1 for
>> each algebraic data type?
>> Would this break any GHC design decision?
>>
>> Regards,
>> Csaba
>> ___
>> ghc-devs mailing list
>> ghc-devs@haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>>
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: DataCon tag value convention

2020-02-12 Thread Sebastian Graf
You probably couldn't do pointer tagging

anymore, which is probably a substantial performance loss.

Am Mi., 12. Feb. 2020 um 19:58 Uhr schrieb Csaba Hruska <
csaba.hru...@gmail.com>:

> Hello,
>
> In theory could GHC codegen work if every data constructor in the whole
> program  have a globally unique tag value instead of starting from 1 for
> each algebraic data type?
> Would this break any GHC design decision?
>
> Regards,
> Csaba
> ___
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


DataCon tag value convention

2020-02-12 Thread Csaba Hruska
Hello,

In theory could GHC codegen work if every data constructor in the whole
program  have a globally unique tag value instead of starting from 1 for
each algebraic data type?
Would this break any GHC design decision?

Regards,
Csaba
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs