Add two new annotations for foreign_procs, tabled_for_descendant_io and

Estimated hours taken: 16
Branches: main

Add two new annotations for foreign_procs, tabled_for_descendant_io and
tabled_for_io_unitize.

By adding the tabled_for_descendant_io annotation to a foreign_proc with I/O
states, the programmer is asserting that the foreign_proc itself doesn't do
I/O, and nor does any foreign language code it calls, though the Mercury
predicates it calls may.

By adding the tabled_for_io_unitize annotation to a foreign_proc with I/O
states, the programmer is saying that both the foreign_proc itself and the
Mercury predicates it calls may do I/O. To avoid the I/O tabling problems
that would arise on retries from Mercury code called by the foreign_proc,
the programmer is requesting that the debugger treat calls to the foreign_proc
as a unit. This means that if I/O tabling is turned on, then the implementation
will disable both debugging and I/O tabling inside Mercury code called from
the foreign_proc.

compiler/prog_data.m:
	Add the tabled_for_descendant_io and tabled_for_io_unitize annotations.

	Parameterize the eval_table_io eval_method to accommodate the
	unitization of foreign_procs.

compiler/prog_io_pragma.m:
	Add code to read in the tabled_for_descendant_io and
	tabled_for_io_unitize annotations.

compiler/table_gen.m:
	Handle the new annotations. Procedures with tabled_for_descendant_io
	annotations don't need to be transformed at all; procedures with
	tabled_for_io_unitize annotations need a small variation of the
	existing transformation.

	Fix an existing bug that made the HLDS not type-correct. Create new
	variables with the appropriate type; do not assume all new variables
	are c_pointers, since some are integers.

library/table_builtin.m:
	Add two new predicates that table_gen.m emits calls to on either side
	of the code of foreign_procs with tabled_for_io_unitize annotations.

compiler/hlds_out.m:
compiler/layout_out.m:
compiler/mercury_to_mercury.m:
	Update the mechanisms for printing out eval methods.

compiler/hlds_pred.m:
	Update the mechanisms for performing tests on eval methods.
	Change some of the predicates involved to functions, partly in order
	to make future maintenance easier.

compiler/det_analysis.m:
compiler/det_report.m:
compiler/make_hlds.m:
compiler/modes.m:
	Conform to the change from predicates to functions.

runtime/mercury_trace_base.c:
	Update the documentation of MR_trace_enabled.

runtime/mercury_stack_layout.h:
	Add names for the new eval methods.

trace/mercury_trace.c:
	Handle the new eval methods.

tests/debugger/tabled_read_unitize.{m,inp,exp,data}:
	A new test case to check the handling of unitized foreign_procs.

tests/debugger/Mmakefile:
	Turn on the new test case.
This commit is contained in:
Zoltan Somogyi
2002-07-26 04:20:14 +00:00
parent 1167698388
commit 41724c68de
20 changed files with 543 additions and 189 deletions

View File

@@ -1144,6 +1144,16 @@ parse_pragma_foreign_proc_attributes_term(ForeignLanguage, Pragma, Term,
thread_safe(thread_safe) -
thread_safe(not_thread_safe),
tabled_for_io(tabled_for_io) -
tabled_for_io(tabled_for_io_unitize),
tabled_for_io(tabled_for_io) -
tabled_for_io(tabled_for_descendant_io),
tabled_for_io(tabled_for_io) -
tabled_for_io(not_tabled_for_io),
tabled_for_io(tabled_for_io_unitize) -
tabled_for_io(tabled_for_descendant_io),
tabled_for_io(tabled_for_io_unitize) -
tabled_for_io(not_tabled_for_io),
tabled_for_io(tabled_for_descendant_io) -
tabled_for_io(not_tabled_for_io),
purity(pure) - purity(impure),
purity(pure) - purity(semipure),
@@ -1278,10 +1288,20 @@ parse_threadsafe(term__functor(term__atom("not_thread_safe"), [], _),
:- pred parse_tabled_for_io(term, tabled_for_io).
:- mode parse_tabled_for_io(in, out) is semidet.
parse_tabled_for_io(term__functor(term__atom("tabled_for_io"), [], _),
tabled_for_io).
parse_tabled_for_io(term__functor(term__atom("not_tabled_for_io"), [], _),
not_tabled_for_io).
parse_tabled_for_io(term__functor(term__atom(Str), [], _), TabledForIo) :-
(
Str = "tabled_for_io",
TabledForIo = tabled_for_io
;
Str = "tabled_for_io_unitize",
TabledForIo = tabled_for_io_unitize
;
Str = "tabled_for_descendant_io",
TabledForIo = tabled_for_descendant_io
;
Str = "not_tabled_for_io",
TabledForIo = not_tabled_for_io
).
% XXX For the moment we just ignore the following attributes.
% These attributes are used for aliasing on the reuse branch,
@@ -1294,7 +1314,6 @@ parse_aliasing(term__functor(term__atom("no_aliasing"), [], _)).
parse_aliasing(term__functor(term__atom("unknown_aliasing"), [], _)).
parse_aliasing(term__functor(term__atom("alias"), [_Types, _Alias], _)).
:- pred parse_max_stack_size(term::in, int::out) is semidet.
parse_max_stack_size(term__functor(