packages feed

speculation 0.8.2.0 → 0.9.0.0

raw patch · 4 files changed

+20/−14 lines, 4 files

Files

CHANGELOG.markdown view
@@ -1,3 +1,6 @@+/0.9.0/:+ * Removed interim boxing in the unsafeIsEvaluated and unsafeGetTagBits check+ /0.8.1/:  * Added Data.List.Foldable  * Added Data.Traversable.Foldable
Control/Concurrent/Speculation.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, BangPatterns, DeriveDataTypeable #-}+{-# LANGUAGE CPP, BangPatterns, DeriveDataTypeable, MagicHash #-} module Control.Concurrent.Speculation     (     -- * Speculative application@@ -27,9 +27,12 @@ import Data.Function (on)  #if __GLASGOW_HASKELL__ >= 608-import Data.Bits ((.&.))+-- import Data.Bits ((.&.))+-- import Unsafe.Coerce (unsafeCoerce) import Foreign (sizeOf)-import Unsafe.Coerce (unsafeCoerce)+import GHC.Prim+import GHC.Types+import GHC.Word -- dynamic pointer tagging is present on this platform #define TAGGED #endif@@ -196,17 +199,22 @@ {-# INLINE specOnSTM' #-}  -- | Inspect the dynamic pointer tagging bits of a closure. This is an impure function that relies on GHC internals and may falsely return 0, but should never give the wrong tag number if it returns a non-0 value.-unsafeGetTagBits :: a -> Int+unsafeGetTagBits :: a -> Word {-# INLINE unsafeGetTagBits #-} #ifndef TAGGED unsafeGetTagBits _ = 0 #else-unsafeGetTagBits a = unsafeCoerce (Box a) .&. (sizeOf (undefined :: Int) - 1)--- | Used to inspect tag bits-data Box a = Box a+unsafeGetTagBits a = W# (and# (unsafeCoerce# a) (int2Word# mask#))+    where +        !(I# mask#) = sizeOf (undefined :: Int) - 1++-- unsafeGetTagBits a = unsafeCoerce (Box a) .&. (sizeOf (undefined :: Word) - 1)+-- data Box a = Box a #endif  -- | Returns a guess as to whether or not a value has been evaluated. This is an impure function that relies on GHC internals and will return false negatives, but no false positives. This is unsafe as the value of this function will vary (from False to True) over the course of otherwise pure invocations! unsafeIsEvaluated :: a -> Bool-unsafeIsEvaluated a = unsafeGetTagBits a /= 0+unsafeIsEvaluated a = and# (unsafeCoerce# a) (int2Word# mask#) `gtWord#` int2Word# 0#+    where +        !(I# mask#) = sizeOf (undefined :: Int) - 1 {-# INLINE unsafeIsEvaluated #-}
ISSUES.markdown view
@@ -26,11 +26,6 @@ Sadly, the cap and spark machinery is marked private by GHC, so this needs to become a ticket. -unboxed tag-checking-----------------------For tag checking purposes, we should be able to unsafeCoerce# a :: Word#, but it isn't subkinded. Ticket?- inconsistent use of the estimator function ------------------------------------------ 
speculation.cabal view
@@ -1,5 +1,5 @@ name:           speculation-version:        0.8.2.0+version:        0.9.0.0 license:        BSD3 license-file:   LICENSE author:         Edward A. Kmett