Changes between Version 2 and Version 3 of Commentary/Rts/HeapObjects


Ignore:
Timestamp:
Sep 6, 2006 10:40:15 AM (8 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Rts/HeapObjects

    v2 v3  
    2121All heap objects have the same basic layout, embodied by the type {{{StgClosure}}} in [http://darcs.haskell.org/ghc/includes/Closures.h Closures.h].  The diagram below shows the layout of a heap object: 
    2222 
     23[[Image(heap-object.png)]] 
     24 
     25A heap object always begins with a ''header'', defined by {{{StgHeader}}} in [http://darcs.haskell.org/ghc/includes/Closures.h Closures.h]: 
     26 
     27{{{ 
     28typedef struct { 
     29    const struct _StgInfoTable* info; 
     30#ifdef PROFILING 
     31    StgProfHeader         prof; 
     32#endif 
     33#ifdef GRAN 
     34    StgGranHeader         gran; 
     35#endif 
     36} StgHeader; 
     37}}} 
     38 
     39The most important part of the header is the ''info pointer'', which points to the info table for the closure.  In the default build, this is all the header contains, so a header is normally just one word.  In other builds, the header may contain extra information: eg. in a profilnig build it also contains information about who built the closure. 
     40 
     41Most of the runtime is insensitive to the size of {{{StgHeader}}}; that is, we are careful not to hardcode the offset to the payload anywhere, instead we use C struct indexing or {{{sizeof(StgHeader)}}}.  This makes it easy to extend {{{StgHeader}}} with new fields if we need to. 
    2342 
    2443== Info Tables == 
    2544 
     45The info table contains all the information that the runtime needs to know about the closure. 
    2646 
    2747== Types of Heap Object == 
     48 
     49== The stack, and stack objects ==