mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 20:03:44 +00:00
Estimated hours taken: 4.5
Fix some bugs in code generation for nondet disjunctions and
if-then-elses. The compiler was incorrectly releasing the temp stack
slots used to save the heap pointer and trail pointer at the start
of the else or the last clauses, thus allowing them to be reused not
only in the else case or the last clause, but also by goals following the
disjunction or if-then-else, even though the values in these slots might
be needed again on backtracking into the condition or the earlier
disjunctions.
Thanks to Warwick Harvey for reporting this bug.
compiler/code_info.m:
Add new predicate `code_info__maybe_reset_and_pop_ticket',
which is like `code_info__maybe_reset_and_discard_ticket',
except that it does not release the temp stack slot.
compiler/disj_gen.m:
compiler/ite_gen.m:
When generating code for nondet goals that save
and restore the hp and trail, if the saved
values might be needed again on backtracking
into the current goal from one that follows
(i.e. in nondet disjunctions and in if-then-elses
with nondet conditions), make sure we use
`code_info__maybe_reset_and_pop_ticket' and
`code_info__reset_hp' instead of
`code_info__maybe_reset_and_discard_ticket' and
`code_info__reset_and_discard_hp'.
compiler/code_info.m:
Include the temp_avail_slots in the set of things
that slap_code_info does not update. Temp slots
that were acquired (and not released) in one branch
of a branched goal need to be still reserved at the
end of the branched goal.
extras/trailed_update/Mmakefile:
extras/trailed_update/samples/Mmakefile:
extras/trailed_update/samples/tests.m:
extras/trailed_update/samples/tests.exp:
extras/trailed_update/tests/Mmakefile:
extras/trailed_update/tests/var_test.m:
extras/trailed_update/tests/var_test.exp:
Add a new subdirectory `tests' in extras/trailed_update,
and move the test case `tests.{m,exp}' from the samples
subdirectory into the tests subdirectory, at the same
time renaming it as `var_test.{m,exp}'.
extras/trailed_update/tests/Mmakefile:
extras/trailed_update/tests/func_trail_test.m:
extras/trailed_update/tests/func_trail_test.exp:
extras/trailed_update/tests/func_trail_test_2.m:
extras/trailed_update/tests/func_trail_test_2.exp:
Add a couple of regression tests for the bug mentioned above.
These tests need to go here rather than somewhere in the
main `tests' directory (e.g. `tests/hard_coded'), because
they only work in trailing grades, and the normal tests are
compiled in lots of grades, many of which don't have
corresponding trailing grades installed.
(I suppose we could put them in the main `tests' directory,
and only enable them for trailing grades, but it just seemed
easier to put them here.)
25 lines
804 B
Plaintext
25 lines
804 B
Plaintext
test_delaying_1: no
|
|
test_delaying_2: yes
|
|
var.m: warning: goal floundered.
|
|
1 outstanding delayed goal.
|
|
X = alias(free(<delayed goal>)) [ground: no]
|
|
Y = alias(free) [ground: no]
|
|
test_delaying_1: no
|
|
test_delaying_2: yes
|
|
test_delaying_3: var.m: warning: goal floundered.
|
|
1 outstanding delayed goal.
|
|
yes: X = alias(free(<delayed goal>)) [ground: no], Y = alias(free) [ground: no]
|
|
test_delaying_4: var.m: warning: goal floundered.
|
|
1 outstanding delayed goal.
|
|
yes: X = alias(free(<delayed goal>)) [ground: no]
|
|
test_ground:
|
|
Z = alias(ground(42)) [ground: yes(42)]
|
|
Z2 = alias(alias(alias(ground(42)))) [ground: yes(42)]
|
|
test_alias_twice:
|
|
A = alias(free) [ground: no]
|
|
B = alias(free) [ground: no]
|
|
test_dup_call_bug:
|
|
A1 = alias(ground(42)) [ground: yes(42)]
|
|
A2 = alias(free) [ground: no]
|
|
Done.
|