Professional Documents
Culture Documents
Takenobu T.
Rev. 0.01.0
WIP
Arthur C. Clarke
NOTE
- This is not an official document by the ghc development team.
- Please don't forget semantics. It's very important.
- This is written for ghc 7.8 (and ghc 7.10).
Contents
- Executable binary
- Compile steps
- Runtime System
- Development languages
- Machine layer/models
- STG-machine
- Heap objects in STG-machine
- STG-machine evaluation
- Pointer tagging
- Thunk and update
- Allocate and free heap objects
- STG - C land interface
- Thread
- Thread context switch
- Creating main and sub threads
- Thread migration
- Heap and Threads
- Threads and GC
- Bound thread
- Spark
- Mvar
- Software transactional memory
- FFI
- IO and FFI
- IO manager
- Bootstrap
- References
Executable binary
GHC (compile)
object (.o)
RuntimeSystem
(libHsRts.o)
libraries
(GHC.Base, ...)
GHC (link)
Executable
binary
Compile steps
GHC
compile
steps
Core language
STG language
Cmm language
Assembly language
(native or llvm)
% ghc -ddump-ds
% ghc -ddump-simpl
% ghc -ddump-prep
% ghc -ddump-stg
% ghc -ddump-cmm
% ghc -ddump-opt-cmm
% ghc -ddump-llvm
% ghc -ddump-asm
References : [1], [C3], [C4], [9], [C5], [C6], [C7], [C8[], [S7], [S8]
Runtime System
software
hardware
Library
OS
(Linux, FreeBSD, Win, ...)
Physical Processor
(x86, ARM, ...)
Storage Manager
Byte-code interpreter
Software
Transactional Memory
User space
Scheduler
Profiling
...
Development languages
runtime system
( $(TOP)/compiler/*)
( $(TOP)/rts/*)
Haskell
+
Alex (lex)
Happy (yacc)
Cmm (C--)
Assembly
C
+
Cmm
Assembly
library
( $(TOP)/libraries/*)
Haskell
+
C
References : [C2]
Machine layer/models
Machine layer
STG-machine
(Abstract machine)
Physical Processor
(x86, ARM, ...)
Machine layer
STG Registers
STG-machine
(Abstract machine)
Stack
Heap
Static region
Heap
Static region
BaseReg
R1
Hp
Sp
:
Register table
BaseReg
R1
Hp
:
Registers
Physical Processor
(x86, ARM, ...)
Memory
ebx
esi
edi
ebp
:
user code
runtime system
HECs
user space
Runtime System
OS Threads
(native threads, kernel threads)
OS Process
OS
OS
(Linux, FreeBSD, Win, ...)
supervisor
space
(kernel space)
hardware
Physical Processor
(x86, ARM, ...)
References : [C14], [C6], [2], [C17], [8], [S15], [S16], [S11]
many HECs
Multi HECs can be generated by compile and runtime options :
$ ghc -rtsopts -threaded
$ ./xxx +RTS -N4
HEC
(Capability,
Virtual processor)
Task
(Worker Thread)
HEC
HEC
HEC
HEC
Tasks
(abstract OS Thread)
OS Threads
OS Process
software
hardware
OS
(Linux, FreeBSD, Win, ...)
Physical Processor
(x86, ARM, ...)
References : [1], [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14]
#if defined(THREADED_RTS)
Task *spare_workers;
nat n_spare_workers;
Mutex lock;
Task *returning_tasks_hd;
Task *returning_tasks_tl;
Message *inbox;
SparkPool *sparks;
SparkCounters spark_stats;
#endif
W_ total_allocated;
StgTVarWatchQueue *free_tvar_watch_queues;
StgInvariantCheckQueue *free_invariant_check_queues;
StgTRecChunk *free_trec_chunks;
StgTRecHeader *free_trec_headers;
nat transaction_tokens;
Each HEC (Capability) has a register table and a run queue and ...
Each HEC (Capability) is initialized at initCapabilities [rts/Capability.c]
References : [S15], [S16], [C11], [C17]
STG-machine
BaseReg
R1
Hp
HpLim
Sp
SpLim
Stack
Sp
grows downwards
SpLim
Heap
HpLim
Hp
grows upwards
STG Registers
physical view
physical register
(x86 example)
Register table
BaseReg
R1
Hp
Sp
ebx
esi
edi
ebp
ebx
esi
edi
...
physical view
Heap memory
Stack
TSO
Thread State Object
Heap
Stack
References : [S5]
header
payload
info ptr
info table
meta data
entry code
payload
info ptr
physical view
heap memory
payload1
payload0
info ptr
info table
static memory
entry code
info table
entry code
7 :: Int
payload
header
'a'
I#
GHC.Types.C#_static_info
layout : 0_1
type : CONSTR
bitmap :
inc %esi
jmp *0x0(%ebp)
info
ptr
payload
#7
GHC.Types.I#_static_info
info table
layout : 0_1
type : CONSTR
bitmap :
info table
entry code
inc %esi
jmp *0x0(%ebp)
entry code
Example.value1 :: GHC.Types.Int
[GblId, Caf=NoCafRefs, Str=DmdType m, Unf=OtherCon []] =
NO_CCS GHC.Types.I#! [8];
Cmm
[ghc -O -ddump-asm
Example.hs]
.data
asm
.align 4
.align 1
.globl __stginit_main:Example
__stginit_main:Example:
.data
.align 4
.align 1
.globl Example.value1_closure
Example.value1_closure:
.long GHC.Types.I#_static_info
.long 7
.section .data
header
.align 4
I#
.align 1
SMd_srt:
payload
#7
payload
header
Just
info
ptr
I#
Data.Maybe.Just_static_info
layout :
type : CONSTR
bitmap :
add
jmp
info table
info
ptr
payload
#7
GHC.Types.I#_static_info
layout :
type : CONSTR
bitmap :
info table
inc %esi
entry code
jmp *0x0(%ebp)
GHC.Types.[]_closure
payload
I#
Cons
GHC.Types.:_static_info
layout :
type : CONSTR
bitmap :
add
jmp
$0x2,%esi
*0x0(%ebp)
Nil
I#
GHC.Types.[]_static_info
layout :
type : CONSTR
bitmap :
inc %esi
jmp *0x0(%ebp)
header
payload
reserved
info
ptr
I#
payload
#7
info
ptr
info table
type : THUNK
info table
type : CONSTR
STG-machine evaluation
stack
Sp
continuation
stack
current
expression
R1
(1)
push a continuation code
(next code) to the stack
top
(2)
enter to R1 closure
jump
a value
Sp
continuation
R1
(3)
set a result to R1
(4)
jump (return)
to the stack top code
(5)
repeat from (1)
Enter to a closure
unevaluated closure
R1
(1) read R1
to get a closure address
(2) read header(info ptr)
to get a Entry code address
(3) jump to the Entry code address
header
payload
info
ptr
layout
closure type
...
if ((Sp + -12) < SpLim)
goto c3h9;
else goto c3ha;
:
Info table
Entry code
Pointer tagging
Pointer tagging
header
(info ptr)
pointer
payload
R1 or ...
pointer
00
01
10
11
fast judgment!
check only pointer's lower bits without evaluating the closure.
References : [4], [2], [C16]
header
Thunk
info
ptr
type : THUNK
(empty)
I#
#7
evaluate ( x + 1 )
x+1
Thunk
info
ptr
(empty)
type : THUNK
x+1
I#
#7
I#
#8
update
Ind (indirect)
info
ptr
type : THUNK
x+1
lock free
I#
#7
I#
#8
type : IND
GC (eliminate Indirect)
HpLim
Hp
allocate
(without malloc)
HpLim
Hp
can't allocate
because full
HpLim
Hp
References : [C11], [C13], [8], [9], [5], [15], [12], [13], [19], [S25]
HpLim
copying
collection
(minor GC)
from space
to space
References : [C11], [C13], [8], [9], [5], [15], [12], [13], [19], [S25]
User code
R1
STG land
(Haskell land)
C land
RtsAPI
StgRun
StgReturn
result
function f
BaseReg
Runtime System
(Scheduler)
Thread
HEC
(Capability,
Virtual processor)
exclusive execution
...
HEC
user space
OS Thread
OS Process
OS
software
hardware
Physical Processor
supervisor
space
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14]
Haskell Threads
Haskell
Threads
HEC
(Capability,
Virtual processor)
...
...
HEC
HEC
user space
OS Thread
OS Thread
OS Process
software
hardware
supervisor
space
OS
(Linux, FreeBSD, Win, ...)
Physical Processor
Physical Processor
Thread
states
Thread #0
Thread #1
Registers
Registers
Registers
Stack
Stack
Stack
load
state
STG-machine
Registers
Stack
Thread #2
...
interleaved
exclusive execution
save
state
execution and
pre-empted via the context switch
heap
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14]
Thread
states
Thread #0
Thread #1
Registers
Registers
Stack
load
state
STG-machine
Stack
save
state
physical view
Thread #2
heap memory
Registers
Stack
...
TSO #0
(Thread State
Object)
TSO #1
(Thread State
Object)
Registers
Stack
TSO #2
(Thread State
Object)
heap
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14]
Registers
Stack
STG land
(Haskell land)
StgRun
C land
StgReturn
Scheduler
run queue
popRunQueue
appendToRunQueue
round robin
...
heap
TSO
TSO
...
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14]
heap
heap
HpLim
-> 0
RTS
Interrupt
TSO
(4) call GC
TSO
GC
Scheduler
(7) scheduling
STG land
(Haskell land)
C land
cap->r.rHpLim = NULL;
stopCapability
stg_returnToSched
W_ r1;
r1 = R1; // foreign calls may clobber R1
SAVE_THREAD_STATE();
foreign "C" threadPaused(MyCapability()
"ptr", CurrentTSO);
R1 = r1;
jump StgReturn [R1];
schedule
contextSwitchCapability
contextSwitchAllCapabilities
handle_tick
next
handle_tick ..
CreateTimerQueue
initTicker
initTimer
startTimer
hs_init_ghc
real_main
OS
*Windows case
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14], [S24]
scheduler
run queue
(5)
(1)
TSO
heap memory
(2)
stack
(3)
*stackobj
closure
(4)
static memory
ZCMain_main_closure
header
payload
info table
entry code
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14], [S24]
User code
Runtime System
append
(5)
scheduler
run queue
(1)
TSO
heap memory
forked closure
(2)
*stackobj
(3)
stack
(4)
header
payload
closure
info table
static memory
entry code
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14], [S24]
Thread migration
Haskell
Threads
Idle HEC
run queue
Idle HEC
run queue
run queue
Idle HEC
run queue
empty
empty
empty
HEC
HEC
HEC
HEC
OS Thread
OS Thread
OS Thread
OS Thread
Physical Processor
Physical Processor
Work pushing
OS Process
hardware
Physical Processor
Physical Processor
References : [5], [8], [9], [14], [C17], [C18], [S17], [S16], [S23], [S24]
Registers
Registers
Stack
Stack
...
Registers
Registers
Stack
Stack
...
hardware
HEC
HEC
Physical Processor
Physical Processor
References : [5], [8], [9], [14], [C17], [C11], [19], [S17], [S16], [S23], [S22], [S14], [S17], [S16], [S25]
heap memory
(shared)
Registers
Registers
Stack
Stack
Registers
Stack
Stack
nursery
...
nursery
generation N
static memory
(shared)
hardware
...
Registers
static memory
HEC
HEC
Physical Processor
Physical Processor
Threads and GC
STG land
(Haskell land)
Runtime System
allocate
generation 0, step 0
Hp
nursery
HEC
nursery
aging
HEC
nursery
HEC
nursery
HEC
generation 0, step 1
promotion
generation 1
heap memory
References : [8], [9], [15], [C13], [C11], [S25]
GC thread
GC thread
GC thread
GC thread
nursery
nursery
nursery
nursery
generation 0, step 1
heap
generation 1
HEC
HEC
HEC
HEC
Physical Processor
Physical Processor
Physical Processor
Physical Processor
GC thread
GC thread
GC thread
GC thread
nursery
nursery
nursery
nursery
generation 0, step 1
heap
generation 1
HEC
HEC
HEC
HEC
Physical Processor
Physical Processor
Physical Processor
Physical Processor
closure
TSO
TSO
closure
stack
TSO
closure
GC aging or promote
unreachable
(garbage)
free
References : [8], [9], [15], [C13], [C11], [S25]
Bound thread
Haskell
Threads
HEC
(Capability,
Virtual processor)
fixed association
for safe foreign calls
HEC
OS Thread
OS Thread
OS Process
Foreign calls from a bound thread are all made by the same OS thread.
A bound thread is created using forkOS.
References : [6], [5], [8], [9], [14], [C17], [19], [S17], [S16], [S23], [S22]
forkIO
forkOS
forkOn
Bound
Threads
Haskell
Threads
affinity
bound
HEC
HEC
HEC
OS Thread
OS Thread
OS Thread
OS Thread
References : [6], [5], [8], [9], [14], [C17], [19], [S17], [S16], [S23], [S22]
Spark
Spark layer
serial execution on each Spark Threads
Sparks
Haskell
Thread
HEC
(Capability,
Virtual processor)
...
Spark Thread
HEC
user space
OS Thread
OS Process
OS
software
hardware
Physical Processor
supervisor
space
Spark
Spark
Spark
Spark Thread
Spark Thread
Spark Thread
Spark Thread
HEC
HEC
HEC
HEC
Physical Processor
Physical Processor
Physical Processor
Physical Processor
Spark pool
rpar
Spark
(Thunk)
References : [C17], [19], [S17], [S26], [S27], [S33], [S12]
Spark
Spark Thread
Spark
Spark Thread
Spark
Spark Thread
Spark Thread
Spark pool
Spark pool
Work stealing
HEC
Spark pool
Spark pool
STG land
(Haskell land)
getSpark
C land
Spark pool
(WSDeque)
HEC
rpar
push
...
heap
closure
(thunk)
closure
(thunk)
...
MVar
MVar
Haskell Thread #0
Haskell Thread #1
putMVar
takeMVar
empty?
or
full?
MVar
Haskell Thread
putMVar
BLOCKED
if full
takeMVar
full
empty
MVar
MVar
BLOCKED
if empty
MVar example
Haskell Thread #0
Haskell Thread #1
(3)
takeMVar
(2)
(1)
putMVar
MVar
time
Thread #0
Running
Blocked
Non Blocked
takeMVar
(1)
MVar
Running
empty
full
putMVar
empty
(2)
Running
Thread #1
* single core case
heap
MVar
empty?
or
full?
StgReturn
chain
of
StgMVarTSOQueue
head
tail
head
tail
value
closure
value
StgMVarTSOQueue
StgMVarTSOQueue
TSO
TSO
newEmptyMVar
Haskell Threads
newEmptyMVar
newMVar#
(1) call the Runtime premitive
Runtime System
stg_newMVarzh
ALLOC_PRIM_
SET_HDR
StgMVar_head
StgMVar_tail
StgMVar_value
heap
stg_END_TSO_QUEUE_closure
head
tail
value
(3) link each fields
Runtime System
stg_takeMVarzh
create StgMVarTSOQueue (1)
append
(2)
StgReturn (3)
(1) create
chain of
StgMVarTSOQueue
head
StgMVarTSOQueue
(2) append
tail
value
MVar object
References : [16], [18], [19], [S31], [S12]
Runtime System
stg_takeMVarzh
(1) get value
(2) set empty
(3) remove head
(4) tryWakeupThread
scheduler
run queue
tail
value
MVar object
References : [16], [18], [19], [S31], [S12]
TVar
readTVar
TVar
transactional
variable
STM a
writeTVar
retry :: STM a
readTVar
TVar
TVar
STM a
STM a
A
orElse ::
STM a
result
if retry A
or
B
if not retry A
A or B or Nothing
References : [17], [19], [20], [C18], [S12], [S28]
TVar
TVar
time
Thread #0
writeTVar
writeTVar writeTVar
commit
TVar #A
old value
new value
TVar #B
old value
new value
atomic update
atomic block
rollback and
try again
atomic block
time
Thread #0
commit
old value
TVar #A
TVar #B
commit
old value
new value
other value
new value
commit
other thread
different
retry example
atomic block
retry
atomic block
time
blocked
Thread #0
wake up
TVar #A
TVar #B
commit
old value
new value
old value
changed value
new value
commit
other thread
newTVar
StgTVar
StgTVar
writeTVar
readTVar
StgTVarWatchQueue
CurrentTSO
StgTVarWatchQueue
TRecEntry
TRecEntry
StgTRecHeader
StgTRecChunk
atomically
StgInvariantCheckQueue
writeTVar
readTVar
or
Runtime System
TRecEntry
(transaction
Record)
TRecEntry
TRecEntry
invariant check
when commit
TVar
StgTVar
heap
retry :: STM a
Runtime System
TSO
StgTVar
(4) commit
(1) retry
(3)yield
scheduler
run queue
WatchQueue
TVar
(4) commit
(2) append
(5)append
wakeup
FFI
ccall
STG land
(Haskell land)
foreign
out-call
StgReturn
Stg interface
C land
FFI
foreign
in-call
StgRun
Scheduler
FFI management
user space
Runtime system
Foreign
C code
OS API (system call)
OS
supervisor
space
(4)
Haskell
Threads
non-blocked
(2)
(1)
HEC
HEC
(5)
Foreign
C code
OS Thread
Physical Processor
HEC
Foreign
C code
(3)
OS Thread
OS Thread
Physical Processor
releaseCapability_
giveCapabilityToTask
startWorkerTask
createOSThread
(3)
non-blocked
Haskell
Threads
(3)
waitForReturnCapability
(1)
(2)
(4)
(1)
HEC
HEC
(4)
Foreign
C code
(2)
OS Thread
OS Thread
Physical Processor
Haskell
Threads
blocking
safe
foreign call
blocked
Haskell
Threads
HEC
HEC
Foreign
C code
blocking
unsafe
foreign call
HEC
Foreign
C code
OS Thread
OS Thread
Physical Processor
OS Thread
Physical Processor
faster,
but blocking to the other Haskell threads
unbound
thread
non-blocked
ccall
an unbound
thread
HEC #0
Processor #0
non-blocked
blocked
ccall
HEC #1
HEC #1
HEC #0
Foreign
C code
OS Thread
unbound
thread
OS Thread
Foreign
C code
OS Thread
Processor #1
non-blocked
HEC #1
bound
thread
OS Thread
OS Thread
Processor #0
Processor #1
non-blocked
blocked
ccall
a bound
thread
HEC #0
HEC #1
HEC #1
ccall
HEC #0
HEC #1
Foreign
C code
OS Thread
Processor #0
OS Thread
OS Thread
Processor #1
bound
thread
HEC #1
Foreign
C code
OS Thread
Processor #0
OS Thread
OS Thread
Processor #1
IO and FFI
IO
Haskell Thread
getLine (IO)
IO String
IO example: getLine
getLine
IO String
standard IO lib
STG land
(Haskell land)
c_read
C land
user
space
C IO lib (libio.a)
read system call
OS API (system call)
supervisor
space
OS
Device driver
Hardware
UART, serial, ...
getLine
hGetLine
hGetLineBuffered
hGetLineBufferedLoop
maybeFillReadBuffer
getSomeCharacters
readTextDevice
Library
Buffered.fillReadBuffer
readBuf
readBuf
RawIO.read
STG land
(Haskell land)
fdRead
readRawBufferPtr
c_read
switch safe/unsafe,
non-threaded/ioManager
C land
read
Runtime
System
OS
References : [6], [11], [20], [S39], [S38], [S37], [S36], [S40]
IO manager
Haskell Threads
IO manager
dispatcher thread
HEC
HEC
OS Thread
OS Thread
affinity
user space
OS Process
software
hardware
OS
(Linux, FreeBSD, Win, ...)
supervisor
space
Physical Processor
(x86, ARM, ...)
Haskell
Threads
Haskell
Threads
IO manager
dispatcher
thread
IO manager
dispatcher
thread
HEC
HEC
HEC
HEC
OS Thread
OS Thread
OS Thread
OS Thread
user space
OS Process
OS
software
hardware
supervisor
space
Physical Processor
Physical Processor
IO manager
Haskell Threads
IO manager
event table
blocking IO
registerFD
event
loop
request and
set callback (MVar)
IO access
(epoll, kqueue)
takeMVar
(wait and wake up)
putMVar
HEC
HEC
OS Thread
OS Thread
OS Process
system call
References : [7], [5], [8], [S29], [S30], [S32], [S37], [S35], [S3]
Bootstrap
Bootstrap sequence
ZCMain_main_closure
User
code
stg_ap_v_info
stg_enter_info
loadThreadState
emitLoadThreadState
STG land
(Haskell land)
stg_returnToStackTop
StgRun
schedule
C land
scheduleWaitThread
main
createIOThread
createThread, pushClosure
rts_evalLazyIO
hs_init_ghc
initScheduler, initStorage, initTimer, ioManagerStart, ...
real_main
hs_main
Runtime
System
(lib/libHSrts.a)
mainCRTStartup
(*Windows case)
OS
References : [S7], [S13], [S14], [S17], [S18], [S19], [S9], [S10], [S21], [S41]
Exit sequence
User
code
STG land
(Haskell land)
stg_stop_thread_info
StgReturn
C land
Runtime
System
(lib/libHSrts.a)
schedule
shutdownHaskellAndExit
stg_exit
exit
OS
References : [S19], [S18], [S17]
Initializing
STG land
(Haskell land)
startIOManagerThread
startIOManagerThreads
ensureIOManagerIsRunning
ioManagerStart
C land
initTimer, startTimer
create Timer
initGcThreads
allocNurseries
storageAddCapabilities
initGeneration
initStorage
createOSThread
newTask
startWorkerTask
startWorkerTasks
initScheduler
initCapabilities
Runtime
System
hs_init_ghc
real_main
hs_main
main
OS
References : [1], [S7], [S13], [S14], [S17], [S15], [S16], [S24], [S21], [S34]
Runtime
system
Haskell threads
OS Threads
software
hardware
newSpark
forkIO
forkOn
forkOS
stg_forkzh, createThread
stg_forkOnzh, createThread
forkOS_createThread
OS Process
OS API
initCapaility
OS
rpar
HECs
Tasks
Runtime system
forkOS
newTask
forkOS
createOSThread
pthread_create
fork
OS
(Linux, FreeBSD, Win, ...)
Physical Processor
(x86, ARM, ...)
References : [1], [5], [8], [9], [C11], [C17], [S12], [S26], [S22], [S15], [S23]
References
References
[1]
[2]
Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine Version 2.5
http://research.microsoft.com/en-us/um/people/simonpj/Papers/spineless-tagless-gmachine.ps.gz
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
References
[11]
[12]
[13]
[14]
[15]
[16]
Concurrent Haskell
http://www.haskell.org/ghc/docs/papers/concurrent-haskell.ps.gz
[17]
Beautiful Concurrency
https://www.fpcomplete.com/school/advanced-haskell/beautiful-concurrency
[18]
[19]
References
The GHC Commentary
[C1]
[C2]
[C3]
[C4]
[C5]
[C6]
[C7]
[C8]
[C9]
[C10]
[C11]
[C12]
[C13]
[C14]
[C15]
[C16]
[C17]
[C18]
[C19]
https://ghc.haskell.org/trac/ghc/wiki/Commentary
https://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/HscMain
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/StgSynType
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CmmType
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/GeneratedCode
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/Stack
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/Registers
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/PointerTagging
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Scheduler
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/STM
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Libraries
References
Source code
[S1] includes/stg/Regs.h
[S2] includes/stg/MachRegs.h
[S3] includes/rts/storage/ClosureTypes.h
[S4] includes/rts/storage/Closures.h
[S5] includes/rts/storage/TSO.h
[S6] includes/rts/storage/InfoTables.h
[S7] compiler/main/DriverPipeline.hs
[S8] compiler/main/HscMain.hs
[S9] compiler/cmm/CmmParse.y.source
[S10] compiler/codeGen/StgCmmForeign.hs
[S11] compiler/codeGen/Stg*.hs
[S12] rts/PrimOps.cmm
[S13] rts/RtsMain.c
[S14] rts/RtsAPI.c
[S15] rts/Capability.h
[S16] rts/Capability.c
[S17] rts/Schedule.c
[S18] rts/StgCRun.c
[S19] rts/StgStartup.cmm
[S20] rts/StgMiscClosures.cmm
[S21] rts/HeapStackCheck.cmm
[S22] rts/Threads.c
[S23] rts/Task.c
[S24] rts/Timer.c
[S25] rts/sm/GC.c
[S26] rts/Sparks.c
[S27] rts/WSDeque.c
[S28] rts/STM.h
[S29] rts/posix/Signals.c
[S30] rts/win32/ThrIOManager.c
[S31] libraries/base/GHC/MVar.hs
[S32] libraries/base/GHC/Conc/IO.hs
[S33] libraries/base/GHC/Conc/Sync.lhs
[S34] libraries/base/GHC/Event/Manager.hs
[S35] libraries/base/GHC/Event/Thread.hs
[S36] libraries/base/GHC/IO/BufferedIO.hs
[S37] libraries/base/GHC/IO/FD.hs
[S38] libraries/base/GHC/IO/Handle/Text.hs
[S39] libraries/base/System/IO.hs
[S40] libraries/base/System/Posix/Internals.hs
[S41] AutoApply.o (utils/genapply/GenApply.hs)