blob: 9752a534bb8d17764e960a20ded1530913bd3616 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 1998-2004
*
* Stable Pointers: A stable pointer is represented as an index into
* the stable pointer table in the low BITS_PER_WORD-8 bits with a
* weight in the upper 8 bits.
*
* SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers
* are guaranteed to be void* on the C-side, so we have to do some occasional
* casting. Size is not a matter, because StgWord is always the same size as
* a void*.
*
* ---------------------------------------------------------------------------*/
#ifndef STABLE_H
#define STABLE_H
/* -----------------------------------------------------------------------------
External C Interface
-------------------------------------------------------------------------- */
EXTERN_INLINE StgPtr deRefStablePtr(StgStablePtr stable_ptr);
extern void freeStablePtr(StgStablePtr sp);
extern StgStablePtr splitStablePtr(StgStablePtr sp);
extern StgStablePtr getStablePtr(StgPtr p);
/* -----------------------------------------------------------------------------
PRIVATE from here.
-------------------------------------------------------------------------- */
typedef struct {
StgPtr addr; /* Haskell object, free list, or NULL */
StgPtr old; /* old Haskell object, used during GC */
StgWord ref; /* used for reference counting */
StgClosure *sn_obj; /* the StableName object (or NULL) */
} snEntry;
extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
extern void freeStablePtr(StgStablePtr sp);
EXTERN_INLINE
StgPtr deRefStablePtr(StgStablePtr sp)
{
ASSERT(stable_ptr_table[(StgWord)sp].ref > 0);
return stable_ptr_table[(StgWord)sp].addr;
}
extern void initStablePtrTable ( void );
extern void exitStablePtrTable ( void );
extern void enlargeStablePtrTable ( void );
extern StgWord lookupStableName ( StgPtr p );
extern void markStablePtrTable ( evac_fn evac, void *user );
extern void threadStablePtrTable ( evac_fn evac, void *user );
extern void gcStablePtrTable ( void );
extern void updateStablePtrTable ( rtsBool full );
extern void stablePtrPreGC ( void );
extern void stablePtrPostGC ( void );
#endif
|