Commit Graph

290 Commits

Author SHA1 Message Date
Ralph Becket
eb135d2e23 Miscellaneous small library improvements.
Estimated hours taken: 3
	[Mainly down to getting reaquainted with remote CVS]

Miscellaneous small library improvements.

library/array.m
	Added `in' mode versions of array.m functions with `array_ui' modes.
	This is handy for immutable arrays.

library/std_util.m
	Added pred `isnt/2' to invert sense of semidet preds for higher
	order programming.  For example, where one might write
		Odds  = list__filter(odd, Xs)
	one could now also write
		Evens = list__filter(isnt(odd), Xs)
	Added func `id/1' that computes the identity function.
2000-04-27 09:27:26 +00:00
Zoltan Somogyi
c6c8365ca8 Finish the removal of unnecessary index predicates.
Estimated hours taken: 2

Finish the removal of unnecessary index predicates.

compiler/make_hlds.m:
	Do not generate type-specific index predicates for du types which
	(a) have user-defined equality, (b) are enums, or (c) have only one
	constructor, since for these types the comparison predicate does
	not call index.

compiler/unify_proc.m:
	Delete the code for generate bodies for type-specific index predicates
	for types which do not need them after the change to make_hlds.m.

library/builtin.m:
library/private_builtin.m:
library/std_util.m:
	Delete index predicates that have been made redundant by this change
	and the previous change involving index predicates.

	This should also fix a problem reported by Fergus, which was caused
	by the entry labels of these index predicates were not declared
	before being defined. Since they are no longer defined, the problem
	should go away.
2000-04-18 03:44:42 +00:00
Zoltan Somogyi
ec7cae8c58 Clean up some typeinfo handling code that is only enabled in non-gc grades.
Estimated hours taken: 2

Clean up some typeinfo handling code that is only enabled in non-gc grades.

runtime/mercury_deep_copy.[ch]:
	Make the typeinfo arg of MR_make_long_lived MR_TypeInfo, not Word.

runtime/mercury_tabling_macros.h:
	Treat the typeinfo arg of MR_make_permanent, a macro that calls
	MR_make_long_lived, a MR_TypeInfo, not Word.

extras/reference/nb_reference.m:
	Treat the typeinfo arg of MR_make_long_lived a MR_TypeInfo, not Word.

library/exception.m:
library/std_util.m:
	Treat the typeinfo arg of deep_copy as MR_TypeInfo, not Word.

	Also fix some other warnings in std_util.m.

library/private_builtin.m:
	Pass the addresses of type_ctor_infos (which function as type_infos)
	to MR_TABLE_SAVE_ANSWER.

	Expect that argument to be a typeinfo, not the name of a type_ctor_info
	to take the address of.

trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
	Treat the typeinfo arg of deep_copy as MR_TypeInfo, not Word.
2000-04-14 07:20:38 +00:00
Fergus Henderson
87324b814c Improve the static type checking and readability of
Estimated hours taken: 1.5

Improve the static type checking and readability of
some of the macros that we define, by using a new
MR_CHECK_EXPR_TYPE() macro.

runtime/mercury_std.h:
	Define the MR_CHECK_EXPR_TYPE() macro.

runtime/mercury_type_info.h:
library/std_util.m:
	Make use of it.

library/std_util.m:
	Add a few comments, and reorder some macro definitions
	do improve readability.  Delete an incorrect XXX comment.

runtime/mercury_make_type_info_body.h:
	Add a type cast, where we were using an MR_TypeInfo
	as an MR_PseudoTypeInfo.

runtime/mercury_type_info.c:
	Ensure that the parameter that we pass to
	MR_TYPE_VARIABLE_IS_UNIV_QUANT() has type
	`MR_PseudoTypeInfo', rather than `Unsigned'.
2000-04-02 06:37:22 +00:00
Fergus Henderson
e022590bf3 Fix some compiler warnings caused by Zoltan's recent MR_TypeInfo
Estimated hours taken: 0.25

extras/trailed_update/tr_store.m:
	Fix some compiler warnings caused by Zoltan's recent MR_TypeInfo
	changes.

library/std_util.m:
	Add a comment mentioning that tr_store.m uses ML_arg().
2000-03-26 07:22:27 +00:00
Zoltan Somogyi
c2a696d8b6 Clean up the runtime system's handling of type_infos and pseudo_type_infos.
Estimated hours taken: 40

Clean up the runtime system's handling of type_infos and pseudo_type_infos.
This cleanup has two major aspects. First, it represents type_infos and
pseudo_type_infos with distinct C types, and reducing the use of casts
to the minimum. These casts are in two kinds of places: in a few macros
defined in runtime/mercury_type_info.h, and at the interfaces between C code
and Mercury code (since Mercury code represents (pseudo-)type_infos, like
everything else, as Words). Part of this aspect is the separation of the
type "MR_TypeInfo" from the type "MR_TypeInfoParams"; a MR_TypeInfo can be
used as a source of type parameters directly only when it is first order.
Second, it removes the confusion between the types named "type_info" and
"type_ctor_info" defined by the modules private_builtin.m and std_util.m,
by renaming the types defined in std_util.m to "type_desc" and
"type_ctor_desc".

To avoid doing this cleanup twice, this diff also removes support for the
old type_ctor_info representation. This in turn makes it feasible to provide
conditionally enabled code to support unification and comparison by RTTI.

runtime/mercury_grade.h:
	Increment the binary compatibility version number. This is required
	by the dropping of support for old type_ctor_info representations.

runtime/mercury_type_info.h:
	Define the types MR_TypeInfo, MR_PseudoTypeInfo and MR_TypeInfoParams,
	and macros that operate on them.

	Remove the types and macros that were useful only with the old RTTI
	representation.

	Move the section that deals with initializing code addresses in
	type_ctor_info structure for grades without static code addresses
	to the logical place.

	Add a const qualifier to the MR_sectag_alternatives field in
	MR_DuPtagLayout, since this simplifies code manipulating du types.

	Convert the whole file to 4 space indentation, since it is a nuisance
	if only part of it is so indented.

runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
	Clean up the implementation as described above.

runtime/mercury_type_info.c:
runtime/mercury_make_type_info_body.h:
	Clean up the implementation as described above.

	Eliminate the code duplication between the function MR_make_type_info
	and MR_create_type_info, and their helpers, which do the same thing
	except for how they allocate memory, by putting the common code into
	the new file mercury_make_type_info_body.h, and including it twice
	in two different #define contexts.

	Move the (updated) documentation of those functions to
	mercury_type_info.h, where it belongs.

runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
	Clean up the implementation as described above.

	Eliminate the code duplication between the implementation of unify
	and compare, which do very similar jobs, by putting the common code
	into the new file mercury_unify_compare_body.h, and including it three
	times in two different #define contexts. The third time is for defining
	the body of a C function which does the same thing as compare. This
	is necessary for unification and comparison by RTTI, since the
	unification or comparison of two structured terms requires comparing
	their subterms. (There is no need for a separate C function for
	unification; the C comparison function is sufficient.)

	mercury_unify_compare_body.h has conditional support for unification
	and comparison by RTTI. Although this has been tested and is known
	to work, it is turned off for the moment. This may change after
	benchmarking.

runtime/Mmakefile:
	Add the new include files to the list.

library/std_util.m:
	Rename type_info to type_desc and type_ctor_info to type_info_desc.
	Keep the old names as equivalence types, for the time being.
	Document the representations.

	Move the macros that refer to type_descs and type_ctor_descs here from
	runtime/mercury_type_info.h, since this is the only place where they
	are used. Rename them to conform to the new names of the types.

	Clean up the implementation of the RTTI predicates and functions
	as described above. In the process, fix some bugs where type variables
	were expanded twice, with the second expansion's code being incorrect.
	Also factor out some common code, and unfactor some uncommon code
	(where a function had two uses, but its implementation was inefficient
	overkill for one of them).

library/builtin.m:
library/private_builtin.m:
library/io.m:
library/store.m:
runtime/mercury_layout_util.[ch]:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.[ch]:
	When calling C functions involving type_infos, cast them to the new
	types.

runtime/mercury_stack_layout.h:
	Fix a bug that was masked by casts in its client code.

compiler/rtti_out.m:
	Delete from the output a cast made unnecessary by the new const
	qualifier on MR_sectag_alternatives.

browser/browse.m:
browser/help.m:
library/io.m:
library/term.m:
tests/hard_coded/construct.m;
tests/hard_coded/existential_types_test.m:
tests/hard_coded/higher_order_type_manip.{m,exp}:
	Refer to the types defined in std_util.m by their new names.

tests/hard_coded/existential_rtti.{m,exp}:
	Make the test tougher by printing out not just one deconstructed term,
	but deconstructed versions of all the terms created by this test.
2000-03-24 10:28:07 +00:00
Fergus Henderson
84c8146d0d Fix several bugs in the trail handling.
Estimated hours taken: 20

Fix several bugs in the trail handling.
Also improve the documentation of trailing, and add a new macro
MR_choicepoint_newer() to the public trailing interface.

The bugs which this change fixes are:
  - choice point ids were being reused after commits,
    rather than only after backtracking;
  - for if-then-elses with nondet conditions, the generated code was
    using MR_commit rather than MR_solve as the MR_untrail_reason;
  - for semidet disjunctions, when committing to a particular disjunct
    the generated code was not calling MR_reset_ticket(..., MR_commit)
    to invoke function trail entries, and was also leaking a trail ticket
  - the all-solutions predicates in std_util.m were leaking trail
    tickets (i.e. allocating them but not pruning or discarding them).

runtime/mercury_trail.h:
runtime/mercury_regorder.h:
runtime/mercury_regs.h:
runtime/mercury_wrapper.c:
runtime/mercury_context.h:
runtime/mercury_engine.h:
	A bunch of changes to add a new virtual register
	`MR_ticket_high_water':
	- in mercury_trail.h, add MR_ticket_high_water_var variable;
	- in mercury_regorder.h, add MR_ticket_high_water macro;
	- in mercury_regs.h, add MR_TICKET_HIGH_WATER_RN macro;
	- in mercury_wrapper.c, change
	  print_register_usage_counts() to handle
	  MR_TICKET_HIGH_WATER_RN.
	- in mercury_context.h and mercury_engine.h,
	  add code to save/restore this new register when
	  appropriate.

runtime/mercury_trail.h:
	- Change MR_store_ticket() so that it does
	  `MR_ticket_counter = ++MR_ticket_high_water'
	  rather than just `MR_ticket_counter++'.
	- Add new macros MR_prune_ticket() and MR_prune_tickets_to(),
	  which only reset MR_ticket_counter, not MR_ticket_high_water.
	- Change the old macros MR_discard_ticket() and MR_discard_tickets_to()
	  so that they reset both MR_ticket_high_water and MR_ticket_counter.
	- Add new macro MR_choicepoint_newer().
	- Enclose macro arguments in parentheses.
	- Some minor changes to the documentation.

doc/reference_manual.texi:
	Document MR_choicepoint_newer().
	Update the documentation to reflect the fact that exceptions
	are now a standard part of Mercury.
	Clarify the documentation in the "Avoiding Redundant Trailing"
	section, and add a longish example.

compiler/notes/trailing.html:
	Add some documentation on the trail and how we manage it.

compiler/llds.m:
compiler/mlds.m:
	Add new `prune_ticket' and `prune_tickets_to' instructions,
	corresponding to the new macros defined in runtime/mercury_trail.h.
	Comment out the `discard_tickets_to' instruction, since it
	is no longer used in the compiler (the MR_discard_tickets_to()
	macro is only used by library/exception.m and the debugger's
	retry command).
	Replace the duplicated documentation in mlds.m with a pointer
	to llds.m.

compiler/ite_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
	Change the trail handling code generated after commits
	so that the ticket is pruned rather than discarded.

compiler/ite_gen.m:
	When generating the reset_ticket instruction for
	if-then-elses with nondet conditions, use `solve'
	rather than `commit' as the reset_trail_reason.

compiler/disj_gen.m:
	Add code to generate a reset_ticket(..., commit)
	instruction at the end of every non-last disjunct
	in semidet disjunctions.

compiler/dupelim.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/ml_elim_nested.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
	Trivial modifications to handle the changes to the
	trailing instructions.

library/exception.m:
	Change the trail handling code so that when the goal in an
	exception handler succeeds (rather than failing or throwing an
	exception), the trail ticket we created on entry to the
	handler is pruned rather than discarded.

library/std_util.m:
	Add a new impure predicate `discard_trail_ticket', which calls
	MR_discard_ticket(), and call it in `builtin_aggregate' and
	`do_while' to discard the ticket that gets allocated by the
	call to MR_store_ticket() in `get_registers'.
2000-03-20 05:27:30 +00:00
Zoltan Somogyi
cc9f51b2b5 Remove some long obsolete comments.
Estimated hours taken: 0.1

library/std_util.m:
	Remove some long obsolete comments.
2000-03-13 04:24:15 +00:00
Zoltan Somogyi
4ccc3b32ac Cleanup of the type_ctor_infos and their components, to achieve two goals.
Estimated hours taken: 65

Cleanup of the type_ctor_infos and their components, to achieve two goals.
First, the new data structure is defined in strongly typed C, with only
two unions, whereas the old data structure was defined by a bunch of macros
that used casts all over the place. The new design should therefore make it
significantly easier to debug code that uses RTTI, and to get it right in
the first place. Second, the new data structures are logically organized,
whereas the old ones had several bad features (such as fixed fields coming
after variable-length arrays in "structures") required by backward
compatibility.

For the time being, the runtime system will be able to handle type_ctor_infos
using both the old and the new data structures, which are distinguished by
the type_ctor_info's version number.

To minimize the disruption caused by such bootstrapping, this change also
incorporates an improvement in the RTTI: for most pseudo_type_infos included
in the RTTI, it records information that allows the runtime system to tell
whether the pseudo_type_info is ground or not; if it is, then the runtime
need not scan the pseudo_type_info looking for type parameters to expand.
Based on statistics I have gathered, this will eliminate between half and two
thirds of all such scans when we do unification and comparison by RTTI.

This change does not impact the structures of typeinfos, base_typeclass_infos
or typeclass_infos.

runtime/mercury_type_info.h:
	Define the C types for the new type_ctor_info components.

	Update the C type for type_ctor_infos themselves, and the macros
	that act on it.

	Centralize the list of files that depend on type info representation
	here.

	Make the names of the two macros that give the number of (all kinds of)
	type info vars and the number of existential type info vars consistent.

runtime/mercury_std.h:
	Change a comment to refer to one of these renamed macros by its new
	name.

compiler/rtti.m:
compiler/rtti_out.m:
	New files: rtti.m defines new types that allow us to construct
	Mercury representations of the C structures we want to emit,
	and rtti_out.m converts those representations to C definitions.
	These files are intended to be independent of whether the backend
	is LLDS or MLDS. At the moment, there are several vestiges that
	tie them to LLDS, mostly due to (a) the lack of a shared common
	infrastructure between llds_out.m and mlds_to_c.m, and (b)
	the continued use of the old representation of (pseudo-) typeinfos
	as rvals. These concerns will be addressed in a future change.

compiler/llds.m:
	Update the definition of the comp_gen_c_data and data_addr types
	to account for the new RTTI structures.

compiler/llds_out.m:
	Update the code to output comp_gen_c_data and data_addr values
	to account for the new RTTI structures.

	Make some parts of the code more modular, so that rtti_out.m
	can use what used to be selected parts of predicates.

	Export several predicates for use by rtti_out.m. Some of these
	should later be moved to a file for infrastructure shared by
	llds_out.m and mlds_to_*.m. Others should be made internal again
	when the representation of typeinfos is made independent of the LLDS.

	Rename some predicates to better reflect their purpose.

compiler/base_type_layout.m:
compiler/base_type_info.m:
	These files are obsoleted by this change. They remain in CVS, but
	are no longer used. All of base_type_info.m has been moved into
	type_ctor_info.m, and so have the parts of base_type_layout.m
	that create the functors and layout structures inside type_ctor_infos;
	the remaining part of base_type_layout.m is now in pseudo_type_info.m.

compiler/pseudo_type_info.m:
	New file containing the code to create pseudo_type_infos from
	base_type_layout.m, slightly updated for the new compiler structure.

compiler/type_ctor_info.m:
        New module: almost total rewrite of the base_type_info.m and the
	relevant part of base_type_layout.m for the new data structure.

	Do not invoke base_typeclass_info.m, since the structures it creates
	are not parts of the type_ctor_infos.

compiler/ml_base_type_info.m:
	Comment out obsolete unfinished code. It should be replaced by
	calls to type_ctor_info, once type_ctor_info's dependence on LLDS
	has been eliminated.

compiler/hlds_module.m:
	Rename the data structure from which type_ctor_infos are generated.
	Delete the data structure from which type_ctor_layouts were generated,
	since it is redundant.

	Switch to using field names.

compiler/make_tags.m:
compiler/hlds_data.m:
	make_tags.m had code that duplicated much of the the functionality
	of an existing predicate in hlds_data.m. This change moves that
	predicate to hlds_data where it belongs, and gives it an appropriate
	name.

compiler/mercury_compile.m:
	Do not invoke the predicates that used to be in base_type_layouts
	directly; let type_ctor_info do it for the types for which it is
	appropriate.

	Do invoke base_typeclass_info directly.

compiler/dead_proc_elim.m:
compiler/llds_common.m:
compiler/opt_debug.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
	Trivial changes to conform to the changes in the representation of
	compiler-generated C data.

compiler/notes/compiler_design.html:
	Updates to reflect the new files.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
	Provide alternate implementations of functionality that used the
	old functors and layout structures, to use the new ones instead
	if the relevant type_ctor_info's version number calls for it.
	In many cases, doing this cleanly required reducing the scopes of
	variables.

runtime/mercury_tabling.[ch]:
	Note where additional work on tabling of typeclass infos is needed,
	but do not do the work yet, since it would conflict with DJ's coming
	change.

library/std_util.m:
	Provide alternate implementations of functionality that used the
	old functors and layout structures, to use the new ones instead
	if the relevant type_ctor_info's version number calls for it.
	In many cases, doing this cleanly required reducing the scopes of
	variables.

	The predicates get_functor and construct take an integer argument
	that identifies a functor of a du type. The integer used to be
	the functor's ordinal number in the type definition, but this
	was not documented. It is now the functor's position in the list
	of the type's functors sorted first on name and then on arity.
	This functionality is potentially more useful, since io__read
	could do binary instead of linear search when looking for a given
	functor. This is an incompatibility, but a very minor one.

	Add a new predicate, get_functor_ordinal, to provide a way
	to convert lexicographic position into ordinal position.
	This is not used yet.

	Rename the two different kinds of variables named "info" so that
	one can tell them apart.

tests/hard_coded/construct.exp:
	Update the expected output of this test based on the new definition
	of the meaning of functor numbers in the get_functor and construct
	predicates in std_util.

tests/hard_coded/deep_copy.{m,exp}:
	Add some code to test the "type contains var" bit vector in du
	functor descriptions.

tests/hard_coded/existential_rtti.{m,exp}:
	Make the test case print out results as it goes along, to make it
	easier which subtask a core dump is coming from. Update the expected
	output accordingly.
2000-03-10 13:38:21 +00:00
Fergus Henderson
cb249f1800 Some modifications to the standard library code to
Estimated hours taken: 4

Some modifications to the standard library code to
get it to compile with `--high-level-code'.
(For a couple of files, namely std_util.m and
store.m, `-O0' is also needed.)

library/array.m:
library/benchmarking.m:
library/io.m:
library/private_builtin.m:
library/std_util.m:
library/store.m:
	Add `#include' declarations that are needed when compiling
	with --high-level-code.
	Wrap `#ifndef MR_HIGHLEVEL_CODE' around definitions
	of low-level C code that doesn't compile with --high-level-code.

library/exception.m:
library/std_util.m:
	Add multiple inclusion guards to all the typedefs defined
	inside `pragma c_header_code'.
	This is necessary since each `pragma c_header_code' fragment
	can be included in several automatically-generated header
	files which all get included by a single C file.

library/builtin.m:
	Implement copy/2 for --high-level-code.
2000-03-10 01:21:34 +00:00
Warwick Harvey
ee4734dd3b Added parametric instantiations corresponding to the parametric
Estimated hours taken: 0.5

library/std_util.m:
        Added parametric instantiations corresponding to the parametric
	types `maybe/1', `maybe_error/1', `pair/2' and `pair/1'.

NEWS:
	Added a news entry for this change.
2000-02-25 01:15:40 +00:00
Tyson Dowd
b2863b4716 Fix a bug with type_to_term introduced recently, reported by Wim
Estimated hours taken: 4

Fix a bug with type_to_term introduced recently, reported by Wim
Vanhoof.

Equivalent types were not being handled correctly when extracting
information about the functors.

It's not correct to simply test if a type is basically a du type,
unless you have expanded all equivalences first.  In the code given
the case for equivalences was unreachable.

It's better to fix the code to use type_ctor_rep to handle all cases
anyway.

library/std_util.m:
	Use type_ctor_rep instead of type_ctor_functors indicator.

tests/hard_coded/Mmakefile:
tests/hard_coded/type_to_term_bug.exp:
tests/hard_coded/type_to_term_bug.m:
	Regression test for this bug.
2000-02-17 06:38:34 +00:00
Zoltan Somogyi
26caad3050 Remove type_ctor_layouts and type_ctor_functors where not needed.
Estimated hours taken: 8, plus about 12 hours by Tyson.

Remove type_ctor_layouts and type_ctor_functors where not needed.
Simplify type_ctor_layouts by removing code that generates (and
documentations for) particularly representations that are no longer used
now that we use type_ctor_reps.

Several files also had miscellaneous cleanups and documentation fixes,
the most important being the move of the type_ctor_info structures
for preds/funcs from runtime/mercury_type_info.c to library/builtin.m.

compiler/base_type_layout.m:
        Simplify documentation.

        Remove references to representations in type_ctor_layouts that
        are no longer used.compiler/base_type_layout.m:

compiler/base_type_info.m:
	Keep base_type_info__type_ctor_rep_to_int in sync with
	MR_TypeCtorRepresentation.

runtime/mercury_grade.h:
runtime/mercury_cpp.h:
	Move the definitions of MR_STRINGIFY and MR_PASTEn to the new file
	mercury_cpp.h. Add MR_PASTEn for several new values of n, for use by
	mercury_type_info.h.

runtime/mercury_type_info.h:
	Define macros for creating type_ctor_info structures for builtin types.
	These have NULL layout and functor fields.

	Remove several obsolete macros.

runtime/mercury_layout_util.c:
	Use the new macros for defining a dummy type_ctor_info.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
	Modify the implementation of some RTTI functions to use the layout
	and functors structures only if they are defined.

runtime/mercury_type_info.c:
	Modify MR_collapse_equivalences to use the type_ctor_rep, not the
	functors indicator, to check for equivalence, since the latter is
	not guaranteed to be present.

	Move the type_ctor_info structure for preds/funcs to builtin.m.

library/array.m:
	Use these macros to define the type_ctor_info structure for array.

library/builtin.m:
	Use these macros to define the type_ctor_info structure for int,
	float, character, string, saved succip etc values, and for preds
	and funcs.

library/private_builtin.m:
	Use these macros to define the type_ctor_info structure for type_infos,
	type_ctor_infos, typeclass_infos and base_typeclass_infos.

	Move a c_header_code to the section that needs it.

library/std_util.m:
	Use the new macros to define the type_ctor_info structure for univ
	and for std_util's own type_info type.

	Modify the implementations of some RTTI predicates to use the
	layout and functors structures only if they are defined.
2000-01-19 09:45:23 +00:00
Fergus Henderson
14078f1aa9 Delete old bootstrapping code.
Estimated hours taken: 1

Delete old bootstrapping code.

runtime/mercury_ho_call.c:
	Delete code to handle old closure representations.

runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
library/std_util.m:
	Delete code to handle old RTTI representations.

runtime/mercury_grade.h:
	Increment the binary compatibility version number.
	This is needed to ensure that any code compiled
	with the old closure or RTTI representations will
	get a link error.

compiler/notes/release_checklist.html:
	Delete the item about deleting code to handle old closure
	representations, since it has been done now.
	(Also delete the item about muz, since that has been
	done now too.)
1999-12-11 15:41:06 +00:00
David Jeffery
93b1c221fe Implement RTTI for functors with existentially typed arguments.
Estimated hours taken: 160

Implement RTTI for functors with existentially typed arguments. This allows
these functors to be deconstructed (and therefore io__write works for them)
and deep_copied.

compiler/base_type_layout.m:
	Generate extra information in the stack layout: the RTTI needs to
	include the number of extra arguments added for type infos and
	typeclass infos for each functor, as well as the locations of the
	type infos for each type.

compiler/stack_layout.m:
	Pass some extra arguments indicating that the pseudo type infos being
	handled are not existentially quantified.

compiler/std_util.m:
	Change ML_expand so that it includes information about existentially
	quantified arguments in the expand info.

compiler/base_typeclass_info.m:
	Extend the typeclass info structure to include enough information to
	copy it at runtime.

runtime/mercury_type_info.c:
	Use the new information in the RTTI to look up the type info packed
	inside a constructor if the pseudo type-info in question is
	existentially quantified. This may involve looking inside a typeclass
	info or just taking the type info directly.

runtime/mercury_deep_copy_body.h:
	Use the new RTTI to lookup up type so existentially quantified
	variables when doing a deep copy.

	Implement a function to deep copy typeclass infos.

runtime/mercury_deep_copy.c:
	#define the appropriate things to make copy_typeclass_info work for
	the different ways of allocating memory.

runtime/mercury_type_info.h:
	Change some prototypes and add macros to access the new information in
	the functor descriptor.

	Change the macros which access typeclass infos to reflect the new
	structure.

tests/hard_coded/existential_rtti.{m,exp}:
	A bunch of test cases for this change.

tests/hard_coded/Mmakefile:
	Turn this test case on.
1999-12-09 04:42:39 +00:00
Zoltan Somogyi
0b660d7ffe Put MR_ prefixes on a couple of uses of string_const() that were missed
Estimated hours taken: 0.1

library/std_util.m:
	Put MR_ prefixes on a couple of uses of string_const() that were missed
	earlier, in order to allow bootstrap with -DMR_NO_BACKWARDS_COMPAT.
1999-12-09 03:38:15 +00:00
Peter Ross
f87f9d2120 Ensure that the none.gc and none grades compile using a compiler
Estimated hours taken: 24

Ensure that the none.gc and none grades compile using a compiler
other than gcc.  This is not completely tested as lcc on linux can't
generate code for boehm_gc, and 'cc -std1' on the alpha runs out of
memory while trying to link the compiler.  However the compiler does
bootstrap using just gcc and also with lcc with boehm_gc compiled by
gcc.

configure.in:
    -Wl,opt1,opt2 syntax is not supported by lcc instead use -Wlopt1
    -Wopt2.

compiler/export.m:
    Only output a label declaration if that label is exported, as the
    static label declarations are not legal C.

library/io.m:
compiler/stack_layout.m:
    Replace escape sequence \x with \\x in pragma c code.

library/array.m:
library/std_util.m:
    Define what the struct is before using it, so the correct size for the
    struct can be calculated.

library/private_builtin.m:
    Replace escape sequence \x with \\x in pragma c code.
    Ensure that there is at least one local variable so that the
    structure definition for holding the local vars contains something.

runtime/mercury_faultaddr.h:
    Remove an unnecessary cast.

runtime/mercury_reg_workarounds.h:
    #include sys/time.h for FD_ZERO().

runtime/mercury_stack_trace.h:
    Remove an extraneous ',' which was causing warnings.
1999-11-25 09:09:46 +00:00
Fergus Henderson
8f2a2976a8 Fix some bugs in the definition of the type_ctor_info for
Estimated hours taken: 0.5

library/std_util.m:
	Fix some bugs in the definition of the type_ctor_info for
	type_info/0 that Tyson recently added.  These bugs meant
	that it didn't compile in some grades.

	Also delete some long obsolete stuff inside `#ifdef COMPACT_ARGS'.
1999-11-16 12:18:19 +00:00
Zoltan Somogyi
e475da1d2c Put MR_ prefixes on uses of string_const(), make_aligned_string()
Estimated hours taken: 0.2

library/*.m:
	Put MR_ prefixes on uses of string_const(), make_aligned_string()
	variants, and COMPARE_EQUAL and friends, in order to allow bootstrap
	with -DMR_NO_BACKWARDS_COMPAT.
1999-11-15 10:12:19 +00:00
Tyson Dowd
7609c18a0a Remove code from mercury_bootstrap.c.
Estimated hours taken: 1

Remove code from mercury_bootstrap.c.

library/std_util.m:
        Add type_ctor_info for type_info/0.

runtime/mercury_bootstrap.c:
	Remove type_ctor_info for type_info/0 (and other supporting
	bootstrapping stuff).
1999-11-15 05:12:29 +00:00
Fergus Henderson
1249efcde0 Fix gcc 2.95 warnings about "non-static declaration follows static".
Estimated hours taken: 0.5

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_memory_zones.c:
	Fix gcc 2.95 warnings about "non-static declaration follows static".
1999-11-14 23:23:19 +00:00
Tyson Dowd
326eadc13b Add support for distinguishing types with user defined equality from
Estimated hours taken: 5

Add support for distinguishing types with user defined equality from
system defined equality.  This information is encoded in the
type_ctor_rep.

It is intended to be used for implementing RTTI driven compare and unify
procedures.

This change uses the version number in the type_ctor_info to allow
Easy Bootstrapping(TM).

compiler/base_type_info.m:
	Add new alternatives for user defined equality types.
	Update RTTI version number.
	Change `type_ctor_info_version' to `type_ctor_info_rtti_version'.

runtime/mercury_type_info.c:
	Define MR_get_new_type_ctor_rep which gets the type_ctor_rep,
	automatically converting older versions.
	(this change is just for bootstrapping).

runtime/mercury_grade.h:
	Note that MR_get_new_type_ctor_rep should be removed when binary
	compatibility number is increased.
	Also suggest inspecting code for RTTI version number checks in
	general.

runtime/mercury_type_info.h:
	Add a macro for checking sane values for RTTI version.

library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_wrapper.c:
	Use MR_get_new_type_ctor_rep to get the type_ctor_rep.
	(this change is just for bootstrapping).

	Add new alternatives to code that uses type_ctor_rep (at the
	moment they just fall through).

runtime/mercury_ho_call.c:
	Use MR_get_new_type_ctor_rep and also fix a bug Zoltan
	introduced when specializing the unification code.  Handle
	enums with user defined equality differently to normal enums.
1999-10-28 06:23:02 +00:00
Tyson Dowd
581a89622e Add version information to type_ctor_infos.
Estimated hours taken: 1.5

Add version information to type_ctor_infos.  This way bootstrapping is
easier and binary compatibility can be broken more slowly.

RTTI code can check version numbers before performing operations on
data structures that have recently changed their representation.
At the least they can abort cleanly and let you know that it's time
to re-compile, at best they can handle both forms of the data structure.
It is a bootstrapping problem that currently there is no version number
information in the appropriate slot in pre-built systems.

The version numbers start at 2 simply because 2 "occurs naturally"
much less often than 1 or 0.  And 42 was becoming trite.

compiler/base_type_info.m:
	Generate RTTI version numbers in compiler-generated
	type_ctor_infos.

library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
	Add RTTI version numbers for handwritten type_ctor_infos.

runtime/mercury_type_info.h:
	Add MR_RTTI_VERSION to define the current version of the RTTI
	info and the first version: MR_RTTI_VERSION_INITIAL which
	happens to have the value of 2.
1999-10-20 07:03:23 +00:00
Fergus Henderson
df867b10b7 Implement `do_while/4'.
Estimated hours taken: 2

library/std_util.m:
	Implement `do_while/4'.

samples/README:
samples/all_solutions.m:
samples/committed_choice.m:
samples/solutions/all_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
	Move the all_solutions.m and committed_choice.m samples
	into a new subdirectory `solutions', renaming committed_choice.m
	as `one_solution.m', and add a new file `some_solutions.m'
	illustrating the use of `do_while/4'.
	(Also fix some documentation rot in samples/README.)

NEWS:
	Mention the new predicate std_util__do_while/4.

tests/general/Mmakefile:
tests/general/do_while.m:
tests/general/do_while.exp:
	A test case for the new feature.
1999-10-20 03:14:35 +00:00
Fergus Henderson
a512184c16 Implement `builtin_aggregate' using impure Mercury
Estimated hours taken: 4

library/std_util.m:
	Implement `builtin_aggregate' using impure Mercury
	and some `pragma c_code' fragments, rather than
	using completely hand-coded low-level C code.

	This has several benefits:
		- it should allow the accurate garbage collector
		  to trace code using solutions/2, without
		  needing to hand-code the liveness information
		- the compiler can specialize the higher-order
		  calls in builtin_aggregate
		- the code is simpler and much more high-level,
		  and thus should be easier to maintain.
1999-10-19 04:45:09 +00:00
Fergus Henderson
88a513b580 Reorganize the routines for allocating and deallocating memory:
Estimated hours taken: 8

Reorganize the routines for allocating and deallocating memory:

runtime/mercury_std.h:
runtime/mercury_misc.c:
runtime/mercury_memory.h:
runtime/mercury_memory.c:
	- Put the routines in the proper place.
		Previously the declarations and definitions of the memory
		allocation/deallocation routines were spread amoungst
		all four of these files; I moved the ones in mercury_std.h
		and mercury_misc.c so that they are now all defined
		in mercury_memory.{h,c}
	- Avoid unnecessary duplication
		The following routines did exactly the same thing,
		modulo bugs(!):
			allocate_bytes()	and newmem()
			deallocate_bytes()	and oldmem()
			make()			and allocate_object()
			make_many()		and allocate_array()
	- Use appropriate names.
		I added `MR_' prefixes, and ensured that macros that are not
		function-like macros use all uppercase.  I also used a more
		consistent naming scheme.
		Previously the names used were
			(1) checked_malloc, checked_realloc
			(2a) allocate_bytes, deallocate_bytes, reallocate_bytes,
				allocate_object, allocate_array, resize_array
			(2b) newmem, oldmem, resizemem,
				make, make_many, resize_many
		The new names are
			(1) MR_malloc, MR_free, MR_realloc,
				MR_NEW, MR_NEW_ARRAY, MR_RESIZE_ARRAY
			(2) MR_GC_malloc, MR_GC_free, MR_GC_realloc,
				MR_GC_NEW, MR_GC_NEW_ARRAY, MR_GC_RESIZE_ARRAY

runtime/*.[ch]:
trace/*.[ch]:
library/array.m:
library/benchmarking.m:
library/io.m:
library/std_util.m:
extras/odbc/odbc.m:
extras/aditi/aditi.m:
	Use the new names.
1999-10-18 15:47:39 +00:00
Fergus Henderson
73c1c6c566 Delete some old bootstrapping code.
Estimated hours taken: 0.25

library/term.m:
library/std_util.m:
	Delete some old bootstrapping code.
1999-10-18 11:13:42 +00:00
Fergus Henderson
c958d29f8e Delete some obsolete comments (mostly ones about Prolog
Estimated hours taken: 0.25

library/string.m:
library/math.m:
library/std_util.m:
	Delete some obsolete comments (mostly ones about Prolog
	compatibility, which is no longer important).
1999-10-15 21:13:42 +00:00
Fergus Henderson
1f01db85bc Fix problems that broke the jump' and fast' grades.
Estimated hours taken: 3

Fix problems that broke the `jump' and `fast' grades.

library/builtin.m:
library/private_builtin.m:
library/array.m:
library/std_util.m:
	Use MR_MAYBE_STATIC_CODE() in initializers for type_ctor_infos,
	to avoid a compilation error when code addresses are not valid
	initializers.  Call MR_INIT_TYPE_CTOR_INFO() to ensure that the
	type_ctor_infos for c_pointer, type_info, type_ctor_info,
	typeclass_info, base_typeclass_info, array, and univ are
	initialized at runtime if they can't be initialized statically.
1999-10-13 07:01:29 +00:00
Zoltan Somogyi
466c844964 Make the retry command work in trailing grades (e.g. for HAL).
Estimated hours taken: 18

Make the retry command work in trailing grades (e.g. for HAL).

compiler/trace.m:
	In trailing grades, reserve two stack slots to hold (a) the trail
	pointer on entry, and (b) a new ticket obtained on entry. Arrange to
	put the numbers of these stack slots in the proc layout.

compiler/stack_layout.m:
	Put the number of the first of these stack slots in the proc layout.

compiler/code_info.m:
	Arrange the default: there are no such slots if debugging is not
	enabled.

compiler/code_gen.m:
	Insert code to discard the allocated ticket, in the success epilog
	of model_det procedures, the success and failure epilogs of model_semi
	procedures, and the failure epilogs of model_non procedures.
	(Model_det procedures don't have failure epilogs, and discarding
	the ticket in the success epilog of a model_non procedure would be
	premature.)

compiler/llds.m:
	Add two new alternatives to the type describing stack slots:
	a stack slot may contain a trail pointer or a ticket.

	Add a new reason for resetting the trail: a retry in the debugger.

compiler/llds_out.m:
	Minor changes to conform to llds.m, and to make diagnostic output
	less misleading.

library/builtin.m:
	Add the type_ctor_info for the new "types" describing stored trail
	pointers and tickets.

	Bring up to date the type_ctor_infos of other "types" used only
	for describing stack slots.

library/std_util.m:
	Add the missing code to handle the type_ctor_infos of trail pointers,
	tickets and other "types" used only for describing stack slots.

runtime/mercury_type_info.h:
	Add a new type_ctor representation value for stored trail pointers,
	tickets, and for other "types" used only for describing stack slots.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
	Add the missing code to handle the type_ctor_infos of trail pointers,
	tickets and other "types" used only for describing stack slots.

runtime/mercury_stack_layout.h:
	Add a field to proc layouts to hold either the number of the first
	of the two stack slots holding trail info, or -1.

runtime/mercury_trail.h:
	Add the new reason why the trail may be reset.

trace/mercury_trace.c:
	In trailing grades, reset the trail, with the reason being given
	as retry, when the debugger's retry command is executed.

extras/references/scoped_update.m:
extras/trailed_update/var.m:
clpr/cfloat.m:
extras/trailed_update/tests/func_trail_test.m:
extras/trailed_update/tests/func_trail_test_2.m:
	Handle MR_retry as a reason for unwinding the trail.
1999-10-08 02:56:24 +00:00
Fergus Henderson
9c8ecb5978 Fix a bug introduced by my improvements to memory profiling.
Estimated hours taken: 8

Fix a bug introduced by my improvements to memory profiling.
The bug was that it wasn't properly handling the case when the
pragma c_code fragments get inlined.

compiler/pragma_c_gen.m:
	When generating model_det/model_semi pragma c_code,
	#define MR_PROC_LABEL to be the entry label of the procedure
	containing the `pragma c_code' goal.

library/io.m:
library/string.m:
library/std_util.m:
library/store.m:
	Use MR_PROC_LABEL rather than hard-coding the procedure entry label.
1999-09-30 22:07:51 +00:00
Zoltan Somogyi
ac69527233 Supply missing MR_mktag wrappers on the first args of MR_field
Estimated hours taken: 0.1

library/std_util.m:
	Supply missing MR_mktag wrappers on the first args of MR_field
	references.
1999-09-28 02:03:48 +00:00
Zoltan Somogyi
bca4cb8162 Make the entire Mercury system bootstrap without backwards compatbility.
Estimated hours taken: 12

Make the entire Mercury system bootstrap without backwards compatbility.

compiler/llds_out.m:
compiler/pragma_c_gen.m:
	Add MR_ prefixes on generated code.

library/builtin.m:
library/exception.m:
library/private_builtin.m:
library/std_util.m:
library/store.m:
	Add MR_ prefixes.

runtime/mercury_deep_copy_body.h:
runtime/mercury_heap.h:
runtime/mercury_stacks.h:
runtime/mercury_string.h:
runtime/mercury_tags.h:
runtime/mercury_type_info.h:
	Add MR_ prefixes.

runtime/mercury_bootstrap.c;
runtime/mercury_engine.c;
runtime/mercury_ho_call.c;
runtime/mercury_tabling.c;
runtime/mercury_trace_base.c;
runtime/mercury_type_info.c;
runtime/mercury_wrapper.c;
	Add MR_ prefixes. In some cases, fix indentation; in functions using
	four-space indentation, convert all tabs to spaces.

trace/mercury_trace_browse.m:
trace/mercury_trace_declarative.m:
trace/mercury_trace_external.m:
trace/mercury_trace_help.m:
	Add MR_ prefixes.
1999-09-27 05:20:58 +00:00
Fergus Henderson
05bb4b1e88 More improvements to memory profiling.
Estimated hours taken: 0.75

More improvements to memory profiling.

runtime/mercury_tags.h:
	Add `_msg' versions of MR_list_cons() and MR_list_empty().
	these record the allocations in the memory profile.

runtime/mercury_heap.h:
	Add `_msg' versions of create1(), create2(), and create3(),
	for use by MR_list_cons_msg() and MR_list_empty_msg().
	Also delete create2_fb() and create2_bf() since they are not used.

library/io.m:
library/string.m:
library/store.m:
library/std_util.m:
	Change calls to MR_list_cons() to instead call MR_list_cons_msg()
	so that these allocations will get included in the memory profile.
	Likewise for MR_list_empty().
1999-09-24 06:25:16 +00:00
Fergus Henderson
3aaf4351f3 Improve memory profiling.
Estimated hours taken: 1.5

Improve memory profiling.

library/io.m:
library/string.m:
library/store.m:
library/std_util.m:
	Change calls to incr_hp() to instead call incr_hp_msg() so that
	these allocations will get included in the memory profile.
	Likewise for calls to tag_incr_hp(), incr_hp_atomic(), etc.

runtime/mercury_heap.h:
	When calling MR_record_allocation() in tag_incr_hp_msg(),
	use ENTRY(proclabel) rather than LABEL(proclabel), so that
	it works even if the allocation is actually done outside
	of the procedure, where the ENTRY label is visible but the
	LABEL isn't.  This can happen if pragma c_code that calls
	tag_incr_hp_msg() is inlined into some other procedure.
1999-09-24 05:47:14 +00:00
Fergus Henderson
9748ebf7ff Delete an unnecessary cast that was causing a compiler warning
Estimated hours taken: 0.25

library/std_util.m:
	Delete an unnecessary cast that was causing a compiler warning
	(and which for C compilers other than gcc might cause an error).
1999-09-17 06:40:32 +00:00
Peter Ross
39be0f175e Add functional and logical versions of fst and snd for the pair data
Estimated hours taken: 0.5

library/std_util.m:
    Add functional and logical versions of fst and snd for the pair data
    structure.
1999-08-20 07:57:12 +00:00
Warwick Harvey
3b26c80e4e Changed all type_ctor_info structures to use the MR_TypeCtorInfo type.
Estimated hours taken: 16

Changed all type_ctor_info structures to use the MR_TypeCtorInfo type.  This
is primarily to reduce the number of conflicts when merging independent
changes to the type_ctor_info structures.  As part of this, changed the type
of `string_const' to be `String' rather than `Word *', to avoid type errors
in the initialisers for compiler-generated type_ctor_infos.

compiler/llds_out.m:
	Don't emit definitions for type_ctor_info structs; instead use
	`MR_TypeCtorInfo_struct'.
	Removed a couple of casts of `string_const's to type `String', since
	they are no longer necessary.

compiler/llds.m:
	Changed the entries for `string_const' and `multi_string_const' in
	llds__const_type/2 to be `string' rather than `data_ptr'.

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
	Changed all the hand-defined type_ctor_info structures to just use
	`MR_TypeCtorInfo_struct', and added appropriate casts to the
	initialisers.  This included removing what appears to have been the
	last vestiges of `USE_TYPE_LAYOUT' conditionals since their use was
	so broken that it would probably be easier to re-implement the same
	functionality from scratch than to debug and rebuild on what was left.

runtime/mercury_type_info.h:
	Introduced `struct MR_TypeCtorInfo_struct' as the name of the
	(previously anonymous) struct which `MR_TypeCtorInfo' was a pointer
	to.
	Introduced `MR_DECLARE_TYPE_CTOR_INFO_STRUCT' for declaring
	type_ctor_info structures, since `MR_DECLARE_STRUCT' generates
	old-style names for type_ctor_infos.

runtime/mercury_deep_copy.c:
runtime/mercury_tabling.c:
library/std_util.m:
extras/exceptions/exception.m:
	Changed some uses of `MR_DECLARE_STRUCT' to use
	`MR_DECLARE_TYPE_CTOR_INFO_STRUCT' instead.

runtime/mercury_bootstrap.h:
	Added some `#define's of some old type_ctor_info type names to be
	`MR_TypeCtorInfo_struct', so that during bootstrapping the type
	names generated by the old version of the compiler work with the new
	scheme used in the manual definitions.

runtime/mercury_string.h:
	Changed the type of the macro `string_const/2'.  It used to cast to
	`Word *', now it casts to `String'.
1999-08-12 09:58:49 +00:00
Tyson Dowd
b845fcb08f Fix a bug that was causing the compiler to fail the debugger
Estimated hours taken: 4

Fix a bug that was causing the compiler to fail the debugger
tests with an unknown layout error.  std_util:type_info/0 needs
to be defined by hand so we can tell the RTTI system that it is
a type_info.

This change breaks bootstrapping with earlier compilers.
Use the CVS tag bootstrap_19990719_handdefine_typeinfo to
bootstrap this change.

compiler/type_util.m:
	Add std_util:type_info/0 to the hand defined types.
	This is different to private_builtin:type_info/1 which
	was already there.  It was type_info/0 that the debugger
	was failing on.

library/builtin.m:
	Move the type_ctor_info for c_pointer back into this module.
	It should have finished bootstrapping by now.

library/std_util.m:
	Define type_ctor_info as (abstractly) equivalent to a type_info
	instead of equivalent to a c_pointer.  This will allow this type
	to be handled by the garbage collector or debugger.

runtime/mercury_bootstrap.c:
	Move the RTTI info for c_pointer out of this module.
	Add the type_ctor_info for type_info/0 as it is now a hand
	defined type.

tests/hard_coded/higher_order_type_manip.exp:
	Fix expected test results not that type_ctor_info is equivalent
	to type_info/0.



Estimated hours taken: _____

<overview or general description of changes>

<directory>/<file>:
	<detailed description of changes>
1999-07-19 04:51:43 +00:00
Fergus Henderson
65782f9925 Add functions for the single output det predicates in a number
Estimated hours taken: 5

[This change was by Ralph Becket.
I'm just the person who reviewed it and committed it.  -fjh.]

Add functions for the single output det predicates in a number
of modules in the standard library.  Basically, for each

	:- pred f(in, ..., in, out) is det.

I have added the declaration

	:- func f(in, ..., in) = out.

and definition

	f(X1, ..., Xn) = Y :-
		f(X1, ..., Xn, Y).

library/char.m:
library/dir.m:
library/map.m:
library/string.m:
library/list.m:
library/set.m:
	Make the changes described above.

library/array.m:
	As above, except array input modes are all array_ui or
	array_di as appropriate and array output modes are array_uo.

library/int.m:
	Added forward versions of +/2, */2 and -/2 as plus/2, times/2
	and minus/2 respectively, to make it easier to pass these
	as arguments to higher-order predicates.
	Also added func constants for max_int, min_int and bits_per_int.

library/integer.m:
	Replaced local functions for list head, tail and length with
	calls to equivalent functions now defined in list.m.

library/io.m:
	Added func for error_message/2.

library/list.m:
	Add functions det_head/1 and det_tail/1 which abort on null lists.

library/set.m:
	Add functions map/2, filter_map/2 and fold/3.

library/std_util.m:
	Added utility function to construct a pair object from its
	arguments and general purpose higher order functions for
	partial functions and for function composition, exponentiation
	and exchanging the arguments of a binary function.
1999-07-07 15:19:42 +00:00
Tyson Dowd
eae3174a2c Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
Estimated hours taken: 30  (including debugging)

Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
representation of this type.

We want to do this because it allows us to check quickly to see
what kind of data representation is being used.  Previously this
information was spread throughout the type_ctor_layout and
type_ctor_functors data structures.  It was complex to interpret
and contained a lot of unnecessary duplication.

We can now omit data structures such as the type_ctor_layout in many
cases (it is only necessary for discriminated unions).  Because we rule
out some of the possible alternatives, the encodings used in the
type_ctor_layout can be simplified.  Also, the functors indicator in
type_ctor_functors can be removed, as it subsumed by this data
structure.

Use this representation in code that uses RTTI.

compiler/base_type_info.m:
	Add a missing alternative to the type_ctor_rep (this was a
	bug).

library/array.m:
library/builtin.m:
library/private_builtin.m:
runtime/mercury_bootstrap.c:
	Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types.

library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
	Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on
	data representations.

	Also, fix a bug in deep_copy when copying floating point values.
	I'm not sure when this stopped working, or if this is exactly
	the right fix, but it is more correct than the previous code.

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Update code to use MR_TYPECTOR_REP_*.
	Use a struct for type_ctor_info.

tests/hard_coded/Mmakefile:
tests/hard_coded/deep_copy.m:
tests/hard_coded/deep_copy.exp:
	Add a test case for deep_copy.
1999-07-06 06:32:33 +00:00
Tyson Dowd
3ecbe3eed0 Move the type_ctor_infos for array and univ into their proper places.
Estimated hours taken: 0.5

Move the type_ctor_infos for array and univ into their proper places.
This change has bootstrapped on most of our platforms, but actually
causes trouble linking small programs (because it creates runtime ->
library dependencies).  So we should move it as soon as possible.


library/array.m:
library/std_util.m:
	Add type_ctor_info for array and univ.

runtime/mercury_bootstrap.c:
	Remove type_ctor_info for array and univ.
1999-06-02 10:05:08 +00:00
Zoltan Somogyi
c6812299c2 Remove support for --args simple. We don't use it, we won't use it even for
Estimated hours taken: 4.5

Remove support for --args simple. We don't use it, we won't use it even for
experiments, and it is unnecessary complication.

If anybody were using --args simple, this would need bootstrapping, but
since nobody does, there is no need, and this can be committed as an
ordinary change.

compiler/options.m:
doc/user_guide.texi:
scripts/*.in:
scripts/*.sh-subr:
	Remove the --args option.

compiler/globals.m:
	Remove the args_method global and its access predicates.

compiler/handle_options.m:
	Don't set the args_method global from the option.

compiler/arg_info.m:
	Remove support for --args simple. This allows us to remove a now
	redundant argument from an exported predicate.

compiler/mercury_compile.m:
	Remove the code for passing -DCOMPACT_ARGS to the C compiler.

compiler/bytecode_gen.m:
compiler/fact_table.m:
compiler/follow_vars.m:
compiler/live_vars.m:
compiler/call_gen.m:
	Don't pass the unnecessary argument to arg_info.

compiler/call_gen.m:
compiler/unify_gen.m:
	Remove now unnecessary assertions.

compiler/hlds_pred.m:
	Don't include an args_method in proc_infos; instead, include
	a slot that says whether the procedure's address is taken or not.
	(In most cases, this determined whether the args_method was
	simple or compact.) We will need this bool in the near future
	(when we generate layout structures for procedures whose address
	is taken).

	Modify the signatures of exported predicates to accommodate
	this change to the data structure.

compiler/hlds_out.m:
	Print the new slot, not the args_method.

compiler/lambda.m:
	When creating procedures from lambdas, set the address-taken slot
	to address_is_taken instead of setting up its args_method.

compiler/make_hlds.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m.

compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/pd_info.m:
compiler/post_typecheck.m:
compiler/unify_gen.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m and make_hlds.m.

runtime/mercury_type_info.h:
	Remove the conditional definition of the macros that provided
	an argument-method-independent way of referring to the registers
	holding the inputs and outputs of e.g. unification procedures.
	We don't need the independence anymore, and using registers instead
	of macros in the code ensures that maintainers are aware of register
	reuse issues (e.g. they copy an input from r1 before overwriting it
	with an output).

runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
	Remove support for the args method component of the grade.

runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
library/*.m:
	Conform to the changes in runtime/mercury_type_info.h by effectively
	applying the #defines appropriate to compact args by hand.

	Remove code and data structures only needed for simple args.
	Remove comments needed only in the presence of uncertainty about
	the args method.
1999-06-01 09:46:20 +00:00
Zoltan Somogyi
c2da42e6d0 Allow the compiler to handle create rvals whose arguments have a size
Estimated hours taken: 16

Allow the compiler to handle create rvals whose arguments have a size
which is different from the size of a word. Use this capability to reduce
the size of RTTI information, in two ways.

The first way is by rearranging the way in which we represent information
about the live values at a label. Instead of an array with an entry for
each live value, the entry being a pair of Words containing a shape
representation and a location description respectively, use an array
of shape representations (still Words), followed by an array of 32-bit ints
(which may be smaller than Word) describing locations whose descriptions
don't fit into 8 bits, followed by an array of 8-bit ints describing
locations whose descriptions do fit into 8 bits.

The second way is by reducing the sizes of some fields in the C structs
used for RTTI. Several of these had to be bigger than necessary in the
past because their fields were represented by the args of a create rval.

On cyclone, this reduces the size of the object file for queens.m by 2.8%.

IMPORTANT
Until this change is reflected in the installed compiler, you will not be
able to use any modules compiled with debugging in your workspaces if the
workspace has been updated to include this change. This is because the RTTI
data structures generated by the old installed compiler will not be compatible
with the new structure definitions.

The workaround is simple: if your workspace contains modules compiled with
debugging, don't do a cvs update until this change has been installed.

configure.in:
	Check whether <stdint.h> is present. If not, autoconfigure
	types that are at least 16 and 32 bits in size.

runtime/mercury_conf.h.in:
	Mention the macros used by the configure script, MR_INT_LEAST32_TYPE
	and MR_INT_LEAST16_TYPE.

runtime/mercury_conf_param.h:
	Document the macros used by the configure script, MR_INT_LEAST32_TYPE
	and MR_INT_LEAST16_TYPE.

runtime/mercury_types.h:
	If <stdint.h> is available, get the basic integer types (intptr_t,
	int_least8_t, etc) from there. Otherwise, get them from the
	autoconfigure script. Define types such as Word in terms of these
	(eventually) standard types.

runtime/mercury_stack_layout.h:
	Add macros for manipulating short location descriptions, update the
	types and macros for manipulating long location descriptions.
	Modify the way the variable count is represented (since it now must
	count locations with long and short descriptions separately),
	and move it to the structure containing the arrays it describes.

	Reduce the size of the some fields in structs. This required some
	reordering of fields to avoid the insertion of padding by the compiler,
	and changes to the definitions of some types (e.g. MR_determinism).

runtime/mercury_layout_util.[ch]:
runtime/mercury_stack_trace.c:
runtime/mercury_accurate_gc.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
	Update the code to conform to the changes to stack_layout.h.

compiler/llds.m:
	Modify the create rval in two ways. First, add an extra argument to
	represent the types of the arguments, which used to always be implicit
	always a word in size, but may now be explicit and possibly smaller
	(e.g. uint_least8). Second, since the code generator would do the wrong
	thing with creates with smaller than wordsize arguments, replace
	the old must-be-unique vs may-be-nonunique bool with a three-valued
	marker, must_be_dynamic vs must_be_static vs can_be_either.

	Add uint_least8, uint_least16, uint_least32 (and their signed variants)
	and string as llds_types.

	Add a couple of utility predicates for checking whether an llds_type
	denotes a type whose size is the same as word.

compiler/llds_out.m:
	Use explicitly given argument types when declaring and initializing
	the arguments of a cell, if they are given.

compiler/llds_common.m:
	Don't conflate creates with identical argument values but different
	C-level argument types. The probability of a match is minuscule anyway.

compiler/stack_layout.m:
	Use the new representation of creates to generate the new versions of
	RTTI data structures.

compiler/code_exprn.m:
	If a create is marked must_be_static, don't inspect the arguments
	to decide whether it can be static or not. If it can't, we'll get
	an abort later on in llds_out or during C compilation anyway.

compiler/base_type_layout.m:
	When creating pseudo typeinfos, return the llds_type of the resulting
	rval.

	Minor changes required by the change in create.

compiler/base_type_info.m:
compiler/base_typeclass_info.m.m:
compiler/code_util.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/string_switch.m:
compiler/unify_gen.m:
compiler/vn_cost.m:
compiler/vn_filter.m:
compiler/vn_flush.m:
compiler/vn_order.m:
compiler/vn_type.m:
compiler/vn_util.m:
compiler/vn_verify.m:
	Minor changes required by the change in create.

library/benchmarking.m:
library/std_util.m:
	Use the new macros in hand-constructing proc layout structures.

library/Mmakefile:
	Add explicit dependencies for benchmarking.o and std_util.o
	on ../runtime/mercury_stack_layout.h. Although this is only a subset
	of the truth (in reality, all library objects depend on most of the
	runtime headers), it is a good tradeoff between safety and efficiency.
	The other runtime header files tend not to change in incompatible ways.

trace/Mmakefile:
	Add explicit dependencies for all the object files on
	../runtime/mercury_stack_layout.h, for similar reasons.
1999-04-30 06:21:49 +00:00
Zoltan Somogyi
dfb59414e4 Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
Estimated hours taken: 3

Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
In the process, get rid of the grade component MR_DEBUG_NONDET_STACK,
since this makes the update to mercury_stacks.h simpler and its use is
long obsolete.

runtime/mercury_tags.h:
	Put MR_ prefixes in front of everything defined here.

runtime/mercury_stacks.h:
	Put MR_ prefixes in front of everything defined here.

	Remove support for MR_DEBUG_NONDET_STACK. Replace most of the
	lost functionality by calling an updated mkframe_msg.

	Remove the definitions of push() and pop(). Their use conflicts with
	the idea that everything on the det stack is part of a frame, which
	the RTTI stuff depends on.

runtime/mercury_bootstrap.h:
	Add backward compatibility macros for the old names in the above two
	files.

	Remove some old entries in this file which are no longer needed.

runtime/mercury_wrapper.c:
	Remove the only uses of push() and pop().

	Put MR_ in front of some things that need them.

runtime/mercury_engine.c:
	Put MR_ in front of some things that need them.

runtime/mercury_misc.[ch]:
	Make mkframe_msg get the name of the procedure that owns the stack
	frame from an explicitly passed argument, rather than the prednm slot
	(which no longer exists). This actually improves low-level debugging
	support without MR_DEBUG_NONDET_STACK.

	Remove unnecessary return statements.

runtime/mercury_debug.h:
	Pass on the new arg of mkframe_msg.

	Fix long lines.

runtime/mercury_conf_param.h:
	Remove the documentation of MR_DEBUG_NONDET_STACK.

runtime/mercury_grade.h:
	Remove the grade component of MR_DEBUG_NONDET_STACK.

doc/reference_manual.texi:
	Document the MR_ prefixed versions of list_empty, list_cons etc.

library/io.m:
library/std_util.m:
library/string.m:
	Add prefixes to some references to the runtime.
1999-04-30 04:25:42 +00:00
Tyson Dowd
6cb525f6bc This change does some renaming to match the new nomenclature introduced
Estimated hours taken: 5

This change does some renaming to match the new nomenclature introduced
in the RTTI paper.

Rename simple tags as unshared tags, complicated tags as shared
remote tags and complicated constant tags as shared local.
Also rename "simple vector" as "functor descriptor",
"functors vector" as "enum vector".

compiler/base_type_layout.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/hlds_data.m:
compiler/make_tags.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/unify_gen.m:
	Perform these renamings in the compiler, renaming a few
	functors and data structures.

library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Perform these renamings in the library and runtime, renaming
	macros and variables.
1999-04-22 01:04:32 +00:00
Zoltan Somogyi
3bf462e0b7 Switch to a closure representation that includes runtime type and procedure id
Estimated hours taken: 36

Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.

This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.

Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.

configure.in:
	Find out what the right way to refer to a variable-sized array
	at the end of a struct is.

runtime/mercury_ho_call.h:
	New file to define the structure of closures and macros for accessing
	closures.

runtime/Mmakefile:
	Add the new header file.

runtime/mercury_ho_call.c:
	Add an entry point to handle calls to new-style closures. The code
	to handle old-style closures, which was unnecessarily duplicated for
	each code model, stays until all the installed compilers use the new
	closure representation.

	Until that time, the new entry point will contain code to detect
	the use of old-style closures and invoke the old code instead.
	This allows stage1s compiled with old compilers to use the old style
	and stage2 to use the new style without any special tricks anywhere
	else.

	Add a new entry point to handle method calls of all code models.
	The old entry points, which had the same code, will also be deleted
	after this change has been bootstrapped.

runtime/mercury_calls.h:
	Remove the macros that call closures. Their interface sucked, they
	were not used, and their implementation is now out of date.

runtime/mercury_stack_layout.h:
	Add a new type, MR_Type_Param_Locns, for use by the C type
	representing closures. Since MR_Stack_Layout_Vars has a field,
	MR_slvs_tvars, which references a data structure identical
	in every way to MR_Type_Param_Locns, change the type of that field
	to this new type, instead of the previous cheat.

runtime/mercury_layout_util.h:
	Minor update to conform to the new type of the MR_slvs_tvars field.
	(This is the only use of that field in the system.)

runtime/mercury_type_info.h:
	Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
	are just Word, but later we can make them more accurate.
	In the meantime, we can refer to them instead of to Word,
	making code clearer. One such reference is now in mercury_ho_call.h.

compiler/notes/release_checklist.html:
	Add a reminder to remove the redundant code from mercury_ho_call.c
	after bootstrapping.

compiler/llds.m:
	Replace three code addresses for calling closures and another three
	for calling methods with one each.

compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
	Trivial updates in accordance with the change to llds.m

compiler/code_info.m:
	Move the code to handle layouts to continuation_info.m,
	since that's where it belongs. Leave only the code for picking
	up parameters from code_infos and for putting results back in there.

	Remove the redundant arguments of code_info__init, and extract
	them from ProcInfo, to make clear that they are related.

compiler/code_gen.m:
	Since we pass ProcInfo to code_info__init, don't pass its components.

compiler/continuation_info.m:
	Add the code moved from code_info.m, in a form which takes explicit
	arguments for things that used be hidden in the code_info.

	Add new code, closely related to the moved code, that creates
	layout info from a procedure's argument info, rather than from a
	(part of) the current code generator state. This way, it can be
	invoked from places that don't have a code_info for the procedure
	for which they want to generate layouts. This is the case when
	we generate layouts for closures.

compiler/par_conj_gen.m:
compiler/trace.m:
	Minor changes required by the move of stuff from code_info to
	continuation_info.

compiler/stack_layout.m:
	Export some predicates for use by unify_gen.

compiler/unify_gen.m:
	Switch to creating new style closures, complete with layout info.

	Optimize the code for extending closures a bit. By copying the
	fixed words of the closure outside the loop, we avoid incurring
	the loop overhead twice.

compiler/code_util.m:
	Add a couple of utility predicates for continuation_info.m and
	unify_gen.m

library/benchmarking.m:
library/std_util.m:
	Refer to the new entry point for handling closures.

browser/dl.m:
	Use the new closure representation.

	Note that extras/dynamic_linking/dl.m, which is supposed to be
	the same as browser/dl.m but is not, should also be updated, but
	this will be handled later by Fergus.

tests/hard_coded/closure_extension.{m,exp}:
	A new test case to exercise the code for extending closures.

tests/hard_coded/Mmakefile:
	Enable the new test case.
1999-04-16 06:05:49 +00:00
Tyson Dowd
9e3a8eae9c During the writing of the RTTI paper, we decided that type_ctor_info
Estimated hours taken: 8

During the writing of the RTTI paper, we decided that type_ctor_info
was a much better name than base_type_info.

Rename base_type* as type_ctor*, except we don't rename the modules
base_type_info and base_type_layout just yet.

Most of these changes were made using the following sed patterns:

s/base_type_info/type_ctor_info/g
s/base_type_layout/type_ctor_layout/g
s/base_type_functors/type_ctor_functors/g
s/BASETYPE_INFO/TYPE_CTOR_INFO/g
s/TYPEFUNCTORS/TYPE_CTOR_FUNCTORS/g
s/TYPELAYOUT/TYPE_CTOR_LAYOUT/g
s/BASE_TYPEINFO/TYPE_CTOR_INFO/g
s/BASE_TYPE_INFO/TYPE_CTOR_INFO/g
s/BaseTypeInfo/TypeCtorInfo/g
s/BaseTypeLayout/TypeCtorLayout/g
s/base_type(/type_ctor(/g
s/:- module type_ctor_info/:- module base_type_info/g
s/:- module type_ctor_layout/:- module base_type_layout/g
s/type_ctor_info__/base_type_info__/g
s/type_ctor_layout__/base_type_layout__/g
/import_module/s/type_ctor_info/base_type_info/g
/import_module/s/type_ctor_layout/base_type_layout/g

compiler/*.m:
library/*.m:
runtime/*.{c,h}:
profiler/demangle.m:
util/mdemangle.c:
	Applied the above sed commands.

runtime/mercury_bootstrap.h:
	Add bootstrapping #defines so the type_ctor_* substitutions in
	the library don't cause link problems.

	Delete some redundant bootstrapping definitions.
1999-03-22 08:09:52 +00:00
Zoltan Somogyi
f7dae2f885 Add two new types:
Estimated hours taken: 0.1

library/std_util.m:
	Add two new types:

	:- type maybe_error ---> ok ; error(string).
	:- type maybe_error(T) ---> ok(T) ; error(string).

	We should think about replacing several types in
	io.m with instances of these.
1999-03-12 01:20:28 +00:00
Fergus Henderson
469036b27c Add parentheses to use of `some' in type declaration for has_type/2,
Estimated hours taken: 0.1

library/std_util.m:
        Add parentheses to use of `some' in type declaration for has_type/2,
	to avoid syntax error for SICStus Prolog.
1999-02-07 14:07:24 +00:00