From 9004e883504aa93055a9fbdebfb21753e2454ca6 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Wed, 7 Feb 2007 08:21:10 +0000 Subject: [PATCH] Optimize dynamic breakpoints for speed Made a bit faster the test which gets done every time a running program hits a dynamic breakpoint. I moved the bounds checking inside a DEBUG pragma and replaced (IArray.!) for unsafeAt --- compiler/ghci/Debugger.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs index cb2a9ba..6248e0c 100644 --- a/compiler/ghci/Debugger.hs +++ b/compiler/ghci/Debugger.hs @@ -45,6 +45,7 @@ import Control.Exception import Control.Monad import qualified Data.Map as Map import Data.Array.Unboxed +import Data.Array.Base import Data.List import Data.Typeable ( Typeable ) import Data.Maybe @@ -539,15 +540,16 @@ addModule a siteCoords bt , sitesByRow <- [ [(s,c) | (s,(r,c)) <- siteCoords, r==i] | i <- [0..nrows] ] , nsites <- length siteCoords - , initialBkpts <- listArray (1, nsites) (repeat False) + , initialBkpts <- listArray (0, nsites+1) (repeat False) = bt{ sites = Map.insert a sitesByRow (sites bt) , breakpoints = Map.insert a initialBkpts (breakpoints bt) } +-- This MUST be fast +isBkptEnabled bt site | bt `seq` site `seq` False = undefined isBkptEnabled bt (a,site) | Just bkpts <- bkptsOf bt a - , inRange (bounds bkpts) site - = bkpts ! site - | otherwise = panic "unexpected condition: I don't know that breakpoint site" + = ASSERT (inRange (bounds bkpts) site) + unsafeAt bkpts site ----------------- -- Other stuff -- 1.7.10.4