1 \section[stable-ptr-ops]{Stable Pointer Operations}
3 The code that implements @performIO@ is mostly in
4 @ghc/runtime/c-as-asm/PerformIO.lhc@. However, this code can be
5 called from the C world so it goes in a @.lc@ file.
7 This code is based heavily on the code in @ghc/runtime/main/main.lc@.
9 It is used to call a (stable pointer to a) function of type
10 @IoWorld -> PrimIntAndIoWorld@ (ie @PrimIO_Int#@).
12 (I doubt very much that this works at the moment - and we're going to
13 change it to take/return a byte array anyway. Code in PerformIO.lhc
21 extern StgPtr unstable_Closure;
23 #ifndef __STG_TAILJUMPS__
24 extern int doSanityChks;
25 extern void checkAStack(STG_NO_ARGS);
29 enterStablePtr(stableIndex, startCode)
30 StgStablePtr stableIndex;
33 unstable_Closure = _deRefStablePointer(stableIndex, StorageMgrInfo.StablePointerTable);
35 /* ToDo: Set arity to right value - if necessary */
37 #if defined(__STG_TAILJUMPS__)
38 miniInterpret(startCode);
41 miniInterpret_debug(startCode, checkAStack);
43 miniInterpret(startCode);
44 #endif /* not tail-jumping */
50 EXTFUN(startPerformIO);
52 extern void checkInCCallGC(STG_NO_ARGS);
55 performIO(stableIndex)
56 StgStablePtr stableIndex;
59 enterStablePtr( stableIndex, (StgFunPtr) startPerformIO );
62 extern StgInt enterInt_Result;
63 EXTFUN(startEnterInt);
67 StgStablePtr stableIndex;
70 enterStablePtr( stableIndex, (StgFunPtr) startEnterInt );
71 return enterInt_Result;
74 extern StgFloat enterFloat_Result;
75 EXTFUN(startEnterFloat);
78 enterFloat(stableIndex)
79 StgStablePtr stableIndex;
82 enterStablePtr( stableIndex, (StgFunPtr) startEnterFloat );
83 return enterFloat_Result;
89 deRefStablePointer(stableIndex)
90 StgStablePtr stableIndex;
92 return _deRefStablePointer(stableIndex, StorageMgrInfo.StablePointerTable);
96 Despite the file name, we have two small malloc ptr operation - not
97 worth putting in a file by itself.
109 And some code that HAS NO RIGHT being here.
112 StgStablePtr softHeapOverflowHandler = -1;
115 catchSoftHeapOverflow( newHandler, deltaLimit )
116 StgStablePtr newHandler;
119 StgStablePtr oldHandler = softHeapOverflowHandler;
121 /* If we're in a _ccall_GC_ then HpLim will be stored in SAVE_HpLim
122 which provides an easy way of changing it. */
125 StorageMgrInfo.hardHpOverflowSize += deltaLimit;
126 SAVE_HpLim -= deltaLimit;
128 if (StorageMgrInfo.hardHpOverflowSize < 0) {
129 fprintf(stderr, "Error: Setting Hard Heap Overflow Size to negative value!\n");
133 softHeapOverflowHandler = newHandler;
138 getSoftHeapOverflowHandler(STG_NO_ARGS)
140 return (StgInt) softHeapOverflowHandler;