1 /* -----------------------------------------------------------------------------
2 * $Id: PrimOps.hc,v 1.12 1999/02/05 15:25:09 simonm Exp $
4 * Primitive functions / data
6 * ---------------------------------------------------------------------------*/
13 #include "StgStartup.h"
18 #include "BlockAlloc.h" /* tmp */
19 #include "StablePriv.h"
23 classes CCallable and CReturnable don't really exist, but the
24 compiler insists on generating dictionaries containing references
25 to GHC_ZcCCallable_static_info etc., so we provide dummy symbols
29 W_ GHC_ZCCCallable_static_info[0];
30 W_ GHC_ZCCReturnable_static_info[0];
32 #ifndef aix_TARGET_OS /* AIX gives link errors with this as a const (RO assembler section) */
35 StgClosure *PrelBase_Bool_closure_tbl[] = {
40 /* -----------------------------------------------------------------------------
41 Macros for Hand-written primitives.
42 -------------------------------------------------------------------------- */
45 * Horrible macros for returning unboxed tuples.
47 * How an unboxed tuple is returned depends on two factors:
48 * - the number of real registers we have available
49 * - the boxedness of the returned fields.
51 * To return an unboxed tuple from a primitive operation, we have macros
52 * RET_<layout> where <layout> describes the boxedness of each field of the
53 * unboxed tuple: N indicates a non-pointer field, and P indicates a pointer.
55 * We only define the cases actually used, to avoid having too much
56 * garbage in this section. Warning: any bugs in here will be hard to
60 /*------ All Regs available */
62 # define RET_P(a) R1.w = (W_)(a); JMP_(ENTRY_CODE(Sp[0]));
63 # define RET_N(a) RET_P(a)
65 # define RET_PP(a,b) R1.w = (W_)(a); R2.w = (W_)(b); JMP_(ENTRY_CODE(Sp[0]));
66 # define RET_NN(a,b) RET_PP(a,b)
67 # define RET_NP(a,b) RET_PP(a,b)
69 # define RET_PPP(a,b,c) \
70 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); JMP_(ENTRY_CODE(Sp[0]));
71 # define RET_NNP(a,b,c) RET_PPP(a,b,c)
73 # define RET_NNNP(a,b,c,d) \
74 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); R4.w = (W_)d; \
75 JMP_(ENTRY_CODE(Sp[0]));
77 # define RET_NNPNNP(a,b,c,d,e,f) \
78 R1.w = (W_)(a); R2.w = (W_)(b); R3.w = (W_)(c); \
79 R4.w = (W_)(d); R5.w = (W_)(e); R6.w = (W_)(f); \
80 JMP_(ENTRY_CODE(Sp[0]));
84 #if defined(REG_R7) || defined(REG_R6) || defined(REG_R5) || \
85 defined(REG_R4) || defined(REG_R3) || defined(REG_R2)
86 # error RET_n macros not defined for this setup.
89 /*------ 1 Register available */
91 # define RET_P(a) R1.w = (W_)(a); JMP_(ENTRY_CODE(Sp[0]));
92 # define RET_N(a) RET_P(a)
94 # define RET_PP(a,b) R1.w = (W_)(a); Sp[-1] = (W_)(b); Sp -= 1; \
95 JMP_(ENTRY_CODE(Sp[1]));
96 # define RET_NN(a,b) R1.w = (W_)(a); Sp[-1] = (W_)(b); Sp -= 2; \
97 JMP_(ENTRY_CODE(Sp[2]));
98 # define RET_NP(a,b) RET_PP(a,b)
100 # define RET_PPP(a,b,c) \
101 R1.w = (W_)(a); Sp[-2] = (W_)(b); Sp[-1] = (W_)(c); Sp -= 2; \
102 JMP_(ENTRY_CODE(Sp[2]));
103 # define RET_NNP(a,b,c) \
104 R1.w = (W_)(a); Sp[-2] = (W_)(b); Sp[-1] = (W_)(c); Sp -= 3; \
105 JMP_(ENTRY_CODE(Sp[3]));
107 # define RET_NNNP(a,b,c,d) \
109 /* Sp[-5] = ARGTAG(1); */ \
111 /* Sp[-3] = ARGTAG(1); */ \
115 JMP_(ENTRY_CODE(Sp[5]));
117 # define RET_NNPNNP(a,b,c,d,e,f) \
121 /* Sp[-3] = ARGTAG(1); */ \
123 /* Sp[-5] = ARGTAG(1); */ \
126 /* Sp[-8] = ARGTAG(1); */ \
128 JMP_(ENTRY_CODE(Sp[8]));
130 #else /* 0 Regs available */
132 #define PUSH_P(o,x) Sp[-o] = (W_)(x)
133 #define PUSH_N(o,x) Sp[1-o] = (W_)(x); /* Sp[-o] = ARGTAG(1) */
134 #define PUSHED(m) Sp -= (m); JMP_(ENTRY_CODE(Sp[m]));
136 /* Here's how to construct these macros:
138 * N = number of N's in the name;
139 * P = number of P's in the name;
141 * while (nonNull(name)) {
142 * if (nextChar == 'P') {
153 # define RET_P(a) PUSH_P(1,a); PUSHED(1)
154 # define RET_N(a) PUSH_N(2,a); PUSHED(2)
156 # define RET_PP(a,b) PUSH_P(2,a); PUSH_P(1,b); PUSHED(2)
157 # define RET_NN(a,b) PUSH_N(4,a); PUSH_N(2,b); PUSHED(4)
158 # define RET_NP(a,b) PUSH_N(3,a); PUSH_P(1,b); PUSHED(3)
160 # define RET_PPP(a,b,c) PUSH_P(3,a); PUSH_P(2,b); PUSH_P(1,c); PUSHED(3)
161 # define RET_NNP(a,b,c) PUSH_N(6,a); PUSH_N(4,b); PUSH_N(2,c); PUSHED(6)
163 # 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)
164 # 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)
171 /*-----------------------------------------------------------------------------
174 Basically just new*Array - the others are all inline macros.
176 The size arg is always passed in R1, and the result returned in R1.
178 The slow entry point is for returning from a heap check, the saved
179 size argument must be re-loaded from the stack.
180 -------------------------------------------------------------------------- */
182 /* for objects that are *less* than the size of a word, make sure we
183 * round up to the nearest word for the size of the array.
186 #define BYTES_TO_STGWORDS(n) ((n) + sizeof(W_) - 1)/sizeof(W_)
188 #define newByteArray(ty,scale) \
189 FN_(new##ty##Arrayzh_fast) \
191 W_ stuff_size, size, n; \
194 MAYBE_GC(NO_PTRS,new##ty##Arrayzh_fast); \
196 stuff_size = BYTES_TO_STGWORDS(n*scale); \
197 size = sizeofW(StgArrWords)+ stuff_size; \
198 p = (StgArrWords *)RET_STGCALL1(P_,allocate,size); \
199 TICK_ALLOC_PRIM(sizeofW(StgArrWords),stuff_size,0); \
200 SET_HDR(p, &ARR_WORDS_info, CCCS); \
201 p->words = stuff_size; \
202 TICK_RET_UNBOXED_TUP(1) \
207 newByteArray(Char, sizeof(C_))
208 newByteArray(Int, sizeof(I_));
209 newByteArray(Word, sizeof(W_));
210 newByteArray(Addr, sizeof(P_));
211 newByteArray(Float, sizeof(StgFloat));
212 newByteArray(Double, sizeof(StgDouble));
213 newByteArray(StablePtr, sizeof(StgStablePtr));
223 MAYBE_GC(R2_PTR,newArrayzh_fast);
225 size = sizeofW(StgMutArrPtrs) + n;
226 arr = (StgMutArrPtrs *)RET_STGCALL1(P_, allocate, size);
227 TICK_ALLOC_PRIM(sizeofW(StgMutArrPtrs), n, 0);
229 SET_HDR(arr,&MUT_ARR_PTRS_info,CCCS);
233 for (p = (P_)arr + sizeofW(StgMutArrPtrs);
234 p < (P_)arr + size; p++) {
238 TICK_RET_UNBOXED_TUP(1);
243 FN_(newMutVarzh_fast)
246 /* Args: R1.p = initialisation value */
249 HP_CHK_GEN(sizeofW(StgMutVar), R1_PTR, newMutVarzh_fast,);
250 TICK_ALLOC_PRIM(sizeofW(StgHeader)+1,1, 0); /* hack, dependent on rep. */
251 CCS_ALLOC(CCCS,sizeofW(StgMutVar));
253 mv = (StgMutVar *)(Hp-sizeofW(StgMutVar)+1);
254 SET_HDR(mv,&MUT_VAR_info,CCCS);
257 TICK_RET_UNBOXED_TUP(1);
262 /* -----------------------------------------------------------------------------
263 Foreign Object Primitives
265 -------------------------------------------------------------------------- */
268 FN_(makeForeignObjzh_fast)
270 /* R1.p = ptr to foreign object,
272 StgForeignObj *result;
275 HP_CHK_GEN(sizeofW(StgForeignObj), NO_PTRS, makeForeignObjzh_fast,);
276 TICK_ALLOC_PRIM(sizeofW(StgHeader),
277 sizeofW(StgForeignObj)-sizeofW(StgHeader), 0);
278 CCS_ALLOC(CCCS,sizeofW(StgForeignObj)); /* ccs prof */
280 result = (StgForeignObj *) (Hp + 1 - sizeofW(StgForeignObj));
281 SET_HDR(result,&FOREIGN_info,CCCS);
284 /* returns (# s#, ForeignObj# #) */
285 TICK_RET_UNBOXED_TUP(1);
291 /* -----------------------------------------------------------------------------
292 Weak Pointer Primitives
293 -------------------------------------------------------------------------- */
306 HP_CHK_GEN(sizeofW(StgWeak), R1_PTR|R2_PTR|R3_PTR, mkWeakzh_fast,);
307 TICK_ALLOC_PRIM(sizeofW(StgHeader)+1, // +1 is for the link field
308 sizeofW(StgWeak)-sizeofW(StgHeader)-1, 0);
309 CCS_ALLOC(CCCS,sizeofW(StgWeak)); /* ccs prof */
311 w = (StgWeak *) (Hp + 1 - sizeofW(StgWeak));
312 SET_HDR(w, &WEAK_info, CCCS);
317 w->finaliser = R3.cl;
319 w->finaliser = &NO_FINALISER_closure;
322 w->link = weak_ptr_list;
324 IF_DEBUG(weak, fprintf(stderr,"New weak pointer at %p\n",w));
326 TICK_RET_UNBOXED_TUP(1);
331 FN_(finaliseWeakzh_fast)
337 TICK_RET_UNBOXED_TUP(0);
340 if (w->finaliser != &NO_FINALISER_closure) {
342 STGCALL2(createGenThread, RtsFlags.GcFlags.initialStkSize, w->finaliser);
344 STGCALL2(createIOThread, RtsFlags.GcFlags.initialStkSize, w->finaliser);
347 w->header.info = &DEAD_WEAK_info;
349 JMP_(ENTRY_CODE(Sp[0]));
355 /* -----------------------------------------------------------------------------
356 Arbitrary-precision Integer operations.
357 -------------------------------------------------------------------------- */
359 FN_(int2Integerzh_fast)
361 /* arguments: R1 = Int# */
363 I_ val, s; /* to avoid aliasing */
364 StgArrWords* p; /* address of array result */
368 HP_CHK_GEN(sizeofW(StgArrWords)+1, NO_PTRS, int2Integerzh_fast,);
369 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
370 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
372 p = stgCast(StgArrWords*,Hp)-1;
373 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, 1);
375 /* mpz_set_si is inlined here, makes things simpler */
379 } else if (val > 0) {
386 /* returns (# alloc :: Int#,
391 TICK_RET_UNBOXED_TUP(3);
396 FN_(word2Integerzh_fast)
398 /* arguments: R1 = Word# */
400 W_ val; /* to avoid aliasing */
402 StgArrWords* p; /* address of array result */
406 HP_CHK_GEN(sizeofW(StgArrWords)+1, NO_PTRS, word2Integerzh_fast,)
407 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
408 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
410 p = stgCast(StgArrWords*,Hp)-1;
411 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, 1);
420 /* returns (# alloc :: Int#,
425 TICK_RET_UNBOXED_TUP(3);
430 FN_(addr2Integerzh_fast)
436 MAYBE_GC(NO_PTRS,addr2Integerzh_fast);
438 /* args: R1 :: Addr# */
441 /* Perform the operation */
442 if (RET_STGCALL3(int, mpz_init_set_str,&result,(str),/*base*/10))
445 TICK_RET_UNBOXED_TUP(3);
446 RET_NNP(result._mp_alloc, result._mp_size,
447 result._mp_d - sizeofW(StgArrWords));
452 * 'long long' primops for converting to/from Integers.
455 #ifdef SUPPORT_LONG_LONGS
457 FN_(int64ToIntegerzh_fast)
459 /* arguments: L1 = Int64# */
461 StgInt64 val; /* to avoid aliasing */
463 I_ s,a, neg, words_needed;
464 StgArrWords* p; /* address of array result */
470 if ( val >= 0x100000000LL || val <= -0x100000000LL ) {
473 /* minimum is one word */
476 HP_CHK_GEN(sizeofW(StgArrWords)+words_needed, NO_PTRS, int64ToIntegerzh_fast,)
477 TICK_ALLOC_PRIM(sizeofW(StgArrWords),words_needed,0);
478 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+words_needed); /* ccs prof */
480 p = stgCast(StgArrWords*,(Hp-words_needed+1))-1;
481 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, words_needed);
490 hi = (W_)((LW_)val / 0x100000000ULL);
496 } else if ( val != 0 ) {
499 } else /* val==0 */ {
502 s = ( neg ? -s : s );
504 /* returns (# alloc :: Int#,
509 TICK_RET_UNBOXED_TUP(3);
514 FN_(word64ToIntegerzh_fast)
516 /* arguments: L1 = Word64# */
518 StgNat64 val; /* to avoid aliasing */
521 StgArrWords* p; /* address of array result */
525 if ( val >= 0x100000000ULL ) {
530 HP_CHK_GEN(sizeofW(StgArrWords)+words_needed, NO_PTRS, word64ToIntegerzh_fast,)
531 TICK_ALLOC_PRIM(sizeofW(StgArrWords),words_needed,0);
532 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+words_needed); /* ccs prof */
534 p = stgCast(StgArrWords*,(Hp-words_needed+1))-1;
535 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, words_needed);
539 hi = (W_)((LW_)val / 0x100000000ULL);
540 if ( val >= 0x100000000ULL ) {
544 } else if ( val != 0 ) {
547 } else /* val==0 */ {
551 /* returns (# alloc :: Int#,
556 TICK_RET_UNBOXED_TUP(3);
562 #endif /* HAVE_LONG_LONG */
564 /* ToDo: this is shockingly inefficient */
566 #define GMP_TAKE2_RET1(name,mp_fun) \
569 MP_INT arg1, arg2, result; \
575 /* call doYouWantToGC() */ \
576 MAYBE_GC(R3_PTR | R6_PTR, name); \
580 d1 = stgCast(StgArrWords*,R3.p); \
583 d2 = stgCast(StgArrWords*,R6.p); \
585 arg1._mp_alloc = (a1); \
586 arg1._mp_size = (s1); \
587 arg1._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d1)); \
588 arg2._mp_alloc = (a2); \
589 arg2._mp_size = (s2); \
590 arg2._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d2)); \
592 STGCALL1(mpz_init,&result); \
594 /* Perform the operation */ \
595 STGCALL3(mp_fun,&result,&arg1,&arg2); \
597 TICK_RET_UNBOXED_TUP(3); \
598 RET_NNP(result._mp_alloc, \
600 result._mp_d-sizeofW(StgArrWords)); \
604 #define GMP_TAKE2_RET2(name,mp_fun) \
607 MP_INT arg1, arg2, result1, result2; \
613 /* call doYouWantToGC() */ \
614 MAYBE_GC(R3_PTR | R6_PTR, name); \
618 d1 = stgCast(StgArrWords*,R3.p); \
621 d2 = stgCast(StgArrWords*,R6.p); \
623 arg1._mp_alloc = (a1); \
624 arg1._mp_size = (s1); \
625 arg1._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d1)); \
626 arg2._mp_alloc = (a2); \
627 arg2._mp_size = (s2); \
628 arg2._mp_d = (unsigned long int *) (BYTE_ARR_CTS(d2)); \
630 STGCALL1(mpz_init,&result1); \
631 STGCALL1(mpz_init,&result2); \
633 /* Perform the operation */ \
634 STGCALL4(mp_fun,&result1,&result2,&arg1,&arg2); \
636 TICK_RET_UNBOXED_TUP(6); \
637 RET_NNPNNP(result1._mp_alloc, \
639 result1._mp_d-sizeofW(StgArrWords), \
642 result2._mp_d-sizeofW(StgArrWords)); \
646 GMP_TAKE2_RET1(plusIntegerzh_fast, mpz_add);
647 GMP_TAKE2_RET1(minusIntegerzh_fast, mpz_sub);
648 GMP_TAKE2_RET1(timesIntegerzh_fast, mpz_mul);
649 GMP_TAKE2_RET1(gcdIntegerzh_fast, mpz_gcd);
651 GMP_TAKE2_RET2(quotRemIntegerzh_fast, mpz_tdiv_qr);
652 GMP_TAKE2_RET2(divModIntegerzh_fast, mpz_fdiv_qr);
654 #ifndef FLOATS_AS_DOUBLES
655 FN_(decodeFloatzh_fast)
663 /* arguments: F1 = Float# */
666 HP_CHK_GEN(sizeof(StgArrWords)+1, NO_PTRS, decodeFloatzh_fast,);
667 TICK_ALLOC_PRIM(sizeofW(StgArrWords),1,0);
668 CCS_ALLOC(CCCS,sizeofW(StgArrWords)+1); /* ccs prof */
670 /* Be prepared to tell Lennart-coded __decodeFloat */
671 /* where mantissa._mp_d can be put (it does not care about the rest) */
672 p = stgCast(StgArrWords*,Hp)-1;
673 SET_ARR_HDR(p,&ARR_WORDS_info,CCCS,1)
674 mantissa._mp_d = (void *)BYTE_ARR_CTS(p);
676 /* Perform the operation */
677 STGCALL3(__decodeFloat,&mantissa,&exponent,arg);
679 /* returns: (R1 = Int# (expn), R2 = Int#, R3 = Int#, R4 = ByteArray#) */
680 TICK_RET_UNBOXED_TUP(4);
681 RET_NNNP(exponent,mantissa._mp_alloc,mantissa._mp_size,p);
684 #endif /* !FLOATS_AS_DOUBLES */
686 #define DOUBLE_MANTISSA_SIZE (sizeof(StgDouble)/sizeof(W_))
687 #define ARR_SIZE (sizeof(StgArrWords) + DOUBLE_MANTISSA_SIZE)
689 FN_(decodeDoublezh_fast)
696 /* arguments: D1 = Double# */
699 HP_CHK_GEN(ARR_SIZE, NO_PTRS, decodeDoublezh_fast,);
700 TICK_ALLOC_PRIM(sizeof(StgArrWords),DOUBLE_MANTISSA_SIZE,0);
701 CCS_ALLOC(CCCS,ARR_SIZE); /* ccs prof */
703 /* Be prepared to tell Lennart-coded __decodeDouble */
704 /* where mantissa.d can be put (it does not care about the rest) */
705 p = stgCast(StgArrWords*,Hp-ARR_SIZE+1);
706 SET_ARR_HDR(p, &ARR_WORDS_info, CCCS, DOUBLE_MANTISSA_SIZE);
707 mantissa._mp_d = (void *)BYTE_ARR_CTS(p);
709 /* Perform the operation */
710 STGCALL3(__decodeDouble,&mantissa,&exponent,arg);
712 /* returns: (R1 = Int# (expn), R2 = Int#, R3 = Int#, R4 = ByteArray#) */
713 TICK_RET_UNBOXED_TUP(4);
714 RET_NNNP(exponent,mantissa._mp_alloc,mantissa._mp_size,p);
718 /* -----------------------------------------------------------------------------
719 * Concurrency primitives
720 * -------------------------------------------------------------------------- */
725 /* args: R1 = closure to spark */
727 if (closure_SHOULD_SPARK(stgCast(StgClosure*,R1.p))) {
729 MAYBE_GC(R1_PTR, forkzh_fast);
731 /* create it right now, return ThreadID in R1 */
732 R1.t = RET_STGCALL2(StgTSO *, createIOThread,
733 RtsFlags.GcFlags.initialStkSize, R1.cl);
735 /* switch at the earliest opportunity */
739 JMP_(ENTRY_CODE(Sp[0]));
743 FN_(killThreadzh_fast)
746 /* args: R1.p = TSO to kill */
748 /* The thread is dead, but the TSO sticks around for a while. That's why
749 * we don't have to explicitly remove it from any queues it might be on.
751 STGCALL1(deleteThread, (StgTSO *)R1.p);
753 /* We might have killed ourselves. In which case, better return to the
756 if ((StgTSO *)R1.p == CurrentTSO) {
757 JMP_(stg_stop_thread_entry); /* leave semi-gracefully */
760 JMP_(ENTRY_CODE(Sp[0]));
771 HP_CHK_GEN(sizeofW(StgMVar), NO_PTRS, newMVarzh_fast,);
772 TICK_ALLOC_PRIM(sizeofW(StgMutVar)-1, // consider head,tail,link as admin wds
774 CCS_ALLOC(CCCS,sizeofW(StgMVar)); /* ccs prof */
776 mvar = (StgMVar *) (Hp - sizeofW(StgMVar) + 1);
777 SET_INFO(mvar,&EMPTY_MVAR_info);
778 mvar->head = mvar->tail = (StgTSO *)&END_TSO_QUEUE_closure;
779 mvar->value = (StgClosure *)&END_TSO_QUEUE_closure;
781 TICK_RET_UNBOXED_TUP(1);
792 /* args: R1 = MVar closure */
794 mvar = (StgMVar *)R1.p;
796 /* If the MVar is empty, put ourselves on its blocking queue,
797 * and wait until we're woken up.
799 if (GET_INFO(mvar) != &FULL_MVAR_info) {
800 if (mvar->head == (StgTSO *)&END_TSO_QUEUE_closure) {
801 mvar->head = CurrentTSO;
803 mvar->tail->link = CurrentTSO;
805 CurrentTSO->link = (StgTSO *)&END_TSO_QUEUE_closure;
806 mvar->tail = CurrentTSO;
808 BLOCK(R1_PTR, takeMVarzh_fast);
811 SET_INFO(mvar,&EMPTY_MVAR_info);
813 mvar->value = (StgClosure *)&END_TSO_QUEUE_closure;
815 TICK_RET_UNBOXED_TUP(1);
826 /* args: R1 = MVar, R2 = value */
828 mvar = (StgMVar *)R1.p;
829 if (GET_INFO(mvar) == &FULL_MVAR_info) {
831 fprintf(stderr, "putMVar#: MVar already full.\n");
832 stg_exit(EXIT_FAILURE);
835 SET_INFO(mvar,&FULL_MVAR_info);
838 /* wake up the first thread on the queue,
839 * it will continue with the takeMVar operation and mark the MVar
843 if (tso != (StgTSO *)&END_TSO_QUEUE_closure) {
844 PUSH_ON_RUN_QUEUE(tso);
845 mvar->head = tso->link;
846 tso->link = (StgTSO *)&END_TSO_QUEUE_closure;
847 if (mvar->head == (StgTSO *)&END_TSO_QUEUE_closure) {
848 mvar->tail = (StgTSO *)&END_TSO_QUEUE_closure;
852 /* ToDo: yield here for better communication performance? */
853 JMP_(ENTRY_CODE(Sp[0]));
857 /* -----------------------------------------------------------------------------
858 Stable pointer primitives
859 ------------------------------------------------------------------------- */
861 FN_(makeStableNamezh_fast)
864 StgStableName *sn_obj;
867 HP_CHK_GEN(sizeofW(StgStableName), R1_PTR, makeStableNamezh_fast,);
868 TICK_ALLOC_PRIM(sizeofW(StgHeader),
869 sizeofW(StgStableName)-sizeofW(StgHeader), 0);
870 CCS_ALLOC(CCCS,sizeofW(StgStableName)); /* ccs prof */
872 index = RET_STGCALL1(StgWord,lookupStableName,R1.p);
874 sn_obj = (StgStableName *) (Hp - sizeofW(StgStableName) + 1);
875 sn_obj->header.info = &STABLE_NAME_info;
878 TICK_RET_UNBOXED_TUP(1);
882 #endif /* COMPILER */