X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Frts%2FPrimOps.hc;h=94dc251bc4dd44f1501f926297d3cc7c400642d1;hb=b70b5550a9c2825bbca73e00c2cd249f85df8521;hp=39b4a74408a2a93e0cb5b55845c7d05a156b01d3;hpb=30681e796f707fa109aaf756d4586049f595195d;p=ghc-hetmet.git diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index 39b4a74..94dc251 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.34 1999/11/09 15:46:53 simonmar Exp $ + * $Id: PrimOps.hc,v 1.49 2000/03/21 11:33:12 rrt Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2000 * * Primitive functions / data * @@ -9,8 +9,6 @@ #include "Rts.h" -#ifdef COMPILER - #include "RtsFlags.h" #include "StgStartup.h" #include "SchedAPI.h" @@ -21,6 +19,8 @@ #include "StablePriv.h" #include "HeapStackCheck.h" #include "StgRun.h" +#include "Itimer.h" +#include "Prelude.h" /* ** temporary ** @@ -185,7 +185,13 @@ W_ GHC_ZCCReturnable_static_info[0]; #else /* 0 Regs available */ #define PUSH_P(o,x) Sp[-o] = (W_)(x) -#define PUSH_N(o,x) Sp[1-o] = (W_)(x); /* Sp[-o] = ARGTAG(1) */ + +#ifdef DEBUG +#define PUSH_N(o,x) Sp[1-o] = (W_)(x); Sp[-o] = ARG_TAG(1); +#else +#define PUSH_N(o,x) Sp[1-o] = (W_)(x); +#endif + #define PUSHED(m) Sp -= (m); JMP_(ENTRY_CODE(Sp[m])); /* Here's how to construct these macros: @@ -363,12 +369,16 @@ FN_(mkWeakzh_fast) { /* R1.p = key R2.p = value - R3.p = finalizer + R3.p = finalizer (or NULL) */ StgWeak *w; FB_ - HP_CHK_GEN_TICKY(sizeofW(StgWeak), R1_PTR|R2_PTR|R3_PTR, mkWeakzh_fast,); + if (R3.cl == NULL) { + R3.cl = &NO_FINALIZER_closure; + } + + HP_CHK_GEN_TICKY(sizeofW(StgWeak),R1_PTR|R2_PTR|R3_PTR, mkWeakzh_fast,); TICK_ALLOC_PRIM(sizeofW(StgHeader)+1, // +1 is for the link field sizeofW(StgWeak)-sizeofW(StgHeader)-1, 0); CCS_ALLOC(CCCS,sizeofW(StgWeak)); /* ccs prof */ @@ -378,11 +388,7 @@ FN_(mkWeakzh_fast) w->key = R1.cl; w->value = R2.cl; - if (R3.cl) { - w->finalizer = R3.cl; - } else { - w->finalizer = &NO_FINALIZER_closure; - } + w->finalizer = R3.cl; w->link = weak_ptr_list; weak_ptr_list = w; @@ -635,7 +641,7 @@ FN_(word64ToIntegerzh_fast) FN_(name) \ { \ MP_INT arg1, arg2, result; \ - I_ s1, s2; \ + I_ s1, s2; \ StgArrWords* d1; \ StgArrWords* d2; \ FB_ \ @@ -670,7 +676,7 @@ FN_(name) \ FN_(name) \ { \ MP_INT arg1, arg2, result1, result2; \ - I_ s1, s2; \ + I_ s1, s2; \ StgArrWords* d1; \ StgArrWords* d2; \ FB_ \ @@ -704,10 +710,13 @@ FN_(name) \ FE_ \ } -GMP_TAKE2_RET1(plusIntegerzh_fast, mpz_add); -GMP_TAKE2_RET1(minusIntegerzh_fast, mpz_sub); -GMP_TAKE2_RET1(timesIntegerzh_fast, mpz_mul); -GMP_TAKE2_RET1(gcdIntegerzh_fast, mpz_gcd); +GMP_TAKE2_RET1(plusIntegerzh_fast, mpz_add); +GMP_TAKE2_RET1(minusIntegerzh_fast, mpz_sub); +GMP_TAKE2_RET1(timesIntegerzh_fast, mpz_mul); +GMP_TAKE2_RET1(gcdIntegerzh_fast, mpz_gcd); +GMP_TAKE2_RET1(quotIntegerzh_fast, mpz_tdiv_q); +GMP_TAKE2_RET1(remIntegerzh_fast, mpz_tdiv_r); +GMP_TAKE2_RET1(divExactIntegerzh_fast, mpz_divexact); GMP_TAKE2_RET2(quotRemIntegerzh_fast, mpz_tdiv_qr); GMP_TAKE2_RET2(divModIntegerzh_fast, mpz_fdiv_qr); @@ -806,43 +815,6 @@ FN_(yieldzh_fast) FE_ } -FN_(killThreadzh_fast) -{ - FB_ - /* args: R1.p = TSO to kill, R2.p = Exception */ - - /* The thread is dead, but the TSO sticks around for a while. That's why - * we don't have to explicitly remove it from any queues it might be on. - */ - - /* We might have killed ourselves. In which case, better be *very* - * careful. If the exception killed us, then return to the scheduler. - * If the exception went to a catch frame, we'll just continue from - * the handler. - */ - if (R1.t == CurrentTSO) { - SaveThreadState(); /* inline! */ - STGCALL2(raiseAsync, R1.t, R2.cl); - if (CurrentTSO->whatNext == ThreadKilled) { - R1.w = ThreadYielding; - JMP_(StgReturn); - } - LoadThreadState(); - if (CurrentTSO->whatNext == ThreadEnterGHC) { - R1.w = Sp[0]; - Sp++; - JMP_(GET_ENTRY(R1.cl)); - } else { - barf("killThreadzh_fast"); - } - } else { - STGCALL2(raiseAsync, R1.t, R2.cl); - } - - JMP_(ENTRY_CODE(Sp[0])); - FE_ -} - FN_(newMVarzh_fast) { StgMVar *mvar; @@ -933,8 +905,13 @@ FN_(putMVarzh_fast) #endif if (info == &FULL_MVAR_info) { - fprintf(stderr, "putMVar#: MVar already full.\n"); - stg_exit(EXIT_FAILURE); +#ifdef INTERPRETER + fprintf(stderr, "fatal: put on a full MVar in Hugs; aborting\n" ); + exit(1); +#else + R1.cl = (StgClosure *)PutFullMVar_closure; + JMP_(raisezh_fast); +#endif } mvar->value = R2.cl; @@ -944,7 +921,14 @@ FN_(putMVarzh_fast) */ if (mvar->head != (StgTSO *)&END_TSO_QUEUE_closure) { ASSERT(mvar->head->why_blocked == BlockedOnMVar); +#if defined(GRAN) + mvar->head = RET_STGCALL2(StgTSO *,unblockOne,mvar->head,mvar); +#elif defined(PAR) + // ToDo: check 2nd arg (mvar) is right + mvar->head = RET_STGCALL2(StgTSO *,unblockOne,mvar->head,mvar); +#else mvar->head = RET_STGCALL1(StgTSO *,unblockOne,mvar->head); +#endif if (mvar->head == (StgTSO *)&END_TSO_QUEUE_closure) { mvar->tail = (StgTSO *)&END_TSO_QUEUE_closure; } @@ -1033,7 +1017,11 @@ FN_(delayzh_fast) /* Add on ticks_since_select, since these will be subtracted at * the next awaitEvent call. */ +#if defined(HAVE_SETITIMER) || defined(mingw32_TARGET_OS) CurrentTSO->block_info.delay = R1.i + ticks_since_select; +#else + CurrentTSO->block_info.target = R1.i + getourtimeofday(); +#endif APPEND_TO_BLOCKED_QUEUE(CurrentTSO); @@ -1042,5 +1030,4 @@ FN_(delayzh_fast) FE_ } -#endif /* COMPILER */