[m-dev.] diff: allocate floats with GC_malloc_atomic()

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 15 13:53:54 AEST 1999


Estimated hours taken: 0.25

runtime/mercury_float.h:
	Ensure that we allocate floating point numbers with
	hp_alloc_atomic(), which calls GC_malloc_atomic(),
	rather than hp_alloc(), which calls GC_malloc().
	The aim is to reduce the likelyhood of false hits for
	the conservative collector.

Workspace: /home/mercury0/fjh/mercury-other
Index: runtime/mercury_float.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_float.h,v
retrieving revision 1.8
diff -u -r1.8 mercury_float.h
--- mercury_float.h	1997/11/20 02:00:11	1.8
+++ mercury_float.h	1999/07/15 03:51:10
@@ -26,7 +26,7 @@
 
 #ifdef CONSERVATIVE_GC
 #define float_to_word(f) ( \
-		hp_alloc(FLOAT_WORDS), \
+		hp_alloc_atomic(FLOAT_WORDS), \
 		*(Float *)(void *)(MR_hp - FLOAT_WORDS) = (f), \
 		/* return */ (Word) (MR_hp - FLOAT_WORDS) \
 	)
@@ -34,8 +34,9 @@
 /* we need to ensure that what we allocated on the heap is properly
    aligned */
 #define float_to_word(f) ( \
-		( (Word)MR_hp & (sizeof(Float) - 1) ? hp_alloc(1) : (void)0 ), \
-		hp_alloc(FLOAT_WORDS), \
+		( (Word)MR_hp & (sizeof(Float) - 1) ? \
+			hp_alloc_atomic(1) : (void)0 ), \
+		hp_alloc_atomic(FLOAT_WORDS), \
 		*(Float *)(void *)(MR_hp - FLOAT_WORDS) = (f), \
 		/* return */ (Word) (MR_hp - FLOAT_WORDS) \
 	)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list