• Edward Z. Yang's avatar
    Immediately tag initialization code to prevent untagged spills. · cb5260d4
    Edward Z. Yang authored
    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
    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.
StgCmmEnv.hs 7.15 KB