Files
mercury/extras/references/tests/glob_test_2.exp
Mark Brown 882674fc8a When creating a new backtrackable reference that uses choicepoint ids
Estimated hours taken: 20
Branches: main

When creating a new backtrackable reference that uses choicepoint ids
to avoid redundant trailing, set the initial value of the id using
MR_null_choicepoint_id() rather than MR_current_choicepoint_id().
If the current id is used, any updates that are performed before the
next choicepoint is created will not be trailed since the code for
updating the reference checks the stored id against the id that is
current at the time of the update, and only adds a trail entry if they
differ.

Normally this wouldn't be a problem because if execution ever does
backtrack to that initial choicepoint then it means it has backtracked
to a point before the reference was created, hence the reference should
no longer be live and it wouldn't matter that the reference was not
untrailed back to its initial value.  In this case the only effect of
this change is that at most one unnecessary entry may be added to the
trail.

However, if a predicate that creates such a reference is tabled, then the
reference will still exist in the table even after backtracking, and will
be produced again if that predicate is later called.  At this point the
reference will not necessarily have its correct initial value.

doc/reference_manual.texi:
	In the section on avoiding redundant trailing, advise users to
	use MR_null_choicepoint_id() if a mutable data structure is
	created by a predicate or function that is tabled.

extras/references/reference.m:
	Use MR_null_choicepoint_id() in the implementation of
	new_reference/2, and document the reason.

extras/references/tests/Mmakefile:
extras/references/tests/glob_test_2.m:
extras/references/tests/glob_test_2.exp:
	A test case that fails in grade asm_fast.gc.tr with the previous
	version of reference.m, but succeeds now.
2004-12-21 06:37:22 +00:00

2 lines
2 B
Plaintext