Changes between Version 5 and Version 6 of Commentary/Rts/HeapObjects


Ignore:
Timestamp:
Sep 6, 2006 3:42:22 PM (8 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Rts/HeapObjects

    v5 v6  
    328328 * {{{IND_OLDGEN_PERM}}}: same as above, but for the old generation. 
    329329 * {{{IND_STATIC}}}: a static indirection, arises when we update a {{{THUNK_STATIC}}}.  A new {{{IND_STATIC}}} 
    330    is placed on the mutable list when it is created (see {{{newCaf()}}} in [[GhcFile(rts/Storage.c)]]. 
     330   is placed on the mutable list when it is created (see {{{newCaf()}}} in [[GhcFile(rts/Storage.c)]]). 
    331331 
    332332=== Byte-code objects === 
     
    355355{{{STABLE_NAME}}} 
    356356 
    357 === Thread objects === 
    358  
    359 {{{TSO}}} 
     357=== Thread State Objects === 
     358 
     359Closure type {{{TSO}}} is a Thread State Object.  It represents the complete state of a thread, including its stack. 
     360 
     361TSOs are ordinary objects that live in the heap, so we can use the existing allocation and garbage collection machinery to manage them.  This gives us one important benefit: the garbage collector can detect when a blocked thread is unreachable, and hence can never become runnable again.  When this happens, we can notify the thread by sending it the {{{BlockedIndefinitely}}} exception. 
     362 
     363GHC keeps stacks contiguous, there are no "stack chunk" objects.  This is simpler, but means that when growing a stack we have to copy the old contents to a larger area (see {{{threadStackOverflow()}}} in [[GhcFile(rts/Schedule.c)]]). 
     364 
     365The TSO structure contains several fields.  For full details see [[GhcFile(includes/TSO.h)]].  Some of the more important fields are: 
     366 
     367 * ''link'': field for linking TSOs together in a list.  For example, the threads blocked on an {{{MVar}}} are kept in 
     368   a queue threaded through the link field of each TSO. 
     369 * ''global_link'': links all TSOs together; the head of this list is {{{all_threads}}} in [[GhcFile(rts/Schedule.c)]]. 
     370 * ''what_next'': how to resume execution of this thread.  The valid values are: 
     371   * {{{ThreadRunGhc}}}: continue by returning to the top stack frame. 
     372   * {{{ThreadInterpret}}}: continue by interpreting the BCO on top of the stack. 
     373   * {{{ThreadKilled}}}: this thread has received an exception which was not caught. 
     374   * {{{ThreadRelocated}}}: this thread ran out of stack and has been relocated to a larger TSO; the link field points 
     375     to its new location. 
     376   * {{{ThreadComplete}}}: this thread has finished and can be garbage collected when it is unreachable. 
     377 * ''why_blocked'': for a blocked thread, indicates why the thread is blocked.  See [[GhcFile(includes/Constants.h)]] for 
     378   the list of possible values. 
     379 * ''block_info'': for a blocked thread, gives more information about the reason for blockage, eg. when blocked on an 
     380    MVar, block_info will point to the MVar. 
     381 * ''bound'': pointer to a [wiki:Commentary/Rts/Scheduler#Task Task] if this thread is bound 
     382 * ''cap'': the [wiki:Commentary/Rts/Scheduler#Capabilities Capability] on which this thread resides. 
    360383 
    361384=== STM objects === 
     
    363386These object types are used by [wiki:Commentary/Rts/STM STM]: {{{TVAR_WAIT_QUEUE}}}, {{{TVAR}}}, {{{TREC_CHUNK}}}, {{{TREC_HEADER}}}. 
    364387 
    365 === Forwarding pointers === 
    366  
    367 The {{{EVACUATED}}} object only appears temporarily during GC.  An object which has been copied into to-space (''evacuated'') is replaced by an {{{EVACUATED}} object: 
     388=== Forwarding Pointers === 
     389 
     390The {{{EVACUATED}}} object only appears temporarily during GC.  An object which has been copied into to-space (''evacuated'') is replaced by an {{{EVACUATED}}} object: 
    368391 
    369392|| Header || Forwarding pointer ||