X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FPrimOps.hc;h=44bedf6017ba399b57d35b37d03235789c7c1f16;hb=fbbed914e114b6b55158319dca8956885f301ff5;hp=b948f1f38752ffefa23cd05487faada74d5e1ccd;hpb=2f015a00457d134124d1522316ae13b95b0b4f47;p=ghc-hetmet.git diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index b948f1f..44bedf6 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.94 2002/03/02 17:40:24 sof Exp $ + * $Id: PrimOps.hc,v 1.99 2002/06/26 08:18:41 stolz Exp $ * * (c) The GHC Team, 1998-2000 * @@ -244,40 +244,57 @@ StgWord GHC_ZCCReturnable_static_info[1]; #define BYTES_TO_STGWORDS(n) ((n) + sizeof(W_) - 1)/sizeof(W_) -FN_(newByteArrayzh_fast) \ - { \ - W_ size, stuff_size, n; \ - StgArrWords* p; \ - FB_ \ - MAYBE_GC(NO_PTRS,newByteArrayzh_fast); \ - n = R1.w; \ - stuff_size = BYTES_TO_STGWORDS(n); \ - size = sizeofW(StgArrWords)+ stuff_size; \ - p = (StgArrWords *)RET_STGCALL1(P_,allocate,size); \ - TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); \ - SET_HDR(p, &stg_ARR_WORDS_info, CCCS); \ - p->words = stuff_size; \ - TICK_RET_UNBOXED_TUP(1) \ - RET_P(p); \ - FE_ \ +FN_(newByteArrayzh_fast) + { + W_ size, stuff_size, n; + StgArrWords* p; + FB_ + MAYBE_GC(NO_PTRS,newByteArrayzh_fast); + n = R1.w; + stuff_size = BYTES_TO_STGWORDS(n); + size = sizeofW(StgArrWords)+ stuff_size; + p = (StgArrWords *)RET_STGCALL1(P_,allocate,size); + TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); + SET_HDR(p, &stg_ARR_WORDS_info, CCCS); + p->words = stuff_size; + TICK_RET_UNBOXED_TUP(1) + RET_P(p); + FE_ } -FN_(newPinnedByteArrayzh_fast) \ - { \ - W_ size, stuff_size, n; \ - StgArrWords* p; \ - FB_ \ - MAYBE_GC(NO_PTRS,newPinnedByteArrayzh_fast); \ - n = R1.w; \ - stuff_size = BYTES_TO_STGWORDS(n); \ - size = sizeofW(StgArrWords)+ stuff_size; \ - p = (StgArrWords *)RET_STGCALL1(P_,allocatePinned,size); \ - TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); \ - SET_HDR(p, &stg_ARR_WORDS_info, CCCS); \ - p->words = stuff_size; \ - TICK_RET_UNBOXED_TUP(1) \ - RET_P(p); \ - FE_ \ +FN_(newPinnedByteArrayzh_fast) + { + W_ size, stuff_size, n; + StgArrWords* p; + FB_ + MAYBE_GC(NO_PTRS,newPinnedByteArrayzh_fast); + n = R1.w; + stuff_size = BYTES_TO_STGWORDS(n); + + // We want an 8-byte aligned array. allocatePinned() gives us + // 8-byte aligned memory by default, but we want to align the + // *goods* inside the ArrWords object, so we have to check the + // size of the ArrWords header and adjust our size accordingly. + size = sizeofW(StgArrWords)+ stuff_size; + if ((sizeof(StgArrWords) & 7) != 0) { + size++; + } + + p = (StgArrWords *)RET_STGCALL1(P_,allocatePinned,size); + TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); + + // Again, if the ArrWords header isn't a multiple of 8 bytes, we + // have to push the object forward one word so that the goods + // fall on an 8-byte boundary. + if ((sizeof(StgArrWords) & 7) != 0) { + ((StgPtr)p)++; + } + + SET_HDR(p, &stg_ARR_WORDS_info, CCCS); + p->words = stuff_size; + TICK_RET_UNBOXED_TUP(1) + RET_P(p); + FE_ } FN_(newArrayzh_fast) @@ -1009,6 +1026,21 @@ FN_(forkzh_fast) FE_ } +FN_(forkProcesszh_fast) +{ + pid_t pid; + + FB_ + /* args: none */ + /* result: Pid */ + + R1.i = RET_STGCALL1(StgInt, forkProcess, CurrentTSO); + + JMP_(ENTRY_CODE(Sp[0])); + + FE_ +} + FN_(yieldzh_fast) { FB_ @@ -1024,7 +1056,18 @@ FN_(myThreadIdzh_fast) FE_ } - +FN_(labelThreadzh_fast) +{ + FB_ + /* args: + R1.p = ThreadId# + R2.p = Addr# */ +#ifdef DEBUG + STGCALL2(labelThread,(StgTSO *)R1.p,(char *)R2.p); +#endif + JMP_(ENTRY_CODE(Sp[0])); + FE_ +} /* -----------------------------------------------------------------------------