diff: fix nondet_c problem

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Mar 27 19:25:09 AEDT 1999


Estimated hours taken: 0.5

compiler/pragma_c_gen.m:
	For nondet pragma c_code, don't output calls to save_registers()
	or restore_registers() unless the procedure may_call_mercury.
	This is necessary to make tests/hard_coded/nondet_c.m work,
	since that test case uses will_not_call_mercury and incr_hp_atomic()
	rather than incr_saved_hp_atomic().
	It's also desirable from an efficiency standpoint and for
	consistency with ordinary (model_det or model_semi) pragma c_code.

Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.26
diff -u -r1.26 pragma_c_gen.m
--- pragma_c_gen.m	1999/01/27 08:34:30	1.26
+++ pragma_c_gen.m	1999/03/27 08:18:47
@@ -581,10 +581,25 @@
 		     LaterTraceCode))
 	},
 
-	{
-	SaveRegs	 = "\tsave_registers();\n",
-	RestoreRegs	 = "\trestore_registers();\n",
+	%
+	% save_registers(); /* see notes (1) and (2) above */
+	%
+	{ MayCallMercury = will_not_call_mercury ->
+		SaveRegs = ""
+	;
+		SaveRegs = "\tsave_registers();\n"
+	},
+
+	%
+	% restore_registers(); /* see notes (1) and (3) above */
+	%
+	{ MayCallMercury = will_not_call_mercury ->
+		RestoreRegs = ""
+	;
+		RestoreRegs = "\trestore_registers();\n"
+	},
 
+	{
 	Succeed	 = "\tsucceed();\n",
 	SucceedDiscard = "\tsucceed_discard();\n",
 

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