Where's the implementation of newArray#

Simon Marlow marlowsd at gmail.com
Fri Mar 7 09:33:24 UTC 2014


Yes, it's always out-of-line.

Cheers,
Simon

On 06/03/2014 20:20, Johan Tibell wrote:
> Is the below code it (from rts/PrimOps.cmm)? Does it being in
> PrimOps.cmm mean that it's always out-of-line?
>
> stg_newArrayzh ( W_ n /* words */, gcptr init )
> {
>      W_ words, size;
>      gcptr p, arr;
>
>      again: MAYBE_GC(again);
>
>      // the mark area contains one byte for each
> 2^MUT_ARR_PTRS_CARD_BITS words
>      // in the array, making sure we round up, and then rounding up to a
> whole
>      // number of words.
>      size = n + mutArrPtrsCardWords(n);
>      words = BYTES_TO_WDS(SIZEOF_StgMutArrPtrs) + size;
>      ("ptr" arr) = ccall allocate(MyCapability() "ptr",words);
>      TICK_ALLOC_PRIM(SIZEOF_StgMutArrPtrs, WDS(n), 0);
>
>      SET_HDR(arr, stg_MUT_ARR_PTRS_DIRTY_info, CCCS);
>      StgMutArrPtrs_ptrs(arr) = n;
>      StgMutArrPtrs_size(arr) = size;
>
>      // Initialise all elements of the the array with the value in R2
>      p = arr + SIZEOF_StgMutArrPtrs;
>    for:
>      if (p < arr + WDS(words)) {
>          W_[p] = init;
>          p = p + WDS(1);
>          goto for;
>      }
>      // Initialise the mark bits with 0
>    for2:
>      if (p < arr + WDS(size)) {
>          W_[p] = 0;
>          p = p + WDS(1);
>          goto for2;
>      }
>
>      return (arr);
> }


More information about the ghc-devs mailing list