• Keith Randall's avatar
    cmd/compile,runtime: implement stack objects · cbafcc55
    Keith Randall authored
    Rework how the compiler+runtime handles stack-allocated variables
    whose address is taken.
    
    Direct references to such variables work as before. References through
    pointers, however, use a new mechanism. The new mechanism is more
    precise than the old "ambiguously live" mechanism. It computes liveness
    at runtime based on the actual references among objects on the stack.
    
    Each function records all of its address-taken objects in a FUNCDATA.
    These are called "stack objects". The runtime then uses that
    information while scanning a stack to find all of the stack objects on
    a stack. It then does a mark phase on the stack objects, using all the
    pointers found on the stack (and ancillary structures, like defer
    records) as the root set. Only stack objects which are found to be
    live during this mark phase will be scanned and thus retain any heap
    objects they point to.
    
    A subsequent CL will remove all the "ambiguously live" logic from
    the compiler, so that the stack object tracing will be required.
    For this CL, the stack tracing is all redundant with the current
    ambiguously live logic.
    
    Update #22350
    
    Change-Id: Ide19f1f71a5b6ec8c4d54f8f66f0e9a98344772f
    Reviewed-on: https://go-review.googlesource.com/c/134155Reviewed-by: 's avatarAustin Clements <austin@google.com>
    cbafcc55
funcdata.h 2.36 KB