summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3f9677e)
- Now that labels are always prefixed with '&' in .hc code, we have to
fix some sloppiness in the RTS .cmm code. Fortunately it's not too
painful.
- SMP: acquire/release the storage manager lock around
atomicModifyMutVar#. This is a hack: atomicModifyMutVar# isn't
atomic under SMP otherwise, but the SM lock is a large sledgehammer.
I think I'll apply the sledgehammer to the MVar primitives too, for
the time being.
TICK_BUMP(ALLOC_HEAP_ctr); \
TICK_BUMP_BY(ALLOC_HEAP_tot,n)
TICK_BUMP(ALLOC_HEAP_ctr); \
TICK_BUMP_BY(ALLOC_HEAP_tot,n)
+/* -----------------------------------------------------------------------------
+ Misc junk
+ -------------------------------------------------------------------------- */
+
+#define TICK_MILLISECS (1000/TICK_FREQUENCY) /* ms per tick */
+
#error RESERVED_STACK_WORDS may be wrong!
#endif
#error RESERVED_STACK_WORDS may be wrong!
#endif
+/* -----------------------------------------------------------------------------
+ How often our context-switch timer ticks
+ -------------------------------------------------------------------------- */
+
+#define TICK_FREQUENCY 50 /* ticks per second */
+
#define END_STM_WAIT_QUEUE ((StgTVarWaitQueue *)(void *)&stg_END_STM_WAIT_QUEUE_closure)
#define END_STM_CHUNK_LIST ((StgTRecChunk *)(void *)&stg_END_STM_CHUNK_LIST_closure)
#define END_STM_WAIT_QUEUE ((StgTVarWaitQueue *)(void *)&stg_END_STM_WAIT_QUEUE_closure)
#define END_STM_CHUNK_LIST ((StgTRecChunk *)(void *)&stg_END_STM_CHUNK_LIST_closure)
+
+#if IN_STG_CODE
+#define NO_TREC (stg_NO_TREC_closure)
+#else
#define NO_TREC ((StgTRecHeader *)(void *)&stg_NO_TREC_closure)
#define NO_TREC ((StgTRecHeader *)(void *)&stg_NO_TREC_closure)
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
/* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
+#if IN_STG_CODE
+#define END_TSO_QUEUE (stg_END_TSO_QUEUE_closure)
+#else
#define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
#define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
#if defined(PAR) || defined(GRAN)
/* this is the NIL ptr for a blocking queue */
#if defined(PAR) || defined(GRAN)
/* this is the NIL ptr for a blocking queue */
-\#include ProfHeap.h \
-\#include LdvProfile.h \
-\#include Profiling.h \
-\#include ProfHeap.h \
-\#include LdvProfile.h \
-\#include Profiling.h \
+ -\#include StoragePriv.h \
+ -\#include OSThreads.h \
-\#include Apply.h
ifeq "$(Windows)" "YES"
-\#include Apply.h
ifeq "$(Windows)" "YES"
W_ mv, z, x, y, r;
/* Args: R1 :: MutVar#, R2 :: a -> (a,b) */
W_ mv, z, x, y, r;
/* Args: R1 :: MutVar#, R2 :: a -> (a,b) */
+#if defined(SMP)
+ foreign "C" ACQUIRE_LOCK(sm_mutex "ptr");
+#endif
+
/* If x is the current contents of the MutVar#, then
We want to make the new contents point to
/* If x is the current contents of the MutVar#, then
We want to make the new contents point to
-#define THUNK_1_SIZE (SIZEOF_StgHeader + WDS(MIN_UPD_SIZE))
+#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
#else
#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1))
#else
-#define THUNK_1_SIZE (SIZEOF_StgHeader + WDS(1))
+#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1))
#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
#endif
#if MIN_UPD_SIZE > 2
#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0)
#endif
#if MIN_UPD_SIZE > 2
-#define THUNK_2_SIZE (SIZEOF_StgHeader + WDS(MIN_UPD_SIZE))
+#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE))
#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
#else
#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2))
#else
-#define THUNK_2_SIZE (SIZEOF_StgHeader + WDS(2))
+#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2))
#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
#endif
#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0)
#endif
z = Hp - THUNK_2_SIZE + WDS(1);
SET_HDR(z, stg_ap_2_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(z);
z = Hp - THUNK_2_SIZE + WDS(1);
SET_HDR(z, stg_ap_2_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(z);
- StgClosure_payload(z,0) = R2;
- StgClosure_payload(z,1) = x;
+ StgThunk_payload(z,0) = R2;
+ StgThunk_payload(z,1) = x;
TICK_ALLOC_THUNK_1();
CCCS_ALLOC(THUNK_1_SIZE);
y = z - THUNK_1_SIZE;
SET_HDR(y, stg_sel_0_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(y);
TICK_ALLOC_THUNK_1();
CCCS_ALLOC(THUNK_1_SIZE);
y = z - THUNK_1_SIZE;
SET_HDR(y, stg_sel_0_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(y);
- StgClosure_payload(y,0) = z;
+ StgThunk_payload(y,0) = z;
r = y - THUNK_1_SIZE;
SET_HDR(r, stg_sel_1_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(r);
r = y - THUNK_1_SIZE;
SET_HDR(r, stg_sel_1_upd_info, W_[CCCS]);
LDV_RECORD_CREATE(r);
- StgClosure_payload(r,0) = z;
+ StgThunk_payload(r,0) = z;
+
+#if defined(SMP)
+ foreign "C" RELEASE_LOCK(sm_mutex "ptr");
+#endif
#include "Storage.h"
#include "Schedule.h"
#include "RetainerProfile.h" // for counting memory blocks (memInventory)
#include "Storage.h"
#include "Schedule.h"
#include "RetainerProfile.h" // for counting memory blocks (memInventory)
+#include "StoragePriv.h"
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
static void *stgReallocForGMP (void *ptr, size_t old_size, size_t new_size);
static void stgDeallocForGMP (void *ptr, size_t size);
static void *stgReallocForGMP (void *ptr, size_t old_size, size_t new_size);
static void stgDeallocForGMP (void *ptr, size_t size);
-/*
- * Storage manager mutex
- */
-#if defined(SMP)
-extern Mutex sm_mutex;
-#define ACQUIRE_SM_LOCK ACQUIRE_LOCK(&sm_mutex)
-#define RELEASE_SM_LOCK RELEASE_LOCK(&sm_mutex)
-#else
-#define ACQUIRE_SM_LOCK
-#define RELEASE_SM_LOCK
-#endif
-
static void
initStep (step *stp, int g, int s)
{
static void
initStep (step *stp, int g, int s)
{
--- /dev/null
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 1998-2005
+ *
+ * Storage manager bits visible to the rest of the RTS only
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef STORAGEPRIV_H
+#define STORAGEPRIV_H
+
+/*
+ * Storage manager mutex
+ */
+#if defined(SMP)
+extern Mutex sm_mutex;
+#define ACQUIRE_SM_LOCK ACQUIRE_LOCK(&sm_mutex)
+#define RELEASE_SM_LOCK RELEASE_LOCK(&sm_mutex)
+#else
+#define ACQUIRE_SM_LOCK
+#define RELEASE_SM_LOCK
+#endif
+
+#endif /* STORAGEPRIV_H */
#ifndef __TIMER_H__
#define __TIMER_H__
#ifndef __TIMER_H__
#define __TIMER_H__
-# define TICK_FREQUENCY 50 /* ticks per second */
# define TICK_MILLISECS (1000/TICK_FREQUENCY) /* ms per tick */
/* Context switch timing constants. Context switches happen after a
# define TICK_MILLISECS (1000/TICK_FREQUENCY) /* ms per tick */
/* Context switch timing constants. Context switches happen after a