diff: declare `report_stats' as impure

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jan 25 03:39:03 AEDT 1998


library/benchmarking.m:
	Declare the predicates report_stats/0 and
	report_full_memory_stats/0 to be `impure',
	since they have side-effects.

library/io.m:
	Add `pragma promise_pure' declarations for io__report_stats/2
	and io__report_full_memory_stats/2.  These declarations are
	necessary since those predicates call the impure predicates
	report_stats/0 and report_full_memory_stats/0 respectively.

cvs diff  library/benchmarking.m library/io.m
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.9
diff -u -r1.9 benchmarking.m
--- benchmarking.m	1998/01/23 12:33:08	1.9
+++ benchmarking.m	1998/01/24 15:27:17
@@ -18,20 +18,18 @@
 
 :- interface.
 
-% Declaratively, `report_stats' is the same as `true'.
+% `report_stats' is a non-logical procedure intended for use in profiling
+% the performance of a program.
 % It has the side-effect of reporting some memory and time usage statistics
 % about the time period since the last call to report_stats to stdout.
-% (Technically, every Mercury implementation must offer a mode of invocation
-% which disables this side-effect.)
 
-:- pred report_stats is det.
+:- impure pred report_stats is det.
 
-% Declaratively, `report_full_memory_stats' is the same as `true'.
-% It has the side-effect of reporting a full memory profile
-% to stdout. (Technically, every Mercury implementation must offer
-% a mode of invocation which disables this side-effect.)
+% `report_full_memory_stats' is a non-logical procedure intended for use
+% in profiling the memory usage of a program.  It has the side-effect of
+% reporting a full memory profile to stdout.
 
-:- pred report_full_memory_stats is det.
+:- impure pred report_full_memory_stats is det.
 
 % benchmark_det(Pred, In, Out, Repeats, Time) is for benchmarking the
 % det predicate Pred. We call Pred with the input In and the output Out,
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.147
diff -u -r1.147 io.m
--- io.m	1998/01/22 02:26:37	1.147
+++ io.m	1998/01/24 16:33:38
@@ -855,6 +855,7 @@
 
 	% Write complete memory usage statistics to stdout,
 	% including information about all procedures and types.
+	% (You need to compile with memory profiling enabled.)
 
 :- pred io__report_full_memory_stats(io__state, io__state).
 :- mode io__report_full_memory_stats(di, uo) is det.
@@ -1899,18 +1900,15 @@
 
 % memory management predicates
 
-% The implementation of io__report_stats/2 in terms of the non-logical
-% report_stats/0 causes problems with --optimize-duplicate-calls.
-% So we need to prevent inlining.  (If/when we support `impure' declarations,
-% it would probably be better to declare `report_stats' as `impure'.)
-
-:- pragma no_inline(io__report_stats/2).
+:- pragma promise_pure(io__report_stats/2).
 
 io__report_stats -->
-	{ report_stats }.
+	{ impure report_stats }.
+
+:- pragma promise_pure(io__report_full_memory_stats/2).
 
 io__report_full_memory_stats -->
-	{ report_full_memory_stats }.
+	{ impure report_full_memory_stats }.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

-- 
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.



More information about the developers mailing list