Changes between Version 6 and Version 7 of SemiTagging


Ignore:
Timestamp:
Oct 13, 2006 3:57:22 PM (8 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SemiTagging

    v6 v7  
    55This page reflects my current understanding on the compiler and the RTS, so if there is something wrong, just yell! 
    66 
    7 == Tagging the LSB of an evaluated closure == 
     7== The starting point == 
    88 
    99Currently when evaluating an expression that is the scrutinee of a case: 
     
    1111case x of { ... } 
    1212}}} 
    13 GHC jumps to the code for the x closure, which returns when x is evaluated. Commonly, x is already evaluated, and the code for an evaluated constructor just (vector) returns immediately. The idea is to encode the fact that a pointer points to an evaluated object by setting the LSB of the pointer. If the case expression detects that the closure is evaluated, it can avoid the jump and return, which are expensive on modern processors (indirect jumps). 
     13GHC jumps to the code for (i.e. "enters") the x closure, which returns when x is evaluated. Commonly, x is already evaluated, and the code for an evaluated constructor just (vector) returns immediately. 
     14 
     15''Alexey: add some example HC code here'' 
     16 
     17== Testing before jumping == 
     18 
     19The simplest optimisation is this.  Instead of entering the closure, grab its info pointer, and follow the info pointer to get the tag.  Now test the tag; if it's evaluated, don't enter the closure.   
     20 
     21The benefit is that processors are typically faster at "test-and-jump to known location" than they are at "jump to this pointer". 
     22 
     23''Alexey: add some example HC code here'' 
     24 
     25== Tagging the LSB of an evaluated closure == 
     26 
     27 The idea is to encode the fact that a pointer points to an evaluated object by setting the LSB of the pointer. If the case expression detects that the closure is evaluated, it can avoid the jump and return, which are expensive on modern processors (indirect jumps). 
    1428 
    1529||  || bits 31..2 || bits 1 0 ||