• tibbe's avatar
    codeGen: inline allocation optimization for clone array primops · 1eece456
    tibbe authored
    The inline allocation version is 69% faster than the out-of-line
    version, when cloning an array of 16 unit elements on a 64-bit
    Comparing the new and the old primop implementations isn't
    straightforward. The old version had a missing heap check that I
    discovered during the development of the new version. Comparing the
    old and the new version would requiring fixing the old version, which
    in turn means reimplementing the equivalent of MAYBE_CG in StgCmmPrim.
    The inline allocation threshold is configurable via
    -fmax-inline-alloc-size which gives the maximum array size, in bytes,
    to allocate inline. The size does not include the closure header size.
    Allowing the same primop to be either inline or out-of-line has some
    implication for how we lay out heap checks. We always place a heap
    check around out-of-line primops, as they may allocate outside of our
    knowledge. However, for the inline primops we only allow allocation
    via the standard means (i.e. virtHp). Since the clone primops might be
    either inline or out-of-line the heap check layout code now consults
    shouldInlinePrimOp to know whether a primop will be inlined.
CLabel.hs 46.3 KB