[m-dev.] for review: fix bug with reused choicepoint ids

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Mar 23 01:42:39 AEDT 2000


I applied all of Warwick's suggestions.
Here's the (trivial) diff.

----------

Estimated hours taken: 0.25

Apply some corrections that Warwick spotted in his
review of my recent trailing changes.

runtime/mercury_context.c:
	Fix a couple of bugs in init_context(): the ticket_counter
	should be initialized to 1, not 0, to ensure that it remains
	different from MR_null_choicepoint_id(), and we need to also
	initialize the ticket_high_water field.

compiler/notes/trailing.html:
doc/reference_manual.texi:
	Fix typos.

Workspace: /home/mercury0/fjh/mercury
Index: compiler/notes/trailing.html
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/notes/trailing.html,v
retrieving revision 1.1
diff -u -d -r1.1 trailing.html
--- compiler/notes/trailing.html	2000/03/20 05:26:56	1.1
+++ compiler/notes/trailing.html	2000/03/22 14:30:34
@@ -150,7 +150,7 @@
 <h2> Trail tickets </h2>
 
 At any point where we create a choice point, i.e. a point to which we may want
-to backtrack to (including exception handlers, and if debugging is enabled,
+to backtrack (including exception handlers, and if debugging is enabled,
 all procedure prologues [to handle the debugger retry command]), or where we
 are about to start a goal for which we may want to do a soft or hard commit,
 the code must allocate a trail ticket, using the MR_store_ticket() macro.
@@ -164,9 +164,11 @@
 
 Whenever we backtrack, or whenever we do a hard or soft commit,
 the code must call MR_reset_ticket(), passing it the trail pointer
-value the was saved by MR_store_ticket(), together with the appropriate
+value that was saved by MR_store_ticket(), together with the appropriate
 MR_trail_reason.  This will walk the trail, applying all the trail
-entries.  In addition, if the ticket will no longer be used,
+entries from the top of the trail down to the given pointer,
+most recently added entries first.
+In addition, if the ticket will no longer be used,
 it should then be pruned or discarded (see below).
 
 <p>
@@ -180,9 +182,9 @@
 <p>
 
 Whenever we backtrack, the code must "discard" the trail tickets that have
-allocated since the choice point was created,
+been allocated since the choice point was created,
 using either MR_discard_ticket(), which discards the most recently
-allocated ticket, or MR_discard_tickets_to(), which prunes all the
+allocated ticket, or MR_discard_tickets_to(), which discards all the
 tickets allocated since the corresponding call to MR_mark_ticket_stack().
 
 <p>
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.175
diff -u -d -r1.175 reference_manual.texi
--- doc/reference_manual.texi	2000/03/08 13:16:50	1.175
+++ doc/reference_manual.texi	2000/03/22 14:33:57
@@ -5084,10 +5084,10 @@
 
 Typically if the @var{untrail_func} is called with @var{reason} being
 @samp{MR_undo} or @samp{MR_exception}, then it should undo the effects
-of the update(s) specified by @var{value}, and the free any resources
+of the update(s) specified by @var{value}, and then free any resources
 associated with that trail entry.  If it is called with @var{reason}
-being @samp{MR_commit} or @samp{MR_solve}, then it not undo the update(s);
-instead, it may check for floundering (see the next section).
+being @samp{MR_commit} or @samp{MR_solve}, then it should not undo the
+update(s); instead, it may check for floundering (see the next section).
 In the @samp{MR_commit} case it may, in some cases, be possible to
 also free resources associated with the trail entry.
 If it is called with anything else (such as @samp{MR_gc}),
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.22
diff -u -d -r1.22 mercury_context.c
--- runtime/mercury_context.c	2000/02/25 15:29:57	1.22
+++ runtime/mercury_context.c	2000/03/22 14:35:17
@@ -153,7 +153,8 @@
 			default_handler);
 	}
 	c->context_trail_ptr = (MR_TrailEntry *) c->trail_zone->min;
-	c->context_ticket_counter = 0;
+	c->context_ticket_counter = 1;
+	c->context_ticket_high_water = 1;
 #endif
 
 	c->context_hp = NULL;


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