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

Warwick Harvey wharvey at cs.monash.edu.au
Tue Mar 21 16:44:30 AEDT 2000


Fergus wrote:
> I thought about it fairly carefully and in the process I found a few more
> bugs.  I also wrote some documentation on how the whole trailing thing hangs
> together.

Good stuff.

> ============================================================
> new file compiler/notes/trailing.html, formatted via `lynx -dump'
> ============================================================
> Trail tickets
> 
>    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

s/backtrack to/backtrack/

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

s/the was/that was/  (or "which was"?)

>    MR_trail_reason. This will walk the trail, applying all the trail
>    entries. In addition, if the ticket will no longer be used, it should

s/entries/entries up to the given pointer, most recent first/

(Is the trail considered to grow "up" or "down"?)

>    then be pruned or discarded (see below).
>    
>    Whenever we do a hard or soft commit, the code must "prune" the trail
>    tickets that we have allocated, using either MR_prune_ticket(), which
>    prunes the most recently allocated ticket, or MR_prune_tickets_to(),
>    which prunes all the tickets allocated since the corresponding call to
>    MR_mark_ticket_stack().
>    
>    Whenever we backtrack, the code must "discard" the trail tickets that
>    have allocated since the choice point was created, using either

s/have/have been/

>    MR_discard_ticket(), which discards the most recently allocated
>    ticket, or MR_discard_tickets_to(), which prunes all the tickets

s/prunes/discards/

> 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/19 07:11:06
[...]
>  Typically if the @var{untrail_func} is called with @var{reason} being
> - at 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
> -associated with that trail entry.  If it is called with @var{reason}
> + at samp{MR_undo}, @samp{MR_exception}, or @samp{MR_retry}, then it should undo
> +the effects of the update(s) specified by @var{value}, and the free any

s/the free/then free/   or maybe   s/the free/free/

> +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);

s/it not/it should not/

>  instead, it may check for floundering (see the next section).

[...]

> + at sp 1
> + at item @bullet{} @code{MR_null_choicepoint_id()}
> +Prototype:
> + at example
> +MR_ChoicepointId MR_null_choicepoint_id(void);
> + at end example
>  
>  @code{MR_null_choicepoint_id()} returns a ``null'' value that is
>  distinct from any value ever returned by @code{MR_current_choicepoint_id}.

Since MR_null_choicepoint_id returns (effectively) `0', for this to be true, 
you probably need this change to runtime/mercury_context.c, at the end of 
the init_context() function (about line 156 in the version I have):

        c->context_ticket_counter = 0;

s/0/1/

Actually, it looks like you haven't changed init_context() to initialise the 
new context_ticket_high_water field you've added; this should also be set to 
1.


Other than that, this stuff looks great.  Thanks!

Warwick

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