Immediately tag initialization code to prevent untagged spills.
authorEdward Z. Yang <ezyang@mit.edu>
Wed, 23 Mar 2011 13:43:30 +0000 (13:43 +0000)
committerEdward Z. Yang <ezyang@mit.edu>
Wed, 23 Mar 2011 13:43:30 +0000 (13:43 +0000)
commitcb5260d444da0f74c2e06c7857dff2f163415ebd
treec6287cdccd93d1106db537fbd4e22d9d276b603a
parent6c979675be92983796cf7426d1ffd30d3dc8af02
Immediately tag initialization code to prevent untagged spills.

When allocating new objects on the heap, we previously returned
a CmmExpr containing the heap pointer as well as the tag expression,
which would be added to the code graph upon first usage.  Unfortunately,
this meant that untagged heap pointers living in registers might
be spilled to the stack, where they interacted poorly with garbage
collection (we saw this bug specifically with the compacting garbage
collector.)

This fix immediately tags the register containing the heap pointer,
so that unless we have extremely unfriendly spill code, the new pointer
will never be spilled to the stack untagged.

An alternate solution might have been to modify allocDynClosure to
tag the pointer upon the initial register allocation, but not all
invocations of allocDynClosure tag the resulting pointer, and
threading the consequent CgIdInfo for the cases that did would have
been annoying.
compiler/codeGen/StgCmmBind.hs
compiler/codeGen/StgCmmCon.hs
compiler/codeGen/StgCmmEnv.hs