summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-09-17 08:09:36 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2012-09-17 08:09:36 +0100
commit8c3b9aca3aaf946a91c9af6c07fc9d2afb6bbb76 (patch)
tree4cad3f73dbb84bbda3b0b7141c5bde2afd359664 /compiler/main
parent7b8a17ad3c0792f06ffa991e9e587f5458610a3c (diff)
parentb0f4c44ed777af599daf35035b0830b35e57fa4a (diff)
downloadhaskell-8c3b9aca3aaf946a91c9af6c07fc9d2afb6bbb76.tar.gz
Merge branch 'master' of http://darcs.haskell.org/ghc
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/BreakArray.hs46
-rw-r--r--compiler/main/DynFlags.hs13
-rw-r--r--compiler/main/InteractiveEval.hs3
3 files changed, 36 insertions, 26 deletions
diff --git a/compiler/main/BreakArray.hs b/compiler/main/BreakArray.hs
index 91e4c96c9a..4d3145fb3a 100644
--- a/compiler/main/BreakArray.hs
+++ b/compiler/main/BreakArray.hs
@@ -25,62 +25,62 @@ module BreakArray
#endif
) where
+import DynFlags
+
#ifdef GHCI
import Control.Monad
import GHC.Exts
import GHC.IO ( IO(..) )
-import Constants
-
data BreakArray = BA (MutableByteArray# RealWorld)
breakOff, breakOn :: Word
breakOn = 1
breakOff = 0
-showBreakArray :: BreakArray -> IO ()
-showBreakArray array = do
- forM_ [0..(size array - 1)] $ \i -> do
+showBreakArray :: DynFlags -> BreakArray -> IO ()
+showBreakArray dflags array = do
+ forM_ [0 .. (size dflags array - 1)] $ \i -> do
val <- readBreakArray array i
putStr $ ' ' : show val
putStr "\n"
-setBreakOn :: BreakArray -> Int -> IO Bool
-setBreakOn array index
- | safeIndex array index = do
+setBreakOn :: DynFlags -> BreakArray -> Int -> IO Bool
+setBreakOn dflags array index
+ | safeIndex dflags array index = do
writeBreakArray array index breakOn
return True
| otherwise = return False
-setBreakOff :: BreakArray -> Int -> IO Bool
-setBreakOff array index
- | safeIndex array index = do
+setBreakOff :: DynFlags -> BreakArray -> Int -> IO Bool
+setBreakOff dflags array index
+ | safeIndex dflags array index = do
writeBreakArray array index breakOff
return True
| otherwise = return False
-getBreak :: BreakArray -> Int -> IO (Maybe Word)
-getBreak array index
- | safeIndex array index = do
+getBreak :: DynFlags -> BreakArray -> Int -> IO (Maybe Word)
+getBreak dflags array index
+ | safeIndex dflags array index = do
val <- readBreakArray array index
return $ Just val
| otherwise = return Nothing
-safeIndex :: BreakArray -> Int -> Bool
-safeIndex array index = index < size array && index >= 0
+safeIndex :: DynFlags -> BreakArray -> Int -> Bool
+safeIndex dflags array index = index < size dflags array && index >= 0
-size :: BreakArray -> Int
-size (BA array) = (I# (sizeofMutableByteArray# array)) `div` wORD_SIZE
+size :: DynFlags -> BreakArray -> Int
+size dflags (BA array) = (I# (sizeofMutableByteArray# array)) `div` wORD_SIZE dflags
allocBA :: Int -> IO BreakArray
allocBA (I# sz) = IO $ \s1 ->
case newByteArray# sz s1 of { (# s2, array #) -> (# s2, BA array #) }
-- create a new break array and initialise elements to zero
-newBreakArray :: Int -> IO BreakArray
-newBreakArray entries@(I# sz) = do
- BA array <- allocBA (entries * wORD_SIZE)
+newBreakArray :: DynFlags -> Int -> IO BreakArray
+newBreakArray dflags entries@(I# sz) = do
+ BA array <- allocBA (entries * wORD_SIZE dflags)
case breakOff of
W# off -> do -- Todo: there must be a better way to write zero as a Word!
let loop n | n ==# sz = return ()
@@ -112,8 +112,8 @@ readBreakArray (BA array) (I# i) = readBA# array i
-- presumably have a different representation.
data BreakArray = Unspecified
-newBreakArray :: Int -> IO BreakArray
-newBreakArray _ = return Unspecified
+newBreakArray :: DynFlags -> Int -> IO BreakArray
+newBreakArray _ _ = return Unspecified
#endif /* GHCI */
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index d07977ceea..d4c3d535d6 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -120,6 +120,8 @@ module DynFlags (
#include "../includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs"
bLOCK_SIZE_W,
wORD_SIZE_IN_BITS,
+ tAG_MASK,
+ mAX_PTR_TAG,
) where
#include "HsVersions.h"
@@ -151,6 +153,7 @@ import System.IO.Unsafe ( unsafePerformIO )
import Data.IORef
import Control.Monad
+import Data.Bits
import Data.Char
import Data.List
import Data.Map (Map)
@@ -3148,8 +3151,14 @@ compilerInfo dflags
#include "../includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs"
bLOCK_SIZE_W :: DynFlags -> Int
-bLOCK_SIZE_W dflags = bLOCK_SIZE dflags `quot` wORD_SIZE
+bLOCK_SIZE_W dflags = bLOCK_SIZE dflags `quot` wORD_SIZE dflags
wORD_SIZE_IN_BITS :: DynFlags -> Int
-wORD_SIZE_IN_BITS _ = wORD_SIZE * 8
+wORD_SIZE_IN_BITS dflags = wORD_SIZE dflags * 8
+
+tAG_MASK :: DynFlags -> Int
+tAG_MASK dflags = (1 `shiftL` tAG_BITS dflags) - 1
+
+mAX_PTR_TAG :: DynFlags -> Int
+mAX_PTR_TAG = tAG_MASK
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index a797329930..806f8356e6 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -347,7 +347,8 @@ isBreakEnabled :: HscEnv -> BreakInfo -> IO Bool
isBreakEnabled hsc_env inf =
case lookupUFM (hsc_HPT hsc_env) (moduleName (breakInfo_module inf)) of
Just hmi -> do
- w <- getBreak (modBreaks_flags (getModBreaks hmi))
+ w <- getBreak (hsc_dflags hsc_env)
+ (modBreaks_flags (getModBreaks hmi))
(breakInfo_number inf)
case w of Just n -> return (n /= 0); _other -> return False
_ ->