Commit 3160a654 authored by wolfgang's avatar wolfgang

[project @ 2004-11-10 02:13:12 by wolfgang]

64-bit fixes.

Don't assume that sizeof(int) == sizeof(StgInt).
This assumption creeped in in many places since 6.2.
parent d23da8bf
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
#define CInt bits32 #define CInt bits32
#elif SIZEOF_INT = 8 #elif SIZEOF_INT == 8
#define CInt bits64 #define CInt bits64
#else #else
#error Unknown int size #error Unknown int size
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
#if SIZEOF_LONG == 4 #if SIZEOF_LONG == 4
#define CLong bits32 #define CLong bits32
#elif SIZEOF_LONG = 8 #elif SIZEOF_LONG == 8
#define CLong bits64 #define CLong bits64
#else #else
#error Unknown long size #error Unknown long size
...@@ -163,6 +163,12 @@ ...@@ -163,6 +163,12 @@
#define HALF_W_(x) %lobits32(x) #define HALF_W_(x) %lobits32(x)
#endif #endif
#if SIZEOF_INT == 4 && SIZEOF_W == 8
#define W_TO_INT(x) %lobits32(x)
#elif SIZEOF_INT == SIZEOF_W
#define W_TO_INT(x) (x)
#endif
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Heap/stack access, and adjusting the heap/stack pointers. Heap/stack access, and adjusting the heap/stack pointers.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -307,7 +313,7 @@ ...@@ -307,7 +313,7 @@
TICK_ALLOC_HEAP_NOCTR(alloc); TICK_ALLOC_HEAP_NOCTR(alloc);
#define MAYBE_GC(liveness,reentry) \ #define MAYBE_GC(liveness,reentry) \
if (CInt[alloc_blocks] >= CInt[alloc_blocks_lim]) { \ if (W_[alloc_blocks] >= W_[alloc_blocks_lim]) { \
R9 = liveness; \ R9 = liveness; \
R10 = reentry; \ R10 = reentry; \
jump stg_gc_gen_hp; \ jump stg_gc_gen_hp; \
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: TSO.h,v 1.37 2004/11/08 12:26:57 simonmar Exp $ * $Id: TSO.h,v 1.38 2004/11/10 02:13:12 wolfgang Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -97,11 +97,11 @@ typedef struct { ...@@ -97,11 +97,11 @@ typedef struct {
typedef union { typedef union {
StgClosure *closure; StgClosure *closure;
struct StgTSO_ *tso; struct StgTSO_ *tso;
int fd; StgInt fd; // StgInt instead of int, so that it's the same size as the ptrs
#if defined(mingw32_TARGET_OS) #if defined(mingw32_TARGET_OS)
StgAsyncIOResult* async_result; StgAsyncIOResult* async_result;
#endif #endif
unsigned int target; StgWord target;
} StgTSOBlockInfo; } StgTSOBlockInfo;
/* /*
......
...@@ -238,7 +238,7 @@ extern void awakenBlockedQueue(StgBlockingQueueElement *q, StgClosure *node); ...@@ -238,7 +238,7 @@ extern void awakenBlockedQueue(StgBlockingQueueElement *q, StgClosure *node);
inf = %GET_STD_INFO(p); \ inf = %GET_STD_INFO(p); \
np = TO_W_(%INFO_PTRS(inf)); \ np = TO_W_(%INFO_PTRS(inf)); \
nw = TO_W_(%INFO_NPTRS(inf)); \ nw = TO_W_(%INFO_NPTRS(inf)); \
if (%INFO_TYPE(inf) != THUNK_SELECTOR::I16) { \ if (%INFO_TYPE(inf) != HALF_W_(THUNK_SELECTOR)) { \
i = 0; \ i = 0; \
for: \ for: \
if (i < np + nw) { \ if (i < np + nw) { \
...@@ -285,7 +285,7 @@ DEBUG_FILL_SLOP(StgClosure *p) ...@@ -285,7 +285,7 @@ DEBUG_FILL_SLOP(StgClosure *p)
/* ASSERT( p1 != p2 && !closure_IND(p1) ); \ /* ASSERT( p1 != p2 && !closure_IND(p1) ); \
*/ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \ */ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \
bd = Bdescr(p1); \ bd = Bdescr(p1); \
if (bdescr_gen_no(bd) == 0) { \ if (bdescr_gen_no(bd) == 0 :: CInt) { \
StgInd_indirectee(p1) = p2; \ StgInd_indirectee(p1) = p2; \
SET_INFO(p1, ind_info); \ SET_INFO(p1, ind_info); \
LDV_RECORD_CREATE(p1); \ LDV_RECORD_CREATE(p1); \
...@@ -295,7 +295,7 @@ DEBUG_FILL_SLOP(StgClosure *p) ...@@ -295,7 +295,7 @@ DEBUG_FILL_SLOP(StgClosure *p)
if (info != stg_BLACKHOLE_BQ_info) { \ if (info != stg_BLACKHOLE_BQ_info) { \
DEBUG_FILL_SLOP(p1); \ DEBUG_FILL_SLOP(p1); \
W_ __mut_once_list; \ W_ __mut_once_list; \
__mut_once_list = generation(bdescr_gen_no(bd)) + \ __mut_once_list = generation(TO_W_(bdescr_gen_no(bd))) + \
OFFSET_generation_mut_once_list; \ OFFSET_generation_mut_once_list; \
StgMutClosure_mut_link(p1) = W_[__mut_once_list]; \ StgMutClosure_mut_link(p1) = W_[__mut_once_list]; \
W_[__mut_once_list] = p1; \ W_[__mut_once_list] = p1; \
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
CLOSE_NURSERY(); \ CLOSE_NURSERY(); \
CurrentNursery = bdescr_link(CurrentNursery); \ CurrentNursery = bdescr_link(CurrentNursery); \
OPEN_NURSERY(); \ OPEN_NURSERY(); \
if (CInt[context_switch] != 0) { \ if (CInt[context_switch] != 0 :: CInt) { \
R1 = ThreadYielding; \ R1 = ThreadYielding; \
goto sched; \ goto sched; \
} else { \ } else { \
......
...@@ -196,12 +196,13 @@ unblock_vtalrm_signal(void) ...@@ -196,12 +196,13 @@ unblock_vtalrm_signal(void)
/* gettimeofday() takes around 1us on our 500MHz PIII. Since we're /* gettimeofday() takes around 1us on our 500MHz PIII. Since we're
* only calling it 50 times/s, it shouldn't have any great impact. * only calling it 50 times/s, it shouldn't have any great impact.
*/ */
unsigned int nat
getourtimeofday(void) getourtimeofday(void)
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, (struct timezone *) NULL); gettimeofday(&tv, (struct timezone *) NULL);
return (tv.tv_sec * TICK_FREQUENCY + // cast to nat because nat may be 64 bit when int is only 32 bit
tv.tv_usec * TICK_FREQUENCY / 1000000); return ((nat)tv.tv_sec * TICK_FREQUENCY +
(nat)tv.tv_usec * TICK_FREQUENCY / 1000000);
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
extern int startTicker( nat ms, TickProc handle_tick); extern int startTicker( nat ms, TickProc handle_tick);
extern int stopTicker ( void ); extern int stopTicker ( void );
extern unsigned int getourtimeofday ( void ); extern nat getourtimeofday ( void );
#if 0 #if 0
/* unused */ /* unused */
extern void block_vtalrm_signal ( void ); extern void block_vtalrm_signal ( void );
......
...@@ -538,20 +538,21 @@ section "bss" { ...@@ -538,20 +538,21 @@ section "bss" {
#define GMP_TAKE2_RET1(name,mp_fun) \ #define GMP_TAKE2_RET1(name,mp_fun) \
name \ name \
{ \ { \
W_ s1, s2, d1, d2; \ CInt s1, s2; \
W_ d1, d2; \
\ \
/* call doYouWantToGC() */ \ /* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \ MAYBE_GC(R2_PTR & R4_PTR, name); \
\ \
s1 = R1; \ s1 = W_TO_INT(R1); \
d1 = R2; \ d1 = R2; \
s2 = R3; \ s2 = W_TO_INT(R3); \
d2 = R4; \ d2 = R4; \
\ \
MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \ MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \ MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
MP_INT__mp_alloc(mp_tmp2) = StgArrWords_words(d2); \ MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(StgArrWords_words(d2)); \
MP_INT__mp_size(mp_tmp2) = (s2); \ MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \ MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\ \
...@@ -560,22 +561,23 @@ name \ ...@@ -560,22 +561,23 @@ name \
/* Perform the operation */ \ /* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1,mp_tmp2); \ foreign "C" mp_fun(result1,mp_tmp1,mp_tmp2); \
\ \
RET_NP(MP_INT__mp_size(result1), \ RET_NP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \ MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
} }
#define GMP_TAKE1_RET1(name,mp_fun) \ #define GMP_TAKE1_RET1(name,mp_fun) \
name \ name \
{ \ { \
W_ s1, d1; \ CInt s1; \
W_ d1; \
\ \
/* call doYouWantToGC() */ \ /* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR, name); \ MAYBE_GC(R2_PTR, name); \
\ \
d1 = R2; \ d1 = R2; \
s1 = R1; \ s1 = W_TO_INT(R1); \
\ \
MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \ MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \ MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
\ \
...@@ -584,27 +586,28 @@ name \ ...@@ -584,27 +586,28 @@ name \
/* Perform the operation */ \ /* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1); \ foreign "C" mp_fun(result1,mp_tmp1); \
\ \
RET_NP(MP_INT__mp_size(result1), \ RET_NP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \ MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
} }
#define GMP_TAKE2_RET2(name,mp_fun) \ #define GMP_TAKE2_RET2(name,mp_fun) \
name \ name \
{ \ { \
W_ s1, s2, d1, d2; \ CInt s1, s2; \
W_ d1, d2; \
\ \
/* call doYouWantToGC() */ \ /* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \ MAYBE_GC(R2_PTR & R4_PTR, name); \
\ \
s1 = R1; \ s1 = W_TO_INT(R1); \
d1 = R2; \ d1 = R2; \
s2 = R3; \ s2 = W_TO_INT(R3); \
d2 = R4; \ d2 = R4; \
\ \
MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \ MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \ MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
MP_INT__mp_alloc(mp_tmp2) = StgArrWords_words(d2); \ MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(StgArrWords_words(d2)); \
MP_INT__mp_size(mp_tmp2) = (s2); \ MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \ MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\ \
...@@ -614,9 +617,9 @@ name \ ...@@ -614,9 +617,9 @@ name \
/* Perform the operation */ \ /* Perform the operation */ \
foreign "C" mp_fun(result1,result2,mp_tmp1,mp_tmp2); \ foreign "C" mp_fun(result1,result2,mp_tmp1,mp_tmp2); \
\ \
RET_NPNP(MP_INT__mp_size(result1), \ RET_NPNP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords, \ MP_INT__mp_d(result1) - SIZEOF_StgArrWords, \
MP_INT__mp_size(result2), \ TO_W_(MP_INT__mp_size(result2)), \
MP_INT__mp_d(result2) - SIZEOF_StgArrWords); \ MP_INT__mp_d(result2) - SIZEOF_StgArrWords); \
} }
...@@ -739,12 +742,12 @@ cmpIntegerzh_fast ...@@ -739,12 +742,12 @@ cmpIntegerzh_fast
cmp = foreign "C" mpn_cmp(up "ptr", vp "ptr", size); cmp = foreign "C" mpn_cmp(up "ptr", vp "ptr", size);
if (cmp == 0) { if (cmp == 0 :: CInt) {
R1 = 0; R1 = 0;
jump %ENTRY_CODE(Sp(0)); jump %ENTRY_CODE(Sp(0));
} }
if (%lt(cmp,0) == %lt(usize,0)) { if (%lt(cmp,0 :: CInt) == %lt(usize,0)) {
R1 = 1; R1 = 1;
} else { } else {
R1 = (-1); R1 = (-1);
...@@ -816,7 +819,7 @@ decodeFloatzh_fast ...@@ -816,7 +819,7 @@ decodeFloatzh_fast
foreign "C" __decodeFloat(mp_tmp1,exponent,arg); foreign "C" __decodeFloat(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */ /* returns: (Int# (expn), Int#, ByteArray#) */
RET_NNP(W_[exponent], MP_INT__mp_size(mp_tmp1), p); RET_NNP(W_[exponent], TO_W_(MP_INT__mp_size(mp_tmp1)), p);
} }
#define DOUBLE_MANTISSA_SIZE SIZEOF_DOUBLE #define DOUBLE_MANTISSA_SIZE SIZEOF_DOUBLE
...@@ -843,7 +846,7 @@ decodeDoublezh_fast ...@@ -843,7 +846,7 @@ decodeDoublezh_fast
foreign "C" __decodeDouble(mp_tmp1,exponent,arg); foreign "C" __decodeDouble(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */ /* returns: (Int# (expn), Int#, ByteArray#) */
RET_NNP(W_[exponent], MP_INT__mp_size(mp_tmp1), p); RET_NNP(W_[exponent], TO_W_(MP_INT__mp_size(mp_tmp1)), p);
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
...@@ -862,7 +865,7 @@ forkzh_fast ...@@ -862,7 +865,7 @@ forkzh_fast
foreign "C" scheduleThread(R1 "ptr"); foreign "C" scheduleThread(R1 "ptr");
// switch at the earliest opportunity // switch at the earliest opportunity
CInt[context_switch] = 1; CInt[context_switch] = 1 :: CInt;
RET_P(R1); RET_P(R1);
} }
...@@ -1307,8 +1310,8 @@ mkApUpd0zh_fast ...@@ -1307,8 +1310,8 @@ mkApUpd0zh_fast
// This function is *only* used to wrap zero-arity BCOs in an // This function is *only* used to wrap zero-arity BCOs in an
// updatable wrapper (see ByteCodeLink.lhs). An AP thunk is always // updatable wrapper (see ByteCodeLink.lhs). An AP thunk is always
// saturated and always points directly to a FUN or BCO. // saturated and always points directly to a FUN or BCO.
ASSERT(%INFO_TYPE(%GET_STD_INFO(R1)) == BCO::I16 && ASSERT(%INFO_TYPE(%GET_STD_INFO(R1)) == HALF_W_(BCO) &&
StgBCO_arity(R1) == 0::I16); StgBCO_arity(R1) == HALF_W_(0));
HP_CHK_GEN_TICKY(SIZEOF_StgAP, R1_PTR, mkApUpd0zh_fast); HP_CHK_GEN_TICKY(SIZEOF_StgAP, R1_PTR, mkApUpd0zh_fast);
TICK_ALLOC_UP_THK(0, 0); TICK_ALLOC_UP_THK(0, 0);
...@@ -1317,7 +1320,7 @@ mkApUpd0zh_fast ...@@ -1317,7 +1320,7 @@ mkApUpd0zh_fast
ap = Hp - SIZEOF_StgAP + WDS(1); ap = Hp - SIZEOF_StgAP + WDS(1);
SET_HDR(ap, stg_AP_info, W_[CCCS]); SET_HDR(ap, stg_AP_info, W_[CCCS]);
StgAP_n_args(ap) = 0::I16; StgAP_n_args(ap) = HALF_W_(0);
StgAP_fun(ap) = R1; StgAP_fun(ap) = R1;
RET_P(ap); RET_P(ap);
...@@ -1411,9 +1414,9 @@ delayzh_fast ...@@ -1411,9 +1414,9 @@ delayzh_fast
#else #else
CInt time; W_ time;
time = foreign "C" getourtimeofday(); time = foreign "C" getourtimeofday();
target = (R1 / (TICK_MILLISECS*1000)) + TO_W_(time); target = (R1 / (TICK_MILLISECS*1000)) + time;
StgTSO_block_info(CurrentTSO) = target; StgTSO_block_info(CurrentTSO) = target;
/* Insert the new thread in the sleeping queue. */ /* Insert the new thread in the sleeping queue. */
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
* When era reaches max_era, the profiling stops because a closure can * When era reaches max_era, the profiling stops because a closure can
* store only up to (max_era - 1) as its creation or last use time. * store only up to (max_era - 1) as its creation or last use time.
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
nat era; unsigned int era;
static nat max_era; static nat max_era;
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment