diff options
Diffstat (limited to 'includes/rts')
-rw-r--r-- | includes/rts/Constants.h | 27 | ||||
-rw-r--r-- | includes/rts/Globals.h | 1 | ||||
-rw-r--r-- | includes/rts/PrimFloat.h | 2 | ||||
-rw-r--r-- | includes/rts/Utils.h | 5 | ||||
-rw-r--r-- | includes/rts/storage/Closures.h | 14 | ||||
-rw-r--r-- | includes/rts/storage/GC.h | 10 | ||||
-rw-r--r-- | includes/rts/storage/SMPClosureOps.h | 77 |
7 files changed, 91 insertions, 45 deletions
diff --git a/includes/rts/Constants.h b/includes/rts/Constants.h index 5ff4d4e51e..494abe2b22 100644 --- a/includes/rts/Constants.h +++ b/includes/rts/Constants.h @@ -84,7 +84,7 @@ #define MAX_FLOAT_REG 6 #define MAX_DOUBLE_REG 6 #define MAX_LONG_REG 1 -#define MAX_SSE_REG 6 +#define MAX_XMM_REG 6 /* ----------------------------------------------------------------------------- Semi-Tagging constants @@ -202,31 +202,32 @@ */ #define NotBlocked 0 #define BlockedOnMVar 1 -#define BlockedOnBlackHole 2 -#define BlockedOnRead 3 -#define BlockedOnWrite 4 -#define BlockedOnDelay 5 -#define BlockedOnSTM 6 +#define BlockedOnMVarRead 2 +#define BlockedOnBlackHole 3 +#define BlockedOnRead 4 +#define BlockedOnWrite 5 +#define BlockedOnDelay 6 +#define BlockedOnSTM 7 /* Win32 only: */ -#define BlockedOnDoProc 7 +#define BlockedOnDoProc 8 /* Only relevant for PAR: */ /* blocked on a remote closure represented by a Global Address: */ -#define BlockedOnGA 8 +#define BlockedOnGA 9 /* same as above but without sending a Fetch message */ -#define BlockedOnGA_NoSend 9 +#define BlockedOnGA_NoSend 10 /* Only relevant for THREADED_RTS: */ -#define BlockedOnCCall 10 -#define BlockedOnCCall_Interruptible 11 +#define BlockedOnCCall 11 +#define BlockedOnCCall_Interruptible 12 /* same as above but permit killing the worker thread */ /* Involved in a message sent to tso->msg_cap */ -#define BlockedOnMsgThrowTo 12 +#define BlockedOnMsgThrowTo 13 /* The thread is not on any run queues, but can be woken up by tryWakeupThread() */ -#define ThreadMigrating 13 +#define ThreadMigrating 14 /* * These constants are returned to the scheduler by a thread that has diff --git a/includes/rts/Globals.h b/includes/rts/Globals.h index 720d9674cc..d0d34ef981 100644 --- a/includes/rts/Globals.h +++ b/includes/rts/Globals.h @@ -25,5 +25,6 @@ StgStablePtr getOrSetSystemEventThreadEventManagerStore(StgStablePtr ptr); StgStablePtr getOrSetSystemEventThreadIOManagerThreadStore(StgStablePtr ptr); StgStablePtr getOrSetSystemTimerThreadEventManagerStore(StgStablePtr ptr); StgStablePtr getOrSetSystemTimerThreadIOManagerThreadStore(StgStablePtr ptr); +StgStablePtr getOrSetLibHSghcFastStringTable(StgStablePtr ptr); #endif /* RTS_GLOBALS_H */ diff --git a/includes/rts/PrimFloat.h b/includes/rts/PrimFloat.h index 7d137a7b6c..96a7d25df3 100644 --- a/includes/rts/PrimFloat.h +++ b/includes/rts/PrimFloat.h @@ -14,5 +14,7 @@ StgDouble __int_encodeDouble (I_ j, I_ e); StgFloat __int_encodeFloat (I_ j, I_ e); +StgDouble __word_encodeDouble (W_ j, I_ e); +StgFloat __word_encodeFloat (W_ j, I_ e); #endif /* RTS_PRIMFLOAT_H */ diff --git a/includes/rts/Utils.h b/includes/rts/Utils.h index 1cb52ae83f..119ec5b6a0 100644 --- a/includes/rts/Utils.h +++ b/includes/rts/Utils.h @@ -13,11 +13,6 @@ #ifndef RTS_UTILS_H #define RTS_UTILS_H -// Used in GHC (basicTypes/Unique.lhs, and Data.Unique in the base -// package. -HsInt genSymZh(void); -HsInt resetGenSymZh(void); - /* Alternate to raise(3) for threaded rts, for BSD-based OSes */ int genericRaise(int sig); diff --git a/includes/rts/storage/Closures.h b/includes/rts/storage/Closures.h index 2302b7d2a1..09e702149a 100644 --- a/includes/rts/storage/Closures.h +++ b/includes/rts/storage/Closures.h @@ -80,7 +80,7 @@ typedef struct { typedef struct StgClosure_ { StgHeader header; struct StgClosure_ *payload[FLEXIBLE_ARRAY]; -} *StgClosurePtr; // StgClosure defined in Rts.h +} *StgClosurePtr; // StgClosure defined in rts/Types.h typedef struct { StgThunkHeader header; @@ -191,17 +191,21 @@ typedef struct _StgStableName { typedef struct _StgWeak { /* Weak v */ StgHeader header; - StgClosure *cfinalizer; + StgClosure *cfinalizers; StgClosure *key; StgClosure *value; /* v */ StgClosure *finalizer; struct _StgWeak *link; } StgWeak; -typedef struct _StgDeadWeak { /* Weak v */ +typedef struct _StgCFinalizerList { StgHeader header; - struct _StgWeak *link; -} StgDeadWeak; + StgClosure *link; + void (*fptr)(void); + void *ptr; + void *eptr; + StgWord flag; /* has environment (0 or 1) */ +} StgCFinalizerList; /* Byte code objects. These are fixed size objects with pointers to * four arrays, designed so that a BCO can be easily "re-linked" to diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h index 80f11d3ee1..fb5e21e832 100644 --- a/includes/rts/storage/GC.h +++ b/includes/rts/storage/GC.h @@ -83,6 +83,8 @@ typedef struct generation_ { StgTSO * threads; // threads in this gen // linked via global_link + StgWeak * weak_ptr_list; // weak pointers in this gen + struct generation_ *to; // destination gen for live objects // stats information @@ -116,6 +118,7 @@ typedef struct generation_ { bdescr * bitmap; // bitmap for compacting collection StgTSO * old_threads; + StgWeak * old_weak_ptr_list; } generation; extern generation * generations; @@ -154,8 +157,11 @@ StgPtr allocate ( Capability *cap, W_ n ); StgPtr allocatePinned ( Capability *cap, W_ n ); /* memory allocator for executable memory */ -void * allocateExec(W_ len, void **exec_addr); -void freeExec (void *p); +typedef void* AdjustorWritable; +typedef void* AdjustorExecutable; + +AdjustorWritable allocateExec(W_ len, AdjustorExecutable *exec_addr); +void freeExec (AdjustorExecutable p); // Used by GC checks in external .cmm code: extern W_ large_alloc_lim; diff --git a/includes/rts/storage/SMPClosureOps.h b/includes/rts/storage/SMPClosureOps.h index 39349874f7..a8ebb5d0ed 100644 --- a/includes/rts/storage/SMPClosureOps.h +++ b/includes/rts/storage/SMPClosureOps.h @@ -11,13 +11,27 @@ #ifdef CMINUSMINUS +/* Lock closure, equivalent to ccall lockClosure but the condition is inlined. + * Arguments are swapped for uniformity with unlockClosure. */ +#if defined(THREADED_RTS) +#define LOCK_CLOSURE(closure, info) \ + if (CInt[n_capabilities] == 1 :: CInt) { \ + info = GET_INFO(closure); \ + } else { \ + ("ptr" info) = ccall reallyLockClosure(closure "ptr"); \ + } +#else +#define LOCK_CLOSURE(closure, info) info = GET_INFO(closure) +#endif + #define unlockClosure(ptr,info) \ prim_write_barrier; \ - StgHeader_info(ptr) = info; + StgHeader_info(ptr) = info; #else -EXTERN_INLINE StgInfoTable *lockClosure(StgClosure *p); +INLINE_HEADER StgInfoTable *lockClosure(StgClosure *p); +EXTERN_INLINE StgInfoTable *reallyLockClosure(StgClosure *p); EXTERN_INLINE StgInfoTable *tryLockClosure(StgClosure *p); EXTERN_INLINE void unlockClosure(StgClosure *p, const StgInfoTable *info); @@ -29,35 +43,58 @@ EXTERN_INLINE void unlockClosure(StgClosure *p, const StgInfoTable *info); * This is used primarily in the implementation of MVars. * -------------------------------------------------------------------------- */ -// We want a callable copy of lockClosure() so that we can refer to it -// from .cmm files compiled using the native codegen. -EXTERN_INLINE StgInfoTable *lockClosure(StgClosure *p) +// We want a callable copy of reallyLockClosure() so that we can refer to it +// from .cmm files compiled using the native codegen, so these are given +// EXTERN_INLINE. C-- should use LOCK_CLOSURE not lockClosure, so we've +// kept it INLINE_HEADER. +EXTERN_INLINE StgInfoTable *reallyLockClosure(StgClosure *p) { StgWord info; do { - nat i = 0; - do { - info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); - if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; - } while (++i < SPIN_COUNT); - yieldThread(); + nat i = 0; + do { + info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); + if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; + } while (++i < SPIN_COUNT); + yieldThread(); } while (1); } +INLINE_HEADER StgInfoTable *lockClosure(StgClosure *p) +{ + if (n_capabilities == 1) { + return (StgInfoTable *)p->header.info; + } + else { + return reallyLockClosure(p); + } +} + +// ToDo: consider splitting tryLockClosure into reallyTryLockClosure, +// same as lockClosure EXTERN_INLINE StgInfoTable *tryLockClosure(StgClosure *p) { StgWord info; - info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); - if (info != (W_)&stg_WHITEHOLE_info) { - return (StgInfoTable *)info; - } else { - return NULL; + if (n_capabilities == 1) { + return (StgInfoTable *)p->header.info; + } + else { + info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); + if (info != (W_)&stg_WHITEHOLE_info) { + return (StgInfoTable *)info; + } else { + return NULL; + } } } #else /* !THREADED_RTS */ EXTERN_INLINE StgInfoTable * +reallyLockClosure(StgClosure *p) +{ return (StgInfoTable *)p->header.info; } + +INLINE_HEADER StgInfoTable * lockClosure(StgClosure *p) { return (StgInfoTable *)p->header.info; } @@ -75,12 +112,12 @@ EXTERN_INLINE void unlockClosure(StgClosure *p, const StgInfoTable *info) } // Handy specialised versions of lockClosure()/unlockClosure() -EXTERN_INLINE void lockTSO(StgTSO *tso); -EXTERN_INLINE void lockTSO(StgTSO *tso) +INLINE_HEADER void lockTSO(StgTSO *tso); +INLINE_HEADER void lockTSO(StgTSO *tso) { lockClosure((StgClosure *)tso); } -EXTERN_INLINE void unlockTSO(StgTSO *tso); -EXTERN_INLINE void unlockTSO(StgTSO *tso) +INLINE_HEADER void unlockTSO(StgTSO *tso); +INLINE_HEADER void unlockTSO(StgTSO *tso) { unlockClosure((StgClosure*)tso, (const StgInfoTable *)&stg_TSO_info); } #endif /* CMINUSMINUS */ |