Commit 7ad4b3c1 authored by siddhanathan's avatar siddhanathan Committed by Austin Seipp

s/StgArrWords/StgArrBytes/

Rename StgArrWords to StgArrBytes (see Trac #8552)

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D1233

GHC Trac Issues: #8552
parent 4275028c
......@@ -317,12 +317,12 @@ minClosureSize dflags = fixedHdrSizeW dflags + mIN_PAYLOAD_SIZE dflags
arrWordsHdrSize :: DynFlags -> ByteOff
arrWordsHdrSize dflags
= fixedHdrSize dflags + sIZEOF_StgArrWords_NoHdr dflags
= fixedHdrSize dflags + sIZEOF_StgArrBytes_NoHdr dflags
arrWordsHdrSizeW :: DynFlags -> WordOff
arrWordsHdrSizeW dflags =
fixedHdrSizeW dflags +
(sIZEOF_StgArrWords_NoHdr dflags `quot` wORD_SIZE dflags)
(sIZEOF_StgArrBytes_NoHdr dflags `quot` wORD_SIZE dflags)
arrPtrsHdrSize :: DynFlags -> ByteOff
arrPtrsHdrSize dflags
......
......@@ -318,17 +318,17 @@ emitPrimOp dflags [] WriteMutVarOp [mutv,var]
[(CmmReg (CmmGlobal BaseReg), AddrHint), (mutv,AddrHint)]
-- #define sizzeofByteArrayzh(r,a) \
-- r = ((StgArrWords *)(a))->bytes
-- r = ((StgArrBytes *)(a))->bytes
emitPrimOp dflags [res] SizeofByteArrayOp [arg]
= emit $ mkAssign (CmmLocal res) (cmmLoadIndexW dflags arg (fixedHdrSizeW dflags) (bWord dflags))
-- #define sizzeofMutableByteArrayzh(r,a) \
-- r = ((StgArrWords *)(a))->bytes
-- r = ((StgArrBytes *)(a))->bytes
emitPrimOp dflags [res] SizeofMutableByteArrayOp [arg]
= emitPrimOp dflags [res] SizeofByteArrayOp [arg]
-- #define getSizzeofMutableByteArrayzh(r,a) \
-- r = ((StgArrWords *)(a))->bytes
-- r = ((StgArrBytes *)(a))->bytes
emitPrimOp dflags [res] GetSizeofMutableByteArrayOp [arg]
= emitAssign (CmmLocal res) (cmmLoadIndexW dflags arg (fixedHdrSizeW dflags) (bWord dflags))
......@@ -1640,7 +1640,7 @@ doNewByteArrayOp res_r n = do
base <- allocHeapClosure rep info_ptr curCCS
[ (mkIntExpr dflags n,
hdr_size + oFFSET_StgArrWords_bytes dflags)
hdr_size + oFFSET_StgArrBytes_bytes dflags)
]
emit $ mkAssign (CmmLocal res_r) base
......
......@@ -540,10 +540,10 @@
-------------------------------------------------------------------------- */
/* The offset of the payload of an array */
#define BYTE_ARR_CTS(arr) ((arr) + SIZEOF_StgArrWords)
#define BYTE_ARR_CTS(arr) ((arr) + SIZEOF_StgArrBytes)
/* The number of words allocated in an array payload */
#define BYTE_ARR_WDS(arr) ROUNDUP_BYTES_TO_WDS(StgArrWords_bytes(arr))
#define BYTE_ARR_WDS(arr) ROUNDUP_BYTES_TO_WDS(StgArrBytes_bytes(arr))
/* Getting/setting the info pointer of a closure */
#define SET_INFO(p,info) StgHeader_info(p) = info
......
......@@ -314,13 +314,13 @@ EXTERN_INLINE StgOffset pap_sizeW( StgPAP* x );
EXTERN_INLINE StgOffset pap_sizeW( StgPAP* x )
{ return PAP_sizeW(x->n_args); }
EXTERN_INLINE StgWord arr_words_words( StgArrWords* x);
EXTERN_INLINE StgWord arr_words_words( StgArrWords* x)
EXTERN_INLINE StgWord arr_words_words( StgArrBytes* x);
EXTERN_INLINE StgWord arr_words_words( StgArrBytes* x)
{ return ROUNDUP_BYTES_TO_WDS(x->bytes); }
EXTERN_INLINE StgOffset arr_words_sizeW( StgArrWords* x );
EXTERN_INLINE StgOffset arr_words_sizeW( StgArrWords* x )
{ return sizeofW(StgArrWords) + arr_words_words(x); }
EXTERN_INLINE StgOffset arr_words_sizeW( StgArrBytes* x );
EXTERN_INLINE StgOffset arr_words_sizeW( StgArrBytes* x )
{ return sizeofW(StgArrBytes) + arr_words_words(x); }
EXTERN_INLINE StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x );
EXTERN_INLINE StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x )
......@@ -381,7 +381,7 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info)
case IND_PERM:
return sizeofW(StgInd);
case ARR_WORDS:
return arr_words_sizeW((StgArrWords *)p);
return arr_words_sizeW((StgArrBytes *)p);
case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY:
case MUT_ARR_PTRS_FROZEN:
......
......@@ -135,18 +135,11 @@ typedef struct StgBlockingQueue_ {
struct MessageBlackHole_ *queue;
} StgBlockingQueue;
/* This struct should be called StgArrBytes rather than StgArrWords.
*
* One might be very tempted to store the number of words in the bytes field,
* but the garbage collector will erase your data then.
*
* It's name is for historical reasons, see #3800
*/
typedef struct {
StgHeader header;
StgWord bytes;
StgWord payload[FLEXIBLE_ARRAY];
} StgArrWords; // TODO: s/StgArrWords/StgArrBytes (#8552)
} StgArrBytes;
typedef struct {
StgHeader header;
......@@ -243,8 +236,8 @@ typedef struct _StgCFinalizerList {
typedef struct {
StgHeader header;
StgArrWords *instrs; /* a pointer to an ArrWords */
StgArrWords *literals; /* a pointer to an ArrWords */
StgArrBytes *instrs; /* a pointer to an ArrWords */
StgArrBytes *literals; /* a pointer to an ArrWords */
StgMutArrPtrs *ptrs; /* a pointer to a MutArrPtrs */
StgHalfWord arity; /* arity of this BCO */
StgHalfWord size; /* size of this BCO (in words) */
......
......@@ -250,15 +250,15 @@ typedef struct _IA64FunDesc {
static void *
stgAllocStable(size_t size_in_bytes, StgStablePtr *stable)
{
StgArrWords* arr;
StgArrBytes* arr;
nat data_size_in_words, total_size_in_words;
/* round up to a whole number of words */
data_size_in_words = ROUNDUP_BYTES_TO_WDS(size_in_bytes);
total_size_in_words = sizeofW(StgArrWords) + data_size_in_words;
total_size_in_words = sizeofW(StgArrBytes) + data_size_in_words;
/* allocate and fill it in */
arr = (StgArrWords *)allocate(total_size_in_words);
arr = (StgArrBytes *)allocate(total_size_in_words);
SET_ARR_HDR(arr, &stg_ARR_WORDS_info, CCCS, size_in_bytes);
/* obtain a stable ptr */
......
......@@ -188,7 +188,7 @@ static void searchHeapBlocks (HashTable *addrs, bdescr *bd)
case ARR_WORDS:
prim = rtsTrue;
size = arr_words_sizeW((StgArrWords*)p);
size = arr_words_sizeW((StgArrBytes*)p);
break;
case MUT_ARR_PTRS_CLEAN:
......
......@@ -33,7 +33,7 @@ disInstr ( StgBCO *bco, int pc )
StgWord16* instrs = (StgWord16*)(bco->instrs->payload);
StgArrWords* literal_arr = bco->literals;
StgArrBytes* literal_arr = bco->literals;
StgWord* literals = (StgWord*)(&literal_arr->payload[0]);
StgMutArrPtrs* ptrs_arr = bco->ptrs;
......
......@@ -843,7 +843,7 @@ run_BCO:
case bci_BRK_FUN:
{
int arg1_brk_array, arg2_array_index, arg3_freeVars;
StgArrWords *breakPoints;
StgArrBytes *breakPoints;
int returning_from_break; // are we resuming execution from a breakpoint?
// if yes, then don't break this time around
StgClosure *ioAction; // the io action to run at a breakpoint
......@@ -864,7 +864,7 @@ run_BCO:
// and continue executing
if (!returning_from_break)
{
breakPoints = (StgArrWords *) BCO_PTR(arg1_brk_array);
breakPoints = (StgArrBytes *) BCO_PTR(arg1_brk_array);
// stop the current thread if either the
// "rts_stop_next_breakpoint" flag is true OR if the
......
......@@ -57,11 +57,11 @@ stg_newByteArrayzh ( W_ n )
MAYBE_GC_N(stg_newByteArrayzh, n);
payload_words = ROUNDUP_BYTES_TO_WDS(n);
words = BYTES_TO_WDS(SIZEOF_StgArrWords) + payload_words;
words = BYTES_TO_WDS(SIZEOF_StgArrBytes) + payload_words;
("ptr" p) = ccall allocate(MyCapability() "ptr",words);
TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0);
TICK_ALLOC_PRIM(SIZEOF_StgArrBytes,WDS(payload_words),0);
SET_HDR(p, stg_ARR_WORDS_info, CCCS);
StgArrWords_bytes(p) = n;
StgArrBytes_bytes(p) = n;
return (p);
}
......@@ -80,7 +80,7 @@ stg_newPinnedByteArrayzh ( W_ n )
payload_words = ROUNDUP_BYTES_TO_WDS(bytes);
/* When we actually allocate memory, we need to allow space for the
header: */
bytes = bytes + SIZEOF_StgArrWords;
bytes = bytes + SIZEOF_StgArrBytes;
/* And we want to align to BA_ALIGN bytes, so we need to allow space
to shift up to BA_ALIGN - 1 bytes: */
bytes = bytes + BA_ALIGN - 1;
......@@ -88,14 +88,14 @@ stg_newPinnedByteArrayzh ( W_ n )
words = ROUNDUP_BYTES_TO_WDS(bytes);
("ptr" p) = ccall allocatePinned(MyCapability() "ptr", words);
TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0);
TICK_ALLOC_PRIM(SIZEOF_StgArrBytes,WDS(payload_words),0);
/* Now we need to move p forward so that the payload is aligned
to BA_ALIGN bytes: */
p = p + ((-p - SIZEOF_StgArrWords) & BA_MASK);
p = p + ((-p - SIZEOF_StgArrBytes) & BA_MASK);
SET_HDR(p, stg_ARR_WORDS_info, CCCS);
StgArrWords_bytes(p) = n;
StgArrBytes_bytes(p) = n;
return (p);
}
......@@ -118,7 +118,7 @@ stg_newAlignedPinnedByteArrayzh ( W_ n, W_ alignment )
/* When we actually allocate memory, we need to allow space for the
header: */
bytes = bytes + SIZEOF_StgArrWords;
bytes = bytes + SIZEOF_StgArrBytes;
/* And we want to align to <alignment> bytes, so we need to allow space
to shift up to <alignment - 1> bytes: */
bytes = bytes + alignment - 1;
......@@ -126,15 +126,15 @@ stg_newAlignedPinnedByteArrayzh ( W_ n, W_ alignment )
words = ROUNDUP_BYTES_TO_WDS(bytes);
("ptr" p) = ccall allocatePinned(MyCapability() "ptr", words);
TICK_ALLOC_PRIM(SIZEOF_StgArrWords,WDS(payload_words),0);
TICK_ALLOC_PRIM(SIZEOF_StgArrBytes,WDS(payload_words),0);
/* Now we need to move p forward so that the payload is aligned
to <alignment> bytes. Note that we are assuming that
<alignment> is a power of 2, which is technically not guaranteed */
p = p + ((-p - SIZEOF_StgArrWords) & (alignment - 1));
p = p + ((-p - SIZEOF_StgArrBytes) & (alignment - 1));
SET_HDR(p, stg_ARR_WORDS_info, CCCS);
StgArrWords_bytes(p) = n;
StgArrBytes_bytes(p) = n;
return (p);
}
......@@ -143,11 +143,11 @@ stg_shrinkMutableByteArrayzh ( gcptr mba, W_ new_size )
// MutableByteArray# s -> Int# -> State# s -> State# s
{
ASSERT(new_size >= 0);
ASSERT(new_size <= StgArrWords_bytes(mba));
ASSERT(new_size <= StgArrBytes_bytes(mba));
OVERWRITING_CLOSURE_OFS(mba, (BYTES_TO_WDS(SIZEOF_StgArrWords) +
OVERWRITING_CLOSURE_OFS(mba, (BYTES_TO_WDS(SIZEOF_StgArrBytes) +
ROUNDUP_BYTES_TO_WDS(new_size)));
StgArrWords_bytes(mba) = new_size;
StgArrBytes_bytes(mba) = new_size;
LDV_RECORD_CREATE(mba);
return ();
......@@ -169,9 +169,9 @@ stg_resizzeMutableByteArrayzh ( gcptr mba, W_ new_size )
new_size_wds = ROUNDUP_BYTES_TO_WDS(new_size);
if (new_size_wds <= BYTE_ARR_WDS(mba)) {
OVERWRITING_CLOSURE_OFS(mba, (BYTES_TO_WDS(SIZEOF_StgArrWords) +
OVERWRITING_CLOSURE_OFS(mba, (BYTES_TO_WDS(SIZEOF_StgArrBytes) +
new_size_wds));
StgArrWords_bytes(mba) = new_size;
StgArrBytes_bytes(mba) = new_size;
LDV_RECORD_CREATE(mba);
return (mba);
......@@ -186,7 +186,7 @@ stg_resizzeMutableByteArrayzh ( gcptr mba, W_ new_size )
// copy over old content
prim %memcpy(BYTE_ARR_CTS(new_mba), BYTE_ARR_CTS(mba),
StgArrWords_bytes(mba), SIZEOF_W);
StgArrBytes_bytes(mba), SIZEOF_W);
return (new_mba);
}
......@@ -199,7 +199,7 @@ stg_casIntArrayzh( gcptr arr, W_ ind, W_ old, W_ new )
{
W_ p, h;
p = arr + SIZEOF_StgArrWords + WDS(ind);
p = arr + SIZEOF_StgArrBytes + WDS(ind);
(h) = ccall cas(p, old, new);
return(h);
......@@ -1927,7 +1927,7 @@ stg_newBCOzh ( P_ instrs,
i = 0;
for:
if (i < BYTE_ARR_WDS(bitmap_arr)) {
StgBCO_bitmap(bco,i) = StgArrWords_payload(bitmap_arr,i);
StgBCO_bitmap(bco,i) = StgArrBytes_payload(bitmap_arr,i);
i = i + 1;
goto for;
}
......@@ -1988,7 +1988,7 @@ stg_unpackClosurezh ( P_ closure )
out:
W_ ptrs_arr_sz, ptrs_arr_cards, nptrs_arr_sz;
nptrs_arr_sz = SIZEOF_StgArrWords + WDS(nptrs);
nptrs_arr_sz = SIZEOF_StgArrBytes + WDS(nptrs);
ptrs_arr_cards = mutArrPtrsCardWords(ptrs);
ptrs_arr_sz = SIZEOF_StgMutArrPtrs + WDS(ptrs) + WDS(ptrs_arr_cards);
......@@ -2016,7 +2016,7 @@ for:
is promoted. */
SET_HDR(nptrs_arr, stg_ARR_WORDS_info, CCCS);
StgArrWords_bytes(nptrs_arr) = WDS(nptrs);
StgArrBytes_bytes(nptrs_arr) = WDS(nptrs);
p = 0;
for2:
if(p < nptrs) {
......
......@@ -297,8 +297,8 @@ printClosure( StgClosure *obj )
{
StgWord i;
debugBelch("ARR_WORDS(\"");
for (i=0; i<arr_words_words((StgArrWords *)obj); i++)
debugBelch("%" FMT_Word, (W_)((StgArrWords *)obj)->payload[i]);
for (i=0; i<arr_words_words((StgArrBytes *)obj); i++)
debugBelch("%" FMT_Word, (W_)((StgArrBytes *)obj)->payload[i]);
debugBelch("\")\n");
break;
}
......
......@@ -1023,7 +1023,7 @@ heapCensusChain( Census *census, bdescr *bd )
case ARR_WORDS:
prim = rtsTrue;
size = arr_words_sizeW((StgArrWords*)p);
size = arr_words_sizeW((StgArrBytes*)p);
break;
case MUT_ARR_PTRS_CLEAN:
......
......@@ -670,7 +670,7 @@ thread_obj (StgInfoTable *info, StgPtr p)
return thread_AP((StgAP *)p);
case ARR_WORDS:
return p + arr_words_sizeW((StgArrWords *)p);
return p + arr_words_sizeW((StgArrBytes *)p);
case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY:
......
......@@ -684,7 +684,7 @@ loop:
case ARR_WORDS:
// just copy the block
copy(p,info,q,arr_words_sizeW((StgArrWords *)q),gen_no);
copy(p,info,q,arr_words_sizeW((StgArrBytes *)q),gen_no);
return;
case MUT_ARR_PTRS_CLEAN:
......
......@@ -388,7 +388,7 @@ checkClosure( StgClosure* p )
}
case ARR_WORDS:
return arr_words_sizeW((StgArrWords *)p);
return arr_words_sizeW((StgArrBytes *)p);
case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY:
......
......@@ -637,7 +637,7 @@ scavenge_block (bdescr *bd)
case ARR_WORDS:
// nothing to follow
p += arr_words_sizeW((StgArrWords *)p);
p += arr_words_sizeW((StgArrBytes *)p);
break;
case MUT_ARR_PTRS_CLEAN:
......
......@@ -412,9 +412,9 @@ wanteds = concat
,closureSize Both "StgSmallMutArrPtrs"
,closureField Both "StgSmallMutArrPtrs" "ptrs"
,closureSize Both "StgArrWords"
,closureField Both "StgArrWords" "bytes"
,closurePayload C "StgArrWords" "payload"
,closureSize Both "StgArrBytes"
,closureField Both "StgArrBytes" "bytes"
,closurePayload C "StgArrBytes" "payload"
,closureField C "StgTSO" "_link"
,closureField C "StgTSO" "global_link"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment