Permalink
Browse files

RTS tidyup sweep, first phase

The first phase of this tidyup is focussed on the header files, and in
particular making sure we are exposinng publicly exactly what we need
to, and no more.

 - Rts.h now includes everything that the RTS exposes publicly,
   rather than a random subset of it.

 - Most of the public header files have moved into subdirectories, and
   many of them have been renamed.  But clients should not need to
   include any of the other headers directly, just #include the main
   public headers: Rts.h, HsFFI.h, RtsAPI.h.

 - All the headers needed for via-C compilation have moved into the
   stg subdirectory, which is self-contained.  Most of the headers for
   the rest of the RTS APIs have moved into the rts subdirectory.

 - I left MachDeps.h where it is, because it is so widely used in
   Haskell code.
 
 - I left a deprecated stub for RtsFlags.h in place.  The flag
   structures are now exposed by Rts.h.

 - Various internal APIs are no longer exposed by public header files.

 - Various bits of dead code and declarations have been removed

 - More gcc warnings are turned on, and the RTS code is more
   warning-clean.

 - More source files #include "PosixSource.h", and hence only use
   standard POSIX (1003.1c-1995) interfaces.

There is a lot more tidying up still to do, this is just the first
pass.  I also intend to standardise the names for external RTS APIs
(e.g use the rts_ prefix consistently), and declare the internal APIs
as hidden for shared libraries.
  • Loading branch information...
1 parent 5d379cb commit a2a67cd520b9841114d69a87a423dabcb3b4368e @simonmar simonmar committed Aug 2, 2009
Showing with 2,182 additions and 3,338 deletions.
  1. +1 −1 compiler/cmm/CmmInfo.hs
  2. +1 −1 compiler/cmm/PprCmm.hs
  3. +1 −1 compiler/codeGen/CgCallConv.hs
  4. +2 −2 compiler/codeGen/CgProf.hs
  5. +1 −1 compiler/codeGen/CgUtils.hs
  6. +2 −2 compiler/codeGen/SMRep.lhs
  7. +1 −1 compiler/codeGen/StgCmmLayout.hs
  8. +2 −2 compiler/codeGen/StgCmmProf.hs
  9. +1 −1 compiler/codeGen/StgCmmUtils.hs
  10. +1 −1 compiler/ghci/ByteCodeAsm.lhs
  11. +2 −2 compiler/ghci/ByteCodeItbls.lhs
  12. +1 −1 compiler/ghci/RtClosureInspect.hs
  13. +1 −1 compiler/iface/BinIface.hs
  14. +2 −2 compiler/main/Constants.lhs
  15. +1 −1 compiler/main/StaticFlags.hs
  16. +1 −1 compiler/nativeGen/Alpha/Regs.hs
  17. +1 −1 compiler/nativeGen/PPC/CodeGen.hs
  18. +1 −1 compiler/nativeGen/PPC/Regs.hs
  19. +1 −1 compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
  20. +1 −1 compiler/nativeGen/RegAlloc/Linear/Main.hs
  21. +1 −1 compiler/nativeGen/SPARC/CodeGen.hs
  22. +1 −1 compiler/nativeGen/SPARC/RegPlate.hs
  23. +6 −4 compiler/nativeGen/SPARC/Regs.hs
  24. +1 −1 compiler/nativeGen/X86/CodeGen.hs
  25. +1 −1 compiler/nativeGen/X86/Ppr.hs
  26. +1 −1 compiler/nativeGen/X86/Regs.hs
  27. +5 −3 compiler/parser/cutils.c
  28. +1 −1 compiler/utils/Binary.hs
  29. +1 −1 compiler/utils/FastMutInt.lhs
  30. +0 −185 includes/ClosureMacros.h
  31. +21 −10 includes/Cmm.h
  32. +0 −331 includes/GranSim.h
  33. +1 −5 includes/HsFFI.h
  34. +0 −3 includes/MachDeps.h
  35. +0 −360 includes/Parallel.h
  36. +3 −6 includes/README
  37. +49 −81 includes/Rts.h
  38. +1 −1 includes/RtsAPI.h
  39. +0 −64 includes/RtsConfig.h
  40. +0 −129 includes/RtsExternal.h
  41. +2 −239 includes/RtsFlags.h
  42. +0 −63 includes/Stable.h
  43. +25 −32 includes/Stg.h
  44. +0 −583 includes/Storage.h
  45. +0 −7 includes/config.h
  46. +3 −3 includes/ghc.mk
  47. +0 −35 includes/ieee-flpt.h
  48. +1 −3 includes/mkDerivedConstants.c
  49. +20 −0 includes/rts/Adjustor.h
  50. 0 includes/{ → rts}/Bytecodes.h
  51. +36 −0 includes/rts/Config.h
  52. +3 −3 includes/{ → rts}/Constants.h
  53. +3 −3 includes/{ → rts}/EventLogFormat.h
  54. +5 −2 includes/{ → rts}/FileLock.h
  55. +239 −0 includes/rts/Flags.h
  56. +3 −6 includes/{RtsGlobals.h → rts/Globals.h}
  57. +5 −0 includes/{ → rts}/Hooks.h
  58. +32 −0 includes/rts/Hpc.h
  59. +39 −0 includes/rts/IOManager.h
  60. +3 −5 includes/{ → rts}/Linker.h
  61. +14 −13 includes/{RtsMessages.h → rts/Messages.h}
  62. +12 −4 includes/{ → rts}/OSThreads.h
  63. +14 −0 includes/rts/Parallel.h
  64. +7 −4 includes/{ → rts}/Signals.h
  65. +3 −3 includes/{ → rts}/SpinLock.h
  66. +35 −0 includes/rts/Stable.h
  67. +26 −6 includes/{SchedAPI.h → rts/Threads.h}
  68. +15 −0 includes/rts/Timer.h
  69. +3 −5 includes/{RtsTypes.h → rts/Types.h}
  70. +3 −3 includes/{StgProf.h → rts/prof/CCS.h}
  71. +3 −2 includes/{StgLdvProf.h → rts/prof/LDV.h}
  72. +3 −3 includes/{ → rts/storage}/Block.h
  73. +395 −0 includes/rts/storage/ClosureMacros.h
  74. +3 −3 includes/{ → rts/storage}/ClosureTypes.h
  75. +10 −10 includes/{ → rts/storage}/Closures.h
  76. +5 −3 includes/{StgFun.h → rts/storage/FunTypes.h}
  77. +204 −0 includes/rts/storage/GC.h
  78. +10 −13 includes/{ → rts/storage}/InfoTables.h
  79. +3 −3 includes/{ → rts/storage}/Liveness.h
  80. +4 −6 {rts/sm → includes/rts/storage}/MBlock.h
  81. +3 −3 includes/{ → rts/storage}/SMPClosureOps.h
  82. +8 −31 includes/{ → rts/storage}/TSO.h
  83. 0 includes/{StgDLL.h → stg/DLL.h}
  84. 0 includes/{ → stg}/MachRegs.h
  85. +1 −3 includes/{StgMiscClosures.h → stg/MiscClosures.h}
  86. +0 −5 includes/{ → stg}/Regs.h
  87. +8 −21 includes/{ → stg}/SMP.h
  88. 0 includes/{ → stg}/TailCalls.h
  89. +2 −2 includes/{TickyCounters.h → stg/Ticky.h}
  90. +11 −37 includes/{StgTypes.h → stg/Types.h}
  91. +2 −2 rts/Adjustor.c
  92. +2 −2 rts/Arena.c
  93. +1 −1 rts/AwaitEvent.h
  94. +8 −9 rts/Capability.c
  95. +13 −18 rts/Capability.h
  96. +2 −4 rts/Disassembler.c
  97. +1 −2 rts/FrontPanel.c
  98. +4 −1 rts/Globals.c
  99. +19 −0 rts/Globals.h
  100. +1 −1 rts/Hash.c
  101. +7 −6 rts/Hpc.c
  102. +0 −10 rts/Hpc.h
  103. +3 −0 rts/HsFFI.c
  104. +1 −0 rts/Inlines.c
  105. +6 −7 rts/Interpreter.c
  106. +2 −2 rts/LdvProfile.c
  107. +10 −19 rts/Linker.c
  108. +1 −0 rts/Main.c
  109. +3 −3 rts/Papi.c
  110. +5 −0 rts/Papi.h
  111. +3 −2 rts/PosixSource.h
  112. +13 −16 rts/Printer.c
  113. +2 −2 rts/Printer.h
  114. +7 −7 rts/ProfHeap.c
  115. +0 −1 rts/ProfHeap.h
  116. +1 −3 rts/Profiling.c
  117. +8 −3 rts/Proftimer.c
  118. +3 −0 rts/Proftimer.h
  119. +3 −3 rts/RaiseAsync.c
  120. +2 −1 rts/RetainerProfile.c
  121. +1 −1 rts/RetainerProfile.h
  122. +2 −2 rts/RetainerSet.c
  123. +2 −5 rts/RtsAPI.c
  124. +2 −3 rts/RtsFlags.c
  125. +1 −3 rts/RtsMain.c
  126. +1 −1 rts/RtsMessages.c
  127. +5 −6 rts/RtsSignals.h
  128. +22 −70 rts/RtsStartup.c
  129. +1 −56 rts/RtsUtils.c
  130. +20 −18 rts/RtsUtils.h
  131. +8 −9 rts/STM.c
  132. 0 {includes → rts}/STM.h
  133. +3 −4 rts/Sanity.c
  134. +1 −1 rts/Sanity.h
  135. +11 −24 rts/Schedule.c
  136. +9 −41 rts/Schedule.h
  137. +3 −12 rts/Sparks.c
  138. +5 −6 rts/Stable.c
  139. +34 −0 rts/Stable.h
  140. +4 −15 rts/Stats.c
  141. +0 −1 rts/Stats.h
  142. +1 −3 rts/StgCRun.c
  143. +5 −249 rts/StgPrimFloat.c
  144. +21 −0 rts/StgPrimFloat.h
  145. +5 −11 rts/Task.c
  146. +10 −25 rts/Task.h
  147. +0 −15 rts/ThrIOManager.h
  148. +1 −0 rts/ThreadLabels.c
  149. +3 −3 rts/ThreadLabels.h
  150. +10 −9 rts/ThreadPaused.c
  151. +14 −0 rts/ThreadPaused.h
  152. +1 −3 rts/Threads.c
  153. +0 −7 rts/Threads.h
  154. +1 −1 rts/Ticky.c
  155. +6 −1 rts/Ticky.h
  156. +4 −3 rts/Timer.c
  157. +2 −4 rts/Timer.h
  158. +4 −2 rts/Trace.c
  159. +2 −1 rts/Updates.cmm
  160. +2 −1 rts/{parallel → }/WSDeque.c
  161. 0 rts/{parallel → }/WSDeque.h
  162. +9 −10 rts/Weak.c
  163. +4 −2 rts/Weak.h
  164. +3 −0 rts/eventlog/EventLog.c
  165. +1 −1 rts/eventlog/EventLog.h
  166. +21 −20 rts/ghc.mk
  167. +1 −0 rts/hooks/FlagDefaults.c
  168. +1 −0 rts/hooks/MallocFail.c
  169. +1 −0 rts/hooks/OnExit.c
  170. +1 −0 rts/hooks/OutOfHeap.c
  171. +1 −0 rts/hooks/RtsOpts.c
  172. +1 −0 rts/hooks/StackOverflow.c
  173. +3 −3 rts/parallel/GranSim.c
  174. +3 −2 rts/posix/FileLock.c
  175. +15 −0 rts/posix/FileLock.h
  176. +5 −30 rts/posix/Itimer.c
  177. +0 −5 rts/posix/Itimer.h
  178. +5 −5 rts/posix/OSMem.c
  179. +2 −1 rts/posix/OSThreads.c
  180. +5 −8 rts/posix/Select.c
  181. +4 −13 rts/posix/Select.h
  182. +4 −7 rts/posix/Signals.c
  183. +65 −0 rts/posix/TTY.c
  184. +15 −0 rts/posix/TTY.h
  185. +23 −21 rts/sm/BlockAlloc.c
  186. +7 −5 rts/sm/Compact.c
  187. +3 −3 rts/sm/Compact.h
  188. +3 −3 rts/sm/Evac.c
  189. +6 −0 rts/sm/Evac.h
  190. +11 −13 rts/sm/GC.c
  191. +13 −3 rts/sm/GC.h
  192. +3 −2 rts/sm/GCAux.c
  193. +3 −4 rts/sm/GCThread.h
  194. +4 −1 rts/sm/GCUtils.c
  195. +6 −1 rts/sm/GCUtils.h
  196. +2 −3 rts/sm/MBlock.c
  197. +3 −1 rts/sm/MarkWeak.c
  198. +5 −0 rts/sm/MarkWeak.h
  199. +5 −0 rts/sm/OSMem.h
  200. +0 −11 rts/sm/README
  201. +2 −3 rts/sm/Scav.c
  202. +6 −0 rts/sm/Scav.h
  203. +4 −7 rts/sm/Storage.c
  204. +169 −0 rts/sm/Storage.h
  205. +3 −1 rts/sm/Sweep.c
  206. +6 −1 rts/sm/Sweep.h
  207. +5 −3 rts/win32/AsyncIO.h
  208. +3 −11 rts/win32/ConsoleHandler.h
  209. +4 −3 rts/win32/IOManager.h
  210. +1 −1 rts/win32/ThrIOManager.c
  211. +4 −3 rts/win32/WorkQueue.h
  212. +4 −3 rts/win32/seh_excn.h
  213. +2 −2 utils/genapply/GenApply.hs
@@ -58,7 +58,7 @@ cmmToRawCmm cmm = do
-- <normal forward rest of StgInfoTable>
-- <forward variable part>
--
--- See includes/InfoTables.h
+-- See includes/rts/storage/InfoTables.h
--
-- For return-points these are as follows
--
@@ -56,7 +56,7 @@ import Data.Maybe
-- Temp Jan08
import SMRep
import ClosureInfo
-#include "../includes/StgFun.h"
+#include "../includes/rts/storage/FunTypes.h"
pprCmms :: (Outputable info, Outputable g) => [GenCmm CmmStatic info g] -> SDoc
@@ -64,7 +64,7 @@ import Data.Bits
-------------------------------------------------------------------------
-- bring in ARG_P, ARG_N, etc.
-#include "../includes/StgFun.h"
+#include "../includes/rts/storage/FunTypes.h"
-------------------------
argDescrType :: ArgDescr -> StgHalfWord
@@ -24,9 +24,9 @@ module CgProf (
) where
#include "HsVersions.h"
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
-- For WORD_SIZE_IN_BITS only.
-#include "../includes/Constants.h"
+#include "../includes/rts/Constants.h"
-- For LDV_CREATE_MASK, LDV_STATE_USE
-- which are StgWords
#include "../includes/DerivedConstants.h"
@@ -50,7 +50,7 @@ module CgUtils (
) where
#include "HsVersions.h"
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
import BlockId
import CgMonad
@@ -246,7 +246,7 @@ data SMRep
| BlackHoleRep
data ClosureType -- Corresponds 1-1 with the varieties of closures
- -- implemented by the RTS. Compare with ghc/includes/ClosureTypes.h
+ -- implemented by the RTS. Compare with includes/rts/storage/ClosureTypes.h
= Constr
| ConstrNoCaf
| Fun
@@ -284,7 +284,7 @@ isStaticRep BlackHoleRep = False
\end{code}
\begin{code}
-#include "../includes/ClosureTypes.h"
+#include "../includes/rts/storage/ClosureTypes.h"
-- Defines CONSTR, CONSTR_1_0 etc
-- krc: only called by tickyDynAlloc in CgTicky; return
@@ -313,7 +313,7 @@ mkVirtHeapOffsets is_thunk things
-------------------------------------------------------------------------
-- bring in ARG_P, ARG_N, etc.
-#include "../includes/StgFun.h"
+#include "../includes/rts/storage/FunTypes.h"
-------------------------
-- argDescrType :: ArgDescr -> StgHalfWord
@@ -25,9 +25,9 @@ module StgCmmProf (
) where
#include "HsVersions.h"
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
-- For WORD_SIZE_IN_BITS only.
-#include "../includes/Constants.h"
+#include "../includes/rts/Constants.h"
-- For LDV_CREATE_MASK, LDV_STATE_USE
-- which are StgWords
#include "../includes/DerivedConstants.h"
@@ -44,7 +44,7 @@ module StgCmmUtils (
) where
#include "HsVersions.h"
-#include "MachRegs.h"
+#include "../includes/stg/MachRegs.h"
import StgCmmMonad
import StgCmmClosure
@@ -208,7 +208,7 @@ sizeSS16 :: SizedSeq a -> Word16
sizeSS16 (SizedSeq n _) = fromIntegral n
-- Bring in all the bci_ bytecode constants.
-#include "Bytecodes.h"
+#include "rts/Bytecodes.h"
largeArgInstr :: Word16 -> Word16
largeArgInstr bci = bci_FLAG_LARGE_ARGS .|. bci
@@ -84,7 +84,7 @@ mkITbl tc
dcs = tyConDataCons tc
n = tyConFamilySize tc
-#include "../includes/ClosureTypes.h"
+#include "../includes/rts/storage/ClosureTypes.h"
cONSTR :: Int -- Defined in ClosureTypes.h
cONSTR = CONSTR
@@ -151,7 +151,7 @@ ptrToInt (Ptr a#) = I# (addr2Int# a#)
#if sparc_TARGET_ARCH
-- After some consideration, we'll try this, where
-- 0x55555555 stands in for the address to jump to.
--- According to ghc/includes/MachRegs.h, %g3 is very
+-- According to includes/rts/MachRegs.h, %g3 is very
-- likely indeed to be baggable.
--
-- 0000 07155555 sethi %hi(0x55555555), %g3
@@ -165,7 +165,7 @@ data Closure = Closure { tipe :: ClosureType
instance Outputable ClosureType where
ppr = text . show
-#include "../includes/ClosureTypes.h"
+#include "../includes/rts/storage/ClosureTypes.h"
aP_CODE, pAP_CODE :: Int
aP_CODE = AP
@@ -206,7 +206,7 @@ initBinMemSize :: Int
initBinMemSize = 1024 * 1024
-- The *host* architecture version:
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
binaryInterfaceMagic :: Word32
#if WORD_SIZE_IN_BITS == 32
@@ -14,8 +14,8 @@ import Data.Bits (shiftL)
-- be in trouble.
#include "HsVersions.h"
-#include "../includes/MachRegs.h"
-#include "../includes/Constants.h"
+#include "../includes/stg/MachRegs.h"
+#include "../includes/rts/Constants.h"
#include "../includes/MachDeps.h"
#include "../includes/DerivedConstants.h"
@@ -275,7 +275,7 @@ opt_Unregisterised = lookUp (fsLit "-funregisterised")
-- Derived, not a real option. Determines whether we will be compiling
-- info tables that reside just before the entry code, or with an
-- indirection to the entry code. See TABLES_NEXT_TO_CODE in
--- includes/InfoTables.h.
+-- includes/rts/storage/InfoTables.h.
tablesNextToCode :: Bool
tablesNextToCode = not opt_Unregisterised
&& cGhcEnableTablesNextToCode == "YES"
@@ -21,7 +21,7 @@ where
{-
#include "nativeGen/NCG.h"
#include "HsVersions.h"
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
import RegsBase
@@ -22,7 +22,7 @@ where
#include "HsVersions.h"
#include "nativeGen/NCG.h"
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
-- NCG stuff:
import PPC.Instr
@@ -49,7 +49,7 @@ where
#include "nativeGen/NCG.h"
#include "HsVersions.h"
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
import Reg
import RegClass
@@ -43,7 +43,7 @@ import FastTypes
-- There is an allocatableRegsInClass :: RegClass -> Int, but doing the unboxing
-- is too slow for us here.
--
--- Look at includes/MachRegs.h to get these numbers.
+-- Look at includes/stg/MachRegs.h to get these numbers.
--
#if i386_TARGET_ARCH
@@ -115,7 +115,7 @@ import Data.Maybe
import Data.List
import Control.Monad
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
-- -----------------------------------------------------------------------------
@@ -15,7 +15,7 @@ where
#include "HsVersions.h"
#include "nativeGen/NCG.h"
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
-- NCG stuff:
import SPARC.CodeGen.Sanity
@@ -93,7 +93,7 @@ import FastBool
#define f31 63
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
-- | Check whether a machine register is free for allocation.
freeReg :: RegNo -> FastBool
@@ -54,7 +54,7 @@ import FastBool
prepared for any eventuality.
The whole fp-register pairing thing on sparcs is a huge nuisance. See
- fptools/ghc/includes/MachRegs.h for a description of what's going on
+ includes/stg/MachRegs.h for a description of what's going on
here.
-}
@@ -290,11 +290,13 @@ regDotColor reg
-- Hard coded freeReg / globalRegMaybe -----------------------------------------
-- This isn't being used at the moment because we're generating
--- these functions from the information in includes/MachRegs.hs via RegPlate.hs
+-- these functions from the information in
+-- includes/stg/MachRegs.hs via RegPlate.hs
-- | Check whether a machine register is free for allocation.
--- This needs to match the info in includes/MachRegs.h otherwise modules
--- compiled with the NCG won't be compatible with via-C ones.
+-- This needs to match the info in includes/stg/MachRegs.h
+-- otherwise modules compiled with the NCG won't be compatible
+-- with via-C ones.
--
{-
freeReg :: RegNo -> FastBool
@@ -27,7 +27,7 @@ where
#include "HsVersions.h"
#include "nativeGen/NCG.h"
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
-- NCG stuff:
import X86.Instr
@@ -466,7 +466,7 @@ pprDataItem lit
-- all such offsets will fit into 32 bits, so we have to stick
-- to 32-bit offset fields and modify the RTS appropriately
--
- -- See Note [x86-64-relative] in includes/InfoTables.h
+ -- See Note [x86-64-relative] in includes/rts/storage/InfoTables.h
--
ppr_item II64 x
| isRelativeReloc x =
@@ -54,7 +54,7 @@ where
-- HACK: go for the max
#endif
-#include "../includes/MachRegs.h"
+#include "../includes/stg/MachRegs.h"
import Reg
import RegClass
@@ -4,7 +4,9 @@ places in the GHC library.
*/
#include "Rts.h"
+#if __GLASGOW_HASKELL__ <= 610
#include "RtsFlags.h"
+#endif
#include "HsFFI.h"
@@ -20,19 +22,19 @@ and causes gcc to require too many registers on x84
*/
HsInt
-ghc_strlen( HsAddr a )
+ghc_strlen( HsPtr a )
{
return (strlen((char *)a));
}
HsInt
-ghc_memcmp( HsAddr a1, HsAddr a2, HsInt len )
+ghc_memcmp( HsPtr a1, HsPtr a2, HsInt len )
{
return (memcmp((char *)a1, a2, len));
}
HsInt
-ghc_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len )
+ghc_memcmp_off( HsPtr a1, HsInt i, HsPtr a2, HsInt len )
{
return (memcmp((char *)a1 + i, a2, len));
}
@@ -59,7 +59,7 @@ module Binary
#include "HsVersions.h"
-- The *host* architecture version:
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
import {-# SOURCE #-} Name (Name)
import FastString
@@ -19,7 +19,7 @@ module FastMutInt(
#ifdef __GLASGOW_HASKELL__
-#include "MachDeps.h"
+#include "../includes/MachDeps.h"
#ifndef SIZEOF_HSINT
#define SIZEOF_HSINT INT_SIZE_IN_BYTES
#endif
Oops, something went wrong.

0 comments on commit a2a67cd

Please sign in to comment.