[m-rev.] not committed: agc library hacks

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jun 7 20:21:20 AEST 2002


I'm not going to commit the following, since it is not really the
right approach.  The right approach is to define a new MR_TypeCtorRep
for mutable variables.

However, with this change, the compiler now bootstraps
and passes all of the tests in our test suite, using
GRADE=hlc.agc, EXTRA_MCFLAGS=--no-reclaim-heap-on-failure,
and MERCURY_OPTIONS=--heap-size 100000.

On the ICFP2000 test cases, it runs an average of about 17-20% slower
than hlc.gc (the Boehm collector).

----------

Estimated hours taken: 1
Branches: main

library/benchmarking.m:
library/std_util.m:
library/store.m:
	Define mutable variables as wrappers around unary tuples, rather
	than wrappers around c_pointer, so that they get traced properly
	by the accurate collector.
	XXX Using unary tuples is a lie, since the semantics (e.g. for
	equality, construct, deconstruct, etc.) are not the same as
	unary tuples!

Workspace: /home/ceres/fjh/mercury
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.47
diff -u -d -r1.47 benchmarking.m
--- library/benchmarking.m	18 Feb 2002 07:01:02 -0000	1.47
+++ library/benchmarking.m	7 Jun 2002 01:53:34 -0000
@@ -704,7 +704,12 @@
 
 %  Impure integer references.
 %  This type is implemented in C.
-:- type int_reference ---> int_reference(c_pointer).
+%  It is represented as a pointer to a single word on the heap.
+%  To ensure that the accurate garbage collector can trace it properly,
+%  we define it as a unary tuple type, which has the same representation.
+%  XXX This is a lie, since the semantics (e.g. for equality,
+%  construct, deconstruct, etc.) are not the same as unary tuples!
+:- type int_reference ---> int_reference({int}).
 
 %  Create a new int_reference given a term for it to reference.
 :- impure pred new_int_reference(int::in, int_reference::out) is det.
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.268
diff -u -d -r1.268 std_util.m
--- library/std_util.m	7 Jun 2002 00:49:57 -0000	1.268
+++ library/std_util.m	7 Jun 2002 01:50:06 -0000
@@ -1283,7 +1283,13 @@
 %%% :- implementation.
 
 %  This type is implemented in C.
-:- type mutvar(T) ---> mutvar(c_pointer).
+%  A mutvar is represented as a pointer to a single word on the heap.
+%  To ensure that the accurate garbage collector can trace it properly,
+%  we define it as a unary tuple type, which has the same representation.
+%  XXX This is a lie, since the semantics (e.g. for equality,
+%  construct, deconstruct, etc.) are not the same as unary tuples!
+
+:- type mutvar(T) ---> mutvar({T}).
 
 :- pragma inline(new_mutvar/2).
 
Index: library/store.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/store.m,v
retrieving revision 1.31
diff -u -d -r1.31 store.m
--- library/store.m	4 Feb 2002 05:22:54 -0000	1.31
+++ library/store.m	7 Jun 2002 01:57:03 -0000
@@ -235,11 +235,21 @@
 
 :- type some_store_type ---> some_store_type. 
 
+% The store type itself is just a dummy type,
+% with no real representation.
+
 :- type store(S) ---> store(c_pointer).
 
-:- type generic_mutvar(T, S) ---> mutvar(c_pointer).
+% Mutvars and references are each represented as a pointer to a single word
+% on the heap.
+% To ensure that the accurate garbage collector can trace them properly,
+% we define them as unary tuple types, which have the same representation.
+% XXX This is a lie, since the semantics (e.g. for equality,
+% construct, deconstruct, etc.) are not the same as unary tuples!
 
-:- type generic_ref(T, S) ---> ref(c_pointer).
+:- type generic_mutvar(T, S) ---> mutvar({T}).
+
+:- type generic_ref(T, S) ---> ref({T}).
 
 store__new(S) :-
 	store__do_init(S).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list