Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
e48618c7
Commit
e48618c7
authored
Apr 12, 2008
by
Ian Lynagh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use CPP for SLIT/FSLIT
parent
53f99d84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
compiler/HsVersions.h
compiler/HsVersions.h
+0
-8
compiler/utils/FastString.lhs
compiler/utils/FastString.lhs
+25
-7
No files found.
compiler/HsVersions.h
View file @
e48618c7
...
...
@@ -60,14 +60,6 @@ name = Util.global (value);
#define WARN(e,msg) if False && (e) then pprPanic "WARN" (msg) else
#endif
#if defined(__GLASGOW_HASKELL__)
#define SLIT(x) (FastString.mkLitString# (x#))
#define FSLIT(x) (FastString.mkFastString# (x#))
#else
#define SLIT(x) (FastString.mkLitString (x))
#define FSLIT(x) (FastString.mkFastString (x))
#endif
--
Useful
for
declaring
arguments
to
be
strict
#define STRICT1(f) f a | a `seq` False = undefined
#define STRICT2(f) f a b | a `seq` b `seq` False = undefined
...
...
compiler/utils/FastString.lhs
View file @
e48618c7
...
...
@@ -62,13 +62,15 @@ module FastString
LitString,
#if defined(__GLASGOW_HASKELL__)
mkLitString#,
#else
mkLitString,
#endif
mkLitString,
unpackLitString,
strLength,
ptrStrLength
ptrStrLength,
sLit,
fsLit,
) where
#include "HsVersions.h"
...
...
@@ -85,12 +87,13 @@ import System.IO
import System.IO.Unsafe ( unsafePerformIO )
import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
import Data.Maybe ( isJust )
#if !defined(__GLASGOW_HASKELL__)
import Data.Char ( ord )
#endif
import GHC.IOBase ( IO(..) )
import GHC.Ptr ( Ptr(..) )
#if defined(__GLASGOW_HASKELL__)
import GHC.Base ( unpackCString# )
#endif
#define hASH_TBL_SIZE 4091
#define hASH_TBL_SIZE_UNBOXED 4091#
...
...
@@ -500,7 +503,7 @@ type LitString = Ptr Word8
#if defined(__GLASGOW_HASKELL__)
mkLitString# :: Addr# -> LitString
mkLitString# a# = Ptr a#
#e
lse
#e
ndif
--can/should we use FastTypes here?
--Is this likely to be memory-preserving if only used on constant strings?
--should we inline it? If lucky, that would make a CAF that wouldn't
...
...
@@ -519,10 +522,12 @@ mkLitString s =
loop n (c:cs) = do
pokeByteOff p n (fromIntegral (ord c) :: Word8)
loop (1+n) cs
-- XXX GHC isn't smart enough to know that we have already covered
-- this case.
loop _ [] = panic "mkLitString"
loop 0 s
return p
)
#endif
unpackLitString :: LitString -> String
unpackLitString p_ = case pUnbox p_ of
...
...
@@ -571,4 +576,17 @@ pokeCAString ptr str =
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 602
peekCAStringLen = peekCStringLen
#endif
{-# NOINLINE sLit #-}
sLit :: String -> LitString
sLit x = mkLitString x
{-# NOINLINE fsLit #-}
fsLit :: String -> FastString
fsLit x = mkFastString x
{-# RULES "slit"
forall x . sLit (unpackCString# x) = mkLitString# x #-}
{-# RULES "fslit"
forall x . fsLit (unpackCString# x) = mkFastString# x #-}
\end{code}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment