summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>2011-12-07 22:40:14 +1100
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>2011-12-07 22:59:14 +1100
commit021a0dd265ff34c1e292813c06185eff1d6b5c1c (patch)
treeb7def5ebb7b8ce7f7637710e34c8034933510429 /rts
parent782d22033417e9ba71ea3322d6c97ca25dcf2745 (diff)
downloadhaskell-021a0dd265ff34c1e292813c06185eff1d6b5c1c.tar.gz
Add new primtypes 'ArrayArray#' and 'MutableArrayArray#'
The primitive array types, such as 'ByteArray#', have kind #, but are represented by pointers. They are boxed, but unpointed types (i.e., they cannot be 'undefined'). The two categories of array types —[Mutable]Array# and [Mutable]ByteArray#— are containers for unboxed (and unpointed) as well as for boxed and pointed types. So far, we lacked support for containers for boxed, unpointed types (i.e., containers for the primitive arrays themselves). This is what the new primtypes provide. Containers for boxed, unpointed types are crucial for the efficient implementation of scattered nested arrays, which are central to the new DPH backend library dph-lifted-vseg. Without such containers, we cannot eliminate all unboxing from the inner loops of traversals processing scattered nested arrays.
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c1
-rw-r--r--rts/PrimOps.cmm39
2 files changed, 40 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index c1ea0dd206..f45c105bdc 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -826,6 +826,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_myThreadIdzh) \
SymI_HasProto(stg_labelThreadzh) \
SymI_HasProto(stg_newArrayzh) \
+ SymI_HasProto(stg_newArrayArrayzh) \
SymI_HasProto(stg_newBCOzh) \
SymI_HasProto(stg_newByteArrayzh) \
SymI_HasProto_redirect(newCAF, newDynCAF) \
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 2ca347e803..21ac05f3c3 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -212,6 +212,45 @@ stg_unsafeThawArrayzh
}
}
+stg_newArrayArrayzh
+{
+ W_ words, n, arr, p, size;
+ /* Args: R1 = words */
+
+ n = R1;
+ MAYBE_GC(NO_PTRS,stg_newArrayArrayzh);
+
+ // 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) = foreign "C" allocate(MyCapability() "ptr",words) [];
+ TICK_ALLOC_PRIM(SIZEOF_StgMutArrPtrs, WDS(n), 0);
+
+ SET_HDR(arr, stg_MUT_ARR_PTRS_DIRTY_info, W_[CCCS]);
+ StgMutArrPtrs_ptrs(arr) = n;
+ StgMutArrPtrs_size(arr) = size;
+
+ // Initialise all elements of the array with a pointer to the new array
+ p = arr + SIZEOF_StgMutArrPtrs;
+ for:
+ if (p < arr + WDS(words)) {
+ W_[p] = arr;
+ 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;
+ }
+
+ RET_P(arr);
+}
+
/* -----------------------------------------------------------------------------
MutVar primitives