1 /* -----------------------------------------------------------------------------
2 * $Id: PrimOps.hc,v 1.16 1999/02/17 15:57:39 simonm Exp $
4 * (c) The GHC Team, 1998-1999
6 * Primitive functions / data
8 * ---------------------------------------------------------------------------*/
15 #include "StgStartup.h"
20 #include "BlockAlloc.h" /* tmp */
21 #include "StablePriv.h"
25 classes CCallable and CReturnable don't really exist, but the
26 compiler insists on generating dictionaries containing references
27 to GHC_ZcCCallable_static_info etc., so we provide dummy symbols
31 W_ GHC_ZCCCallable_static_info[0];
32 W_ GHC_ZCCReturnable_static_info[0];
34 #ifndef aix_TARGET_OS /* AIX gives link errors with this as a const (RO assembler section) */
37 StgClosure *PrelBase_Bool_closure_tbl[] = {
42 /* -----------------------------------------------------------------------------
43 Macros for Hand-written primitives.
44 -------------------------------------------------------------------------- */
47 * Horrible macros for returning unboxed tuples.
49 * How an unboxed tuple is returned depends on two factors:
50 * - the number of real registers we have available
51 * - the boxedness of the returned fields.
53 * To return an unboxed tuple from a primitive operation, we have macros
54 * RET_<layout> where <layout> describes the boxedness of each field of the
55 * unboxed tuple: N indicates a non-pointer field, and P indicates a pointer.
57 * We only define the cases actually used, to avoid having too much
58 * garbage in this section. Warning: any bugs in here will be hard to
62 /*------ All Regs available */
64 # define RET_P(a) R1.w = (W_)(a); JMP_(ENTRY_CODE(Sp[0]));
65 # define RET_N(a) RET_P(a)
67 # define RET_PP(a,b) R1.w = (W_)(a); R2.w = (W_)(b); JMP_(ENTRY_CODE(Sp[0]));
68 # define RET_NN(a,b) RET_PP(a,b)
69 # define RET_NP(a,b) RET_PP(a,b)
71 # define RET_PPP(a,b,c) \
72 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); JMP_(ENTRY_CODE(Sp[0]));
73 # define RET_NNP(a,b,c) RET_PPP(a,b,c)
75 # define RET_NNNP(a,b,c,d) \
76 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); R4.w = (W_)d; \
77 JMP_(ENTRY_CODE(Sp[0]));
79 # define RET_NPNP(a,b,c,d) \
80 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); R4.w = (W_)(d);
81 JMP_(ENTRY_CODE(Sp[0]));
83 # define RET_NNPNNP(a,b,c,d,e,f) \
84 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); \
85 R4.w = (W_)(d); R5.w = (W_)(e); R6.w = (W_)(f); \
86 JMP_(ENTRY_CODE(Sp[0]));
90 #if defined(REG_R7) || defined(REG_R6) || defined(REG_R5) || \
91 defined(REG_R4) || defined(REG_R3) || defined(REG_R2)
92 # error RET_n macros not defined for this setup.
95 /*------ 1 Register available */
97 # define RET_P(a) R1.w = (W_)(a); JMP_(ENTRY_CODE(Sp[0]));
98 # define RET_N(a) RET_P(a)
100 # define RET_PP(a,b) R1.w = (W_)(a); Sp[-1] = (W_)(b); Sp -= 1; \
101 JMP_(ENTRY_CODE(Sp[1]));
102 # define RET_NN(a,b) R1.w = (W_)(a); Sp[-1] = (W_)(b); Sp -= 2; \
103 JMP_(ENTRY_CODE(Sp[2]));
104 # define RET_NP(a,b) RET_PP(a,b)
106 # define RET_PPP(a,b,c) \
107 R1.w = (W_)(a); Sp[-2] = (W_)(b); Sp[-1] = (W_)(c); Sp -= 2; \
108 JMP_(ENTRY_CODE(Sp[2]));
109 # define RET_NNP(a,b,c) \
110 R1.w = (W_)(a); Sp[-2] = (W_)(b); Sp[-1] = (W_)(c); Sp -= 3; \
111 JMP_(ENTRY_CODE(Sp[3]));
113 # define RET_NNNP(a,b,c,d) \
115 /* Sp[-5] = ARGTAG(1); */ \
117 /* Sp[-3] = ARGTAG(1); */ \
121 JMP_(ENTRY_CODE(Sp[5]));
123 # define RET_NPNP(a,b,c,d) \
126 /* Sp[-3] = ARGTAG(1); */ \
130 JMP_(ENTRY_CODE(Sp[4]));
132 # define RET_NNPNNP(a,b,c,d,e,f) \
136 /* Sp[-3] = ARGTAG(1); */ \
138 /* Sp[-5] = ARGTAG(1); */ \
141 /* Sp[-8] = ARGTAG(1); */ \
143 JMP_(ENTRY_CODE(Sp[8]));
145 #else /* 0 Regs available */
147 #define PUSH_P(o,x) Sp[-o] = (W_)(x)
148 #define PUSH_N(o,x) Sp[1-o] = (W_)(x); /* Sp[-o] = ARGTAG(1) */
149 #define PUSHED(m) Sp -= (m); JMP_(ENTRY_CODE(Sp[m]));
151 /* Here's how to construct these macros:
153 * N = number of N's in the name;
154 * P = number of P's in the name;
156 * while (nonNull(name)) {
157 * if (nextChar == 'P') {
168 # define RET_P(a) PUSH_P(1,a); PUSHED(1)
169 # define RET_N(a) PUSH_N(2,a); PUSHED(2)
171 # define RET_PP(a,b) PUSH_P(2,a); PUSH_P(1,b); PUSHED(2)
172 # define RET_NN(a,b) PUSH_N(4,a); PUSH_N(2,b); PUSHED(4)
173 # define RET_NP(a,b) PUSH_N(3,a); PUSH_P(1,b); PUSHED(3)
175 # define RET_PPP(a,b,c) PUSH_P(3,a); PUSH_P(2,b); PUSH_P(1,c); PUSHED(3)
176 # define RET_NNP(a,b,c) PUSH_N(6,a); PUSH_N(4,b); PUSH_N(2,c); PUSHED(6)
178 # define RET_NNNP(a,b,c,d) PUSH_N(7,a); PUSH_N(5,b); PUSH_N(3,c); PUSH_P(1,d); PUSHED(7)
179 # define RET_NPNP(a,b,c,d) PUSH_N(6,a); PUSH_P(4,b); PUSH_N(3,c); PUSH_P(1,d); PUSHED(6)
180 # define RET_NNPNNP(a,b,c,d,e,f) PUSH_N(10,a); PUSH_N(8,b); PUSH_P(6,c); PUSH_N(5,d); PUSH_N(3,e); PUSH_P(1,f); PUSHED(10)
187 /*-----------------------------------------------------------------------------
190 Basically just new*Array - the others are all inline macros.
192 The size arg is always passed in R1, and the result returned in R1.
194 The slow entry point is for returning from a heap check, the saved
195 size argument must be re-loaded from the stack.
196 -------------------------------------------------------------------------- */
198 /* for objects that are *less* than the size of a word, make sure we
199 * round up to the nearest word for the size of the array.
202 #define BYTES_TO_STGWORDS(n) ((n) + sizeof(W_) - 1)/sizeof(W_)
204 #define newByteArray(ty,scale) \
205 FN_(new##ty##Arrayzh_fast) \
207 W_ stuff_size, size, n; \
210 MAYBE_GC(NO_PTRS,new##ty##Arrayzh_fast); \
212 stuff_size = BYTES_TO_STGWORDS(n*scale); \
213 size = sizeofW(StgArrWords)+ stuff_size; \
214 p = (StgArrWords *)RET_STGCALL1(P_,allocate,size); \
215 TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); \
216 SET_HDR(p, &ARR_WORDS_info, CCCS); \
217 p->words = stuff_size; \
218 TICK_RET_UNBOXED_TUP(1) \
223 newByteArray(Char, sizeof(C_))
224 newByteArray(Int, sizeof(I_));
225 newByteArray(Word, sizeof(W_));
226 newByteArray(Addr, sizeof(P_));
227 newByteArray(Float, sizeof(StgFloat));
228 newByteArray(Double, sizeof(StgDouble));
229 newByteArray(StablePtr, sizeof(StgStablePtr));
239 MAYBE_GC(R2_PTR,newArrayzh_fast);
241 size = sizeofW(StgMutArrPtrs) + n;
242 arr = (StgMutArrPtrs *)RET_STGCALL1(P_, allocate, size);
243 TICK_ALLOC_PRIM(sizeofW(StgMutArrPtrs), n, 0);
245 SET_HDR(arr,&MUT_ARR_PTRS_info,CCCS);
249 for (p = (P_)arr + sizeofW(StgMutArrPtrs);
250 p < (P_)arr + size; p++) {
254 TICK_RET_UNBOXED_TUP(1);
259 FN_(newMutVarzh_fast)
262 /* Args: R1.p = initialisation value */
265 HP_CHK_GEN(sizeofW(StgMutVar), R1_PTR, newMutVarzh_fast,);
266 TICK_ALLOC_PRIM(sizeofW(StgHeader)+1,1, 0); /* hack, dependent on rep. */
267 CCS_ALLOC(CCCS,sizeofW(StgMutVar));
269 mv = (StgMutVar *)(Hp-sizeofW(StgMutVar)+1);
270 SET_HDR(mv,&MUT_VAR_info,CCCS);
273 TICK_RET_UNBOXED_TUP(1);
278 /* -----------------------------------------------------------------------------
279 Foreign Object Primitives
281 -------------------------------------------------------------------------- */
284 FN_(makeForeignObjzh_fast)
286 /* R1.p = ptr to foreign object,
288 StgForeignObj *result;
291 HP_CHK_GEN(sizeofW(StgForeignObj), NO_PTRS, makeForeignObjzh_fast,);
292 TICK_ALLOC_PRIM(sizeofW(StgHeader),
293 sizeofW(StgForeignObj)-sizeofW(StgHeader), 0);
294 CCS_ALLOC(CCCS,sizeofW(StgForeignObj)); /* ccs prof */
296 result = (StgForeignObj *) (Hp + 1 - sizeofW(StgForeignObj));
297 SET_HDR(result,&FOREIGN_info,CCCS);
300 /* returns (# s#, ForeignObj# #) */
301 TICK_RET_UNBOXED_TUP(1);
307 /* -----------------------------------------------------------------------------
308 Weak Pointer Primitives
309 -------------------------------------------------------------------------- */
322 HP_CHK_GEN(sizeofW(StgWeak), R1_PTR|R2_PTR|R3_PTR, mkWeakzh_fast,);
323 TICK_ALLOC_PRIM(sizeofW(StgHeader)+1, // +1 is for the link field
324 sizeofW(StgWeak)-sizeofW(StgHeader)-1, 0);
325 CCS_ALLOC(CCCS,sizeofW(StgWeak)); /* ccs prof */
327 w = (StgWeak *) (Hp + 1 - sizeofW(StgWeak));
328 SET_HDR(w, &WEAK_info, CCCS);
333 w->finalizer = R3.cl;
335 w->finalizer = &NO_FINALIZER_closure;
338 w->link = weak_ptr_list;
340 IF_DEBUG(weak, fprintf(stderr,"New weak pointer at %p\n",w));
342 TICK_RET_UNBOXED_TUP(1);
347 FN_(finalizzeWeakzh_fast)
353 TICK_RET_UNBOXED_TUP(0);
357 if (w->header.info == &DEAD_WEAK_info) {
358 RET_NP(0,&NO_FINALIZER_closure);
362 w->header.info = &DEAD_WEAK_info;
364 /* return the finalizer */
365 if (w->finalizer == &NO_FINALIZER_closure) {
366 RET_NP(0,&NO_FINALIZER_closure);
368 RET_NP(1,w->finalizer);
375 /* -----------------------------------------------------------------------------
376 Arbitrary-precision Integer operations.
377 -------------------------------------------------------------------------- */
379 FN_(int2Integerzh_fast)
381 /* arguments: R1 = Int# */
383 I_ val, s; /* to avoid aliasing */
384 StgArrWords* p; /* address of array result */
388 HP_CHK_GEN(sizeofW(StgArrWords)+1, NO_PTRS, int2Integerzh_fast,);
389 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
390 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
392 p = stgCast(StgArrWords*,Hp)-1;
393 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, 1);
395 /* mpz_set_si is inlined here, makes things simpler */
399 } else if (val > 0) {
406 /* returns (# size :: Int#,
410 TICK_RET_UNBOXED_TUP(2);
415 FN_(word2Integerzh_fast)
417 /* arguments: R1 = Word# */
419 W_ val; /* to avoid aliasing */
421 StgArrWords* p; /* address of array result */
425 HP_CHK_GEN(sizeofW(StgArrWords)+1, NO_PTRS, word2Integerzh_fast,)
426 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
427 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
429 p = stgCast(StgArrWords*,Hp)-1;
430 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, 1);
439 /* returns (# size :: Int#,
443 TICK_RET_UNBOXED_TUP(2);
448 FN_(addr2Integerzh_fast)
454 MAYBE_GC(NO_PTRS,addr2Integerzh_fast);
456 /* args: R1 :: Addr# */
459 /* Perform the operation */
460 if (RET_STGCALL3(int, mpz_init_set_str,&result,(str),/*base*/10))
463 /* returns (# size :: Int#,
467 TICK_RET_UNBOXED_TUP(2);
468 RET_NP(result._mp_size,
469 result._mp_d - sizeofW(StgArrWords));
474 * 'long long' primops for converting to/from Integers.
477 #ifdef SUPPORT_LONG_LONGS
479 FN_(int64ToIntegerzh_fast)
481 /* arguments: L1 = Int64# */
483 StgInt64 val; /* to avoid aliasing */
485 I_ s, neg, words_needed;
486 StgArrWords* p; /* address of array result */
492 if ( val >= 0x100000000LL || val <= -0x100000000LL ) {
495 /* minimum is one word */
498 HP_CHK_GEN(sizeofW(StgArrWords)+words_needed, NO_PTRS, int64ToIntegerzh_fast,)
499 TICK_ALLOC_PRIM(sizeofW(StgArrWords),words_needed,0);
500 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+words_needed); /* ccs prof */
502 p = stgCast(StgArrWords*,(Hp-words_needed+1))-1;
503 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, words_needed);
510 hi = (W_)((LW_)val / 0x100000000ULL);
512 if ( words_needed == 2 ) {
516 } else if ( val != 0 ) {
519 } else /* val==0 */ {
522 s = ( neg ? -s : s );
524 /* returns (# size :: Int#,
528 TICK_RET_UNBOXED_TUP(2);
533 FN_(word64ToIntegerzh_fast)
535 /* arguments: L1 = Word64# */
537 StgNat64 val; /* to avoid aliasing */
540 StgArrWords* p; /* address of array result */
544 if ( val >= 0x100000000ULL ) {
549 HP_CHK_GEN(sizeofW(StgArrWords)+words_needed, NO_PTRS, word64ToIntegerzh_fast,)
550 TICK_ALLOC_PRIM(sizeofW(StgArrWords),words_needed,0);
551 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+words_needed); /* ccs prof */
553 p = stgCast(StgArrWords*,(Hp-words_needed+1))-1;
554 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, words_needed);
556 hi = (W_)((LW_)val / 0x100000000ULL);
557 if ( val >= 0x100000000ULL ) {
561 } else if ( val != 0 ) {
564 } else /* val==0 */ {
568 /* returns (# size :: Int#,
572 TICK_RET_UNBOXED_TUP(2);
578 #endif /* HAVE_LONG_LONG */
580 /* ToDo: this is shockingly inefficient */
582 #define GMP_TAKE2_RET1(name,mp_fun) \
585 MP_INT arg1, arg2, result; \
591 /* call doYouWantToGC() */ \
592 MAYBE_GC(R2_PTR | R4_PTR, name); \
594 d1 = (StgArrWords *)R2.p; \
596 d2 = (StgArrWords *)R4.p; \
599 arg1._mp_alloc = d1->words; \
600 arg1._mp_size = (s1); \
601 arg1._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d1)); \
602 arg2._mp_alloc = d2->words; \
603 arg2._mp_size = (s2); \
604 arg2._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d2)); \
606 STGCALL1(mpz_init,&result); \
608 /* Perform the operation */ \
609 STGCALL3(mp_fun,&result,&arg1,&arg2); \
611 TICK_RET_UNBOXED_TUP(2); \
612 RET_NP(result._mp_size, \
613 result._mp_d-sizeofW(StgArrWords)); \
617 #define GMP_TAKE2_RET2(name,mp_fun) \
620 MP_INT arg1, arg2, result1, result2; \
626 /* call doYouWantToGC() */ \
627 MAYBE_GC(R2_PTR | R4_PTR, name); \
629 d1 = (StgArrWords *)R2.p; \
631 d2 = (StgArrWords *)R4.p; \
634 arg1._mp_alloc = d1->words; \
635 arg1._mp_size = (s1); \
636 arg1._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d1)); \
637 arg2._mp_alloc = d2->words; \
638 arg2._mp_size = (s2); \
639 arg2._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d2)); \
641 STGCALL1(mpz_init,&result1); \
642 STGCALL1(mpz_init,&result2); \
644 /* Perform the operation */ \
645 STGCALL4(mp_fun,&result1,&result2,&arg1,&arg2); \
647 TICK_RET_UNBOXED_TUP(4); \
648 RET_NPNP(result1._mp_size, \
649 result1._mp_d-sizeofW(StgArrWords), \
651 result2._mp_d-sizeofW(StgArrWords)); \
655 GMP_TAKE2_RET1(plusIntegerzh_fast, mpz_add);
656 GMP_TAKE2_RET1(minusIntegerzh_fast, mpz_sub);
657 GMP_TAKE2_RET1(timesIntegerzh_fast, mpz_mul);
658 GMP_TAKE2_RET1(gcdIntegerzh_fast, mpz_gcd);
660 GMP_TAKE2_RET2(quotRemIntegerzh_fast, mpz_tdiv_qr);
661 GMP_TAKE2_RET2(divModIntegerzh_fast, mpz_fdiv_qr);
663 #ifndef FLOATS_AS_DOUBLES
664 FN_(decodeFloatzh_fast)
672 /* arguments: F1 = Float# */
675 HP_CHK_GEN(sizeof(StgArrWords)+1, NO_PTRS, decodeFloatzh_fast,);
676 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
677 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
679 /* Be prepared to tell Lennart-coded __decodeFloat */
680 /* where mantissa._mp_d can be put (it does not care about the rest) */
681 p = stgCast(StgArrWords*,Hp)-1;
682 SET_ARR_HDR(p,&ARR_WORDS_info,CCCS,1)
683 mantissa._mp_d = (void *)BYTE_ARR_CTS(p);
685 /* Perform the operation */
686 STGCALL3(__decodeFloat,&mantissa,&exponent,arg);
688 /* returns: (Int# (expn), Int#, ByteArray#) */
689 TICK_RET_UNBOXED_TUP(3);
690 RET_NNP(exponent,mantissa._mp_size,p);
693 #endif /* !FLOATS_AS_DOUBLES */
695 #define DOUBLE_MANTISSA_SIZE (sizeof(StgDouble)/sizeof(W_))
696 #define ARR_SIZE (sizeof(StgArrWords) + DOUBLE_MANTISSA_SIZE)
698 FN_(decodeDoublezh_fast)
705 /* arguments: D1 = Double# */
708 HP_CHK_GEN(ARR_SIZE, NO_PTRS, decodeDoublezh_fast,);
709 TICK_ALLOC_PRIM(sizeof(StgArrWords),DOUBLE_MANTISSA_SIZE,0);
710 CCS_ALLOC(CCCS,ARR_SIZE); /* ccs prof */
712 /* Be prepared to tell Lennart-coded __decodeDouble */
713 /* where mantissa.d can be put (it does not care about the rest) */
714 p = stgCast(StgArrWords*,Hp-ARR_SIZE+1);
715 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, DOUBLE_MANTISSA_SIZE);
716 mantissa._mp_d = (void *)BYTE_ARR_CTS(p);
718 /* Perform the operation */
719 STGCALL3(__decodeDouble,&mantissa,&exponent,arg);
721 /* returns: (Int# (expn), Int#, ByteArray#) */
722 TICK_RET_UNBOXED_TUP(3);
723 RET_NNP(exponent,mantissa._mp_size,p);
727 /* -----------------------------------------------------------------------------
728 * Concurrency primitives
729 * -------------------------------------------------------------------------- */
734 /* args: R1 = closure to spark */
736 if (closure_SHOULD_SPARK(stgCast(StgClosure*,R1.p))) {
738 MAYBE_GC(R1_PTR, forkzh_fast);
740 /* create it right now, return ThreadID in R1 */
741 R1.t = RET_STGCALL2(StgTSO *, createIOThread,
742 RtsFlags.GcFlags.initialStkSize, R1.cl);
744 /* switch at the earliest opportunity */
748 JMP_(ENTRY_CODE(Sp[0]));
752 FN_(killThreadzh_fast)
755 /* args: R1.p = TSO to kill */
757 /* The thread is dead, but the TSO sticks around for a while. That's why
758 * we don't have to explicitly remove it from any queues it might be on.
760 STGCALL1(deleteThread, (StgTSO *)R1.p);
762 /* We might have killed ourselves. In which case, better return to the
765 if ((StgTSO *)R1.p == CurrentTSO) {
766 JMP_(stg_stop_thread_entry); /* leave semi-gracefully */
769 JMP_(ENTRY_CODE(Sp[0]));
780 HP_CHK_GEN(sizeofW(StgMVar), NO_PTRS, newMVarzh_fast,);
781 TICK_ALLOC_PRIM(sizeofW(StgMutVar)-1, // consider head,tail,link as admin wds
783 CCS_ALLOC(CCCS,sizeofW(StgMVar)); /* ccs prof */
785 mvar = (StgMVar *) (Hp - sizeofW(StgMVar) + 1);
786 SET_INFO(mvar,&EMPTY_MVAR_info);
787 mvar->head = mvar->tail = (StgTSO *)&END_TSO_QUEUE_closure;
788 mvar->value = (StgClosure *)&END_TSO_QUEUE_closure;
790 TICK_RET_UNBOXED_TUP(1);
801 /* args: R1 = MVar closure */
803 mvar = (StgMVar *)R1.p;
805 /* If the MVar is empty, put ourselves on its blocking queue,
806 * and wait until we're woken up.
808 if (GET_INFO(mvar) != &FULL_MVAR_info) {
809 if (mvar->head == (StgTSO *)&END_TSO_QUEUE_closure) {
810 mvar->head = CurrentTSO;
812 mvar->tail->link = CurrentTSO;
814 CurrentTSO->link = (StgTSO *)&END_TSO_QUEUE_closure;
815 mvar->tail = CurrentTSO;
817 BLOCK(R1_PTR, takeMVarzh_fast);
820 SET_INFO(mvar,&EMPTY_MVAR_info);
822 mvar->value = (StgClosure *)&END_TSO_QUEUE_closure;
824 TICK_RET_UNBOXED_TUP(1);
835 /* args: R1 = MVar, R2 = value */
837 mvar = (StgMVar *)R1.p;
838 if (GET_INFO(mvar) == &FULL_MVAR_info) {
840 fprintf(stderr, "putMVar#: MVar already full.\n");
841 stg_exit(EXIT_FAILURE);
844 SET_INFO(mvar,&FULL_MVAR_info);
847 /* wake up the first thread on the queue,
848 * it will continue with the takeMVar operation and mark the MVar
852 if (tso != (StgTSO *)&END_TSO_QUEUE_closure) {
853 PUSH_ON_RUN_QUEUE(tso);
854 mvar->head = tso->link;
855 tso->link = (StgTSO *)&END_TSO_QUEUE_closure;
856 if (mvar->head == (StgTSO *)&END_TSO_QUEUE_closure) {
857 mvar->tail = (StgTSO *)&END_TSO_QUEUE_closure;
861 /* ToDo: yield here for better communication performance? */
862 JMP_(ENTRY_CODE(Sp[0]));
866 /* -----------------------------------------------------------------------------
867 Stable pointer primitives
868 ------------------------------------------------------------------------- */
870 FN_(makeStableNamezh_fast)
873 StgStableName *sn_obj;
876 HP_CHK_GEN(sizeofW(StgStableName), R1_PTR, makeStableNamezh_fast,);
877 TICK_ALLOC_PRIM(sizeofW(StgHeader),
878 sizeofW(StgStableName)-sizeofW(StgHeader), 0);
879 CCS_ALLOC(CCCS,sizeofW(StgStableName)); /* ccs prof */
881 index = RET_STGCALL1(StgWord,lookupStableName,R1.p);
883 sn_obj = (StgStableName *) (Hp - sizeofW(StgStableName) + 1);
884 sn_obj->header.info = &STABLE_NAME_info;
887 TICK_RET_UNBOXED_TUP(1);
891 #endif /* COMPILER */