Changes between Version 1 and Version 2 of Commentary/Compiler/CodeGen


Ignore:
Timestamp:
Oct 11, 2006 3:03:06 PM (8 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/CodeGen

    v1 v2  
    44 
    55[[GhcFile(compiler/codeGen)]] 
     6 
     7== Storage manager representations == 
     8 
     9The code generator needs to know the layout of heap objects, because it generates code that accesses and constructs those heap objects.  The runtime also needs to know about the layout of heap objects, because it contains the garbage collector.  How can we share the definition of storage layout such that the code generator and the runtime both have access to it, and so that we don't have to keep two independent definitions in sync? 
     10 
     11Currently we solve the problem this way: 
     12 
     13 * C types representing heap objects are defined in the C header files, see for example [[GhcFile(includes/Closures.h)]]. 
     14 
     15 * A C program, [[GhcFile(includes/mkDerivedConstants.c)]],  `#includes` the runtime headers. 
     16   This program is built and run when you type `make` or `make boot` in `includes/`.  It is 
     17   run twice: once to generate `includes\DerivedConstants.h`, and again to generate  
     18   `includes/GHCConstants.h`. 
     19 
     20 * The file `DerivedConstants.h` contains lots of `#defines` like this: 
     21{{{ 
     22#define OFFSET_StgTSO_why_blocked 18 
     23}}} 
     24   which says that the offset to the why_blocked field of an `StgTSO` is 18 bytes.  This file 
     25   is `#included` into [[GhcFile(includes/Cmm.h)]], so these offests are available to the 
     26   [wiki:Commentary/Rts/Cmm hand-written .cmm files]. 
     27 
     28 * The file `GHCConstants.h` contains similar definitions: 
     29{{{ 
     30oFFSET_StgTSO_why_blocked = 18::Int 
     31}}} 
     32  This time the definitions are in Haskell syntax, and this file is `#included` directly into 
     33  [[GhcFile(compiler/main/Constants.lhs)]].  This is the way that these offsets are made 
     34  available to GHC's code generator.