| Version 1 (modified by simonmar, 7 years ago) |
|---|
GHC Source Tree Roadmap: rts/
This directory contains the source code for the runtime system.
There are three types of files:
- .h
- Header files that are private to the RTS. That is, header files in this directory are not shipped with GHC, and APIs they define are therefore intended to be private and not usable by client code (in practice, we do not and probably cannot enforce this). Header files that we do ship with GHC are in the includes directory.
- .c
- C source code for the runtime system. Conventions used in this code are described in Commentary/Rts/Conventions.
- .cmm
- C-- code for parts of the runtime that are part of the Haskell execution environment: for example, the implementation of primitives, exceptions, and so on. A .cmm file is pseudo C--: more or less C-- syntax with some omissions and some additional macro-like extensions implemented by GHC. The .cmm files are compiled using GHC itself: see Commentary/Compiler/CmmFiles?.
Subdirectories of rts/
- posix/
- win32/
- POSIX and Win32-specific parts of the runtime respectively. We try to put platform-specific stuff in these directories, however not all of the RTS follows this convention right now.
- hooks/
- Hooks for changing the RTS behaviour from client code, eg. changing the default heap size. (see User's Guide for more about hooks).
Haskell Execution
All this code runs on the Haskell side of the Haskell/C divide; StgCRun is the interface between the two layers.
- Apply.cmm, AutoApply.h, AutoApply.cmm, Apply.h
- The eval/apply machinery. Note: AutoApply.cmm is the family of functions for performing generic application of unknown functions, this code depends on the number of registers available for argument passing, so it is generated automatically by the program genapply in utils/genapply.
- Exception.cmm
- Support for execptions.
- HeapStackCheck.cmm
- Code for preparing the stack when the current Haskell thread needs to return to the RTS, because we either ran out of heap or stack, or need to block (eg. takeMVar), or yield.
- PrimOps.cmm
- Implementation of out-of-line primitives (see Commentary/PrimOps).
- StgMiscClosures.cmm
- Some built-in closures, such as the family of small Ints and Chars, and some built-in info tables such as BLACKHOLE and ARR_WORDS.
- StgStartup.cmm
- Code that executes when a Haskell thread begins and ends.
- StgStdThunks.cmm
- Some built-in thunks: Commentary/Rts/SelectorThunks? and "apply" thunks.
- HCIncludes.h
- Header file included when compiling .cmm files via C.
- StgPrimFloat.c
- Floating-point stuff.
- STM.c
- Implementation of Software Transactional Memory.
The Storage Manager?
- BlockAlloc.c, BlockAlloc.h
- The low-level block allocator, requires only MBlock.
- ClosureFlags.c
- Determining properties of various types of closures.
- GC.c
- The generational copying garbage collector.
- GCCompact.c, GCCompact.h
- The compacting garbage collector.
- MBlock.c, MBlock.h, OSMem.h
- The "megablock" allocator; this is the thin layer between the RTS and the operating system for allocating memory.
- Stable.c
- Stable names and stable pointers.
- Storage.c
- Top-level of the storage manager.
The Scheduler
- Capability.c, Capability.h
- Capabilities: virtual CPUs for executing Haskell code.
- RaiseAsync.c, RaiseAsync.h
- Asynchronous exceptions.
- Schedule.c, Schedule.h
- The scheduler itself.
- ThreadLabels.c, ThreadLabels.h
- Labelling threads.
- AwaitEvent.h
- Waiting for events (non-threaded RTS only).
C files: the Commentary/Rts/FFI
- Adjustor.c
- Very hairy support for foreign import "wrapper".
The Byte-code Interpreter
- Disassembler.c, Disassembler.h
- Interpreter.c, Interpreter.h
- The byte-code interpreter and disassembler.
Profiling
- LdvProfile.c, LdvProfile.h
- Lag-drag-void profiling (also known as Biographical Profiling).
- ProfHeap.c, ProfHeap.h
- Generic heap-profilng support.
- Profiling.c, Profiling.h
- Generic profilng support.
- Proftimer.c, Proftimer.h
- The profiling timer.
- RetainerProfile.c, RetainerProfile.h
- RetainerSet.c, RetainerSet.h
- Retainer profiling.
RTS Debugging
The Front Panel
The front panel is currently defunct. It offers a graphical view of the running Haskell program in real time, and was pretty cool when it worked.
- FrontPanel.c, FrontPanel.h
- VisCallbacks.c, VisCallbacks.h
- VisSupport.c, VisSupport.h
- VisWindow.c, VisWindow.h
Other
- Main.c
- The C main() function for a standalone Haskell program; basically this is just a client of HsFFI.h.
- RtsFlags.c
- Understands the +RTS ... -RTS flags.
- RtsMessages.c
- Support for emitting messages from the runtime.
- RtsSignals.c, RtsSignals.h
- Signal-related stuff.
Miscellaneous stuff:
OLD stuff
- parallel/
- Code for GUM: parallel GHC. This is heavily bitrotted and currently doesn't work (as of GHC 6.6; it last worked around 5.02 I believe).
- dotnet/
- Bitrotted code for GHC.NET.
