Behavior of touch#

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Behavior of touch#

Brandon Simmons
The `primitive` package exports a lifted version of the undocumented `touch#`

    http://hackage.haskell.org/package/ghc-prim-0.3.1.0/docs/GHC-Prim.html

which has type:

    touch :: PrimMonad m => a -> m ()

I'd like to know if this works correctly in general, or will it suffer
from the same gotches w/r/t unboxing as with addFinalizer and Weak
references? i.e. must it only be passed an unboxed type?

Brandon
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of touch#

Carter Schonwald
the point of touch is to prevent premature GC, it actually gets erased at the CMM level i believe. 
That is, it only makes sense to apply touch to lifted types on the heap! 

On Mon, Dec 15, 2014 at 4:21 PM, Brandon Simmons <[hidden email]> wrote:
The `primitive` package exports a lifted version of the undocumented `touch#`

    http://hackage.haskell.org/package/ghc-prim-0.3.1.0/docs/GHC-Prim.html

which has type:

    touch :: PrimMonad m => a -> m ()

I'd like to know if this works correctly in general, or will it suffer
from the same gotches w/r/t unboxing as with addFinalizer and Weak
references? i.e. must it only be passed an unboxed type?

Brandon
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of touch#

Carter Schonwald
https://github.com/ghc/ghc/blob/8c10b67ba049477cc9ed23e61f5bd119e1cefc29/compiler/cmm/CmmMachOp.hs#L556


spell it out a bit more

so touch is preserved through the CMM level, and then gets erased when doing final code gen.
Its meant to ensure on heap pointers remain reachable

On Tue, Dec 16, 2014 at 1:43 AM, Carter Schonwald <[hidden email]> wrote:
the point of touch is to prevent premature GC, it actually gets erased at the CMM level i believe. 
That is, it only makes sense to apply touch to lifted types on the heap! 

On Mon, Dec 15, 2014 at 4:21 PM, Brandon Simmons <[hidden email]> wrote:
The `primitive` package exports a lifted version of the undocumented `touch#`

    http://hackage.haskell.org/package/ghc-prim-0.3.1.0/docs/GHC-Prim.html

which has type:

    touch :: PrimMonad m => a -> m ()

I'd like to know if this works correctly in general, or will it suffer
from the same gotches w/r/t unboxing as with addFinalizer and Weak
references? i.e. must it only be passed an unboxed type?

Brandon
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

RE: Behavior of touch#

Simon Peyton Jones

Would it make sense to elaborate the Haddock docs to explain stuff here?

 

Simon

 

From: Glasgow-haskell-users [mailto:[hidden email]] On Behalf Of Carter Schonwald
Sent: 16 December 2014 06:45
To: Brandon Simmons
Cc: glasgow-haskell-users
Subject: Re: Behavior of touch#

 

https://github.com/ghc/ghc/blob/8c10b67ba049477cc9ed23e61f5bd119e1cefc29/compiler/cmm/CmmMachOp.hs#L556

 

 

spell it out a bit more

 

so touch is preserved through the CMM level, and then gets erased when doing final code gen.

Its meant to ensure on heap pointers remain reachable

 

On Tue, Dec 16, 2014 at 1:43 AM, Carter Schonwald <[hidden email]> wrote:

the point of touch is to prevent premature GC, it actually gets erased at the CMM level i believe. 

That is, it only makes sense to apply touch to lifted types on the heap! 

 

On Mon, Dec 15, 2014 at 4:21 PM, Brandon Simmons <[hidden email]> wrote:

The `primitive` package exports a lifted version of the undocumented `touch#`

    http://hackage.haskell.org/package/ghc-prim-0.3.1.0/docs/GHC-Prim.html

which has type:

    touch :: PrimMonad m => a -> m ()

I'd like to know if this works correctly in general, or will it suffer
from the same gotches w/r/t unboxing as with addFinalizer and Weak
references? i.e. must it only be passed an unboxed type?

Brandon
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users