Commit Graph

29 Commits

Author SHA1 Message Date
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
b293bd999d Replace __ with . as the module qualifier everywhere.
Estimated hours taken: 1
Branches: main

library/*.m:
	Replace __ with . as the module qualifier everywhere.

tests/hard_coded/test_injection.exp:
	Replace __ with . as the module qualifier in expected exceptions.
2006-03-07 22:23:58 +00:00
Julien Fischer
7a8681f774 Annotate foreign_procs with trail usage information throughout most of
Estimated hours taken: 0.5
Branches: main

library/*.m:
	Annotate foreign_procs with trail usage information throughout most of
	the standard library.

	Fix an out of date comment in string.m.

	Fix some minor formatting problems.
2005-12-14 10:33:56 +00:00
Zoltan Somogyi
57b8f436eb Convert to four-space indentation most of the library modules that
Estimated hours taken: 4
Branches: main

library/*.m:
	Convert to four-space indentation most of the library modules that
	weren't already indented that way. Use predmode syntax where possible.
	In some modules, shorten long lines by deleting module name prefixes.
	Fix departures from our coding standards.

	In some modules, simplify code, mostly using field names and/or state
	variables.

	There are no changes in algorithms, except for neg_list in integer.m.
2005-10-17 11:35:22 +00:00
Zoltan Somogyi
2db67ed200 Provide versions of foldl and fold2 that work with two accumulators.
Estimated hours taken: 1.5
Branches: main

library/sparse_bitset.m:
	Provide versions of foldl and fold2 that work with two accumulators.

	Convert to four-space indentation.

library/relation.m:
	Fix some efficiency problems caused by folds on sparse_bitsets.
	Use the new two-accumulator variants instead of using pairs,
	which avoids memory allocation. Use the folds over predicates
	instead of the folds over functions, since sparse_bitset.m implements
	the folds over functions by converting the function into a predicate,
	which takes time.

	Make some lambda expressions into named predicates.

	Convert to four-space indentation.
2005-09-01 02:22:44 +00:00
Zoltan Somogyi
88c7539230 Import only one module per line, as we already do in the compiler
Estimated hours taken: 0.3
Branches: main

library/*.m:
	Import only one module per line, as we already do in the compiler
	directory.
2005-06-16 04:08:07 +00:00
Julien Fischer
b13a50c7f6 Make the positioning of descriptive comments conform
Estimated hours taken: 3.5
Branches: main

Make the positioning of descriptive comments conform
to the coding standard for the following library modules.

Convert preds to predmode syntax where possible.

Make the ordering of related predicates and functions
conform to the coding standard, where the descriptive
comment makes it possible to do that.

Other minor changes are listed below.

library/bimap.m:
	Fix capitalisation of a few comments.

library/dir.m:
	s/throw an exception/throws an exception/.

library/exception.m:
	Fix the comment about the exception_result/1 type.
	There is only one type and an inst following the comment.

library/map.m:
	Remove the unique modes for map.set/4, map.delete/3 and
	map.delete_list/3.

library/rbtree.m:
	Remove the unique modes for rbtree.set/4, rbtree.delete/3,
	rbtree.remove/4, rbtree.remove_smallest/4 and rbtree.remove_largest/4.

library/tree234.m:
	Remove left over unique modes for preds.

library/set.m:
	XXX the ordering of procedures in this module is a bit strange.
library/set_bbbtree.m:
library/set_unordlist.m:
	Remove various unique modes for set operations like
	delete/3.  (Some of these were commented out anyway).

library/term_to_xml.m:
	Fix a spot where line width exceeded 79 characters.

library/array.m:
library/assoc_list.m:
library/random.m:
library/multi_map.m:
library/pqueue.m:
library/queue.m:
library/bool.m:
library/char.m:
library/construct.m:
library/counter.m:
library/deconstruct.m:
library/eqvclass.m:
library/gc.m:
library/io.m:
library/sparse_bitset.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/string.m:
library/term.m:
library/term_io.m:
library/type_desc.m:
library/varset.m:
	As above.
2005-01-24 23:16:40 +00:00
Zoltan Somogyi
95b64f73a1 Move changes in the library on the mode-constraints branch onto the trunk.
Estimated hours taken: unknown (but probably several weeks by dmo)
Branches: main

Move changes in the library on the mode-constraints branch onto the trunk.

library/eqvclass.m:
	Add some utility functions and predicates.

library/map.m:
	Add some utility functions and predicates, and some type
	specialization directives.

library/tree234.m:
	Add some utility functions and predicates.

library/robdd.m:
	Add this module, which provides a Mercury interface to the C code in
	robdd/bryant.c. In some places, robustness has been sacrificed for
	speed, and the module is not (yet) as well documented as it could be;
	therefore it is not (yet) included in the documentation.

library/pprint.m:
	Print robdds nicely, since this is essential to debugging code handling
	robdds. (This is why adding robdd.m in some other directory, e.g. the
	compiler, wouldn't really work.)

library/term.m:
	Add a function that returns the highest numbered vars created from
	a var_supply.

library/varset.m:
	Add a function that returns the highest numbered vars created from
	a varset.

library/unsafe.m:
	Add this module here, since it may be needed to debug code in the
	library (e.g. in robdd.m.).

library/library.m:
	Add a reference to the robdd module, and a commented out reference
	to the unsafe module. If a developer needs to use unsafe.m anywhere
	in the Mercury implementation, they can uncomment this reference
	in the relevant workspace.

	Make the list of modules easier to maintain (especially in the case
	of CVS conflicts) by listing one module per line.

	Fix formatting of some foreign_procs.

NEWS:
	Mention the new predicates and functions.

Mmake.workspace:
	Add a new make variable that specifies the location of the robdd
	subdirectory.

Mmakefile:
	Add rules for handling the robdd subdirectory.

configure.in:
	Check whether the compiler can handle local foreign_decls, since
	robdd.m now needs this.

tools/bootcheck:
	Add the robdd subdirectory to the stage 2 & 3 directories.

deep_profiler/unsafe.m:
	Remove this module from this directory.

doc/Mmakefile:
	Do not include the robdd and unsafe modules in the documentation.
	The robdd module because (in its present state) it is not stable
	enough, the unsafe module because it is not enabled in installed
	versions of the library.

robdd/Makefile:
	Update the set of default compilation flags. The main code in this
	directory, bryant.c, is #included in library/robdd.m, and the only
	other programs in this directory are test programs.

robdd/Mmakefile:
	New file. Includes a mechanism to compile bryant.c in the robdd
	subdirectory, since this can give cleaner error messages than
	compiling library/robdd.m.

robdd/bryant.[ch]:
	Huge cleanup of these files. Add MR_ROBDD_ prefixes to global symbols,
	make the formatting conform to our standards, and fix irregularities
	in the uses of the macros that control the use of optional facilities.

robdd/bryantPrint.[ch]:
robdd/table.[ch]:
robdd/test_abexit.c:
robdd/test_abunify.c:
robdd/test_abglb.c:
robdd/test_iff.c:
robdd/test_rename.c:
robdd/test_restrict.c:
robdd/test_rglb.c:
robdd/test_upclose.c:
robdd/test_var.c:
robdd/test_vars.c:
robdd/timing.[ch]:
robdd/var.h:
	Conform to the changes in bryant.h. Note that since the code in these
	files won't end up in Mercury program code, they don't need to be
	namespace clean.

runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
	#define GC_I_HIDE_POINTERS before each #include of gc.h (bryant.c
	hides pointers). This impact of this #define is so small that it is
	not measurable.

runtime/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
	Add HIDE_POINTER and REVEAL_POINTER, since defining GC_I_HIDE_POINTERS
	makes these macros from gc.h visible.

runtime/mercury_reg_workarounds.[ch]:
	Add the MR_memset function.

tests/debugger/declarative/if_then_else.{inp,exp}:
tests/debugger/declarative/ite_2.{inp,exp,exp2}:
	Avoid a name conflict with the predicate ite in robdd.m.
2004-12-15 06:58:00 +00:00
Fergus Henderson
0fab56287a Fix a typo which meant that everything was always getting
Estimated hours taken: 0.5
Branches: main

library/Mmakefile:
	Fix a typo which meant that everything was always getting
	compiled with --allow-stubs --no-warn-stubs.

library/sparse_bitset.m:
	Use pragma type_spec declarations for predicate foldr_2/4;
	the previous patch to this file deleted them for function foldr_2/3,
	but the right fix was to move them to the corresponding predicate.
2004-01-15 05:19:16 +00:00
James Goddard
af1a0d9cae Removed a function declaration from the sparse_bitset implementation.
Estimated hours taken: 0.5
Branches: main

Removed a function declaration from the sparse_bitset implementation.

library/sparse_bitset.m:
	Removed the function declaration for sparse_bitset.foldr_2/3 from the
	implementation, since the function is not called by anything and
	causes a compile warning.
2004-01-15 04:41:51 +00:00
Simon Taylor
e18d74a90e Fix performance bugs in library/relation.m which caused
Estimated hours taken: 12
Branches: main

Fix performance bugs in library/relation.m which caused
`mmc --generate-dependencies' to choke on large programs
(e.g. the compiler).

`mmc --generate-dependencies top_level' now takes
about 8 seconds on jupiter, compared to over a minute
before.

library/relation.m:
	Use sparse_bitset for sets of relation_keys.

	Rewrite relation__compose to use the indexing
	in the relation structure, rather than just
	doing a naive nested loop join.

	Clean up and fix a bug in relation__is_dag.

	Rewrite algorithms to avoid using to_sorted_list
	on sparse_bitsets of relation keys; this is not
	a cheap operation as it is with set.sets.
	Use sparse_bitset.fold{l,r} instead where
	possible.

library/sparse_bitset.m:
	Add new functions to_set and from_set,
	which convert between sparse_bitsets
	and set.sets.

	Add predicate versions of foldl and foldr with
	the same modes as the list version.

compiler/modules.m:
	Use sparse_bitset.foldl rather than sparse_bitset.to_sorted_list
	followed by list.map.

profiler/propagate.m:
	relation__dfsrev now takes a sparse_bitset(relation_key),
	not set_bbbtree(relation_key).

library/map.m:
library/tree234.m:
	Type specialize map__det_update for term.var and int.

NEWS:
	Document new predicates and functions.

tests/hard_coded/relation_test.{m,exp}:
	Test relation__is_dag.
2003-12-22 11:21:49 +00:00
Zoltan Somogyi
f007b45df8 Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main

Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.

For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.

The implementation of term size profiling consists of three main parts:

- a source-to-source transform that computes the size of each heap cell
  when it is constructed (and increments it in the rare cases when a free
  argument of an existing heap cell is bound),

- a relatively small change to the code generator that reserves the extra
  slot in new heap cells, and

- extensions to the facilities for creating cells from C code to record
  the extra information we now need.

The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).

The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.

compiler/size_prof.m:
	A new module implementing the source-to-source transform.

compiler/notes/compiler_design.html:
	Mention the new module.

compiler/transform_hlds.m:
	Include size_prof as a submodule of transform_hlds.

compiler/mercury_compile.m:
	If term size profiling is enabled, invoke its source-to-source
	transform.

compiler/hlds_goal.m:
	Extend construction unifications with an optional slot for recording
	the size of the term if the size is a constant, or the identity of the
	variable holding the size, if the size is not constant. This is
	needed by the source-to-source transform.

compiler/quantification.m:
	Treat the variable reference that may be in this slot as a nonlocal
	variable of construction unifications, since the code generator needs
	this.

compiler/compile_target_code.m:
	Handle the new grade components.

compiler/options.m:
	Implement the options that control term size profiling.

doc/user_guide.texi:
	Document the options and grade components that control term size
	profiling, and the term_size mdb command. The documentation is
	commented out for now.

	Modify the wording of the 'u' HLDS dump flag to include other details
	of unifications (e.g. term size info) rather than just unification
	categories.

	Document the new alternatives of the print and browse commands. Since
	they are for developers only, the documentation is commented out.

compiler/handle_options.m:
	Handle the implications of term size profiling grades.

	Add a -D flag value to print HLDS components relevant to HLDS
	transformations.

compiler/modules.m:
	Import the new builtin library module that implements the operations
	needed by term size profiling automatically in term size profiling
	grades.

	Switch the predicate involved to use state var syntax.

compiler/prog_util.m:
	Add predicates and functions that return the sym_names of the modules
	needed by term size profiling.

compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
 	Reserve an extra slot in heap cells and fill them in in unifications
	marked by size_prof.

compiler/builtin_ops.m:
	Add term_size_prof_builtin.term_size_plus as a builtin, with the same
	implementation as int.+.

compiler/make_hlds.m:
	Disable warnings about clauses for builtins while the change to
	builtin_ops is bootstrapped.

compiler/polymorphism.m:
	Export predicates that generate goals to create type_infos and
	type_ctor_infos to add_to_construct.m. Rewrite their documentation
	to make it more detailed.

	Make orders of arguments amenable to the use of state variable syntax.

	Consolidate knowledge of which type categories have builtin unify and
	compare predicates in one place.

	Add code to leave the types of type_ctor_infos alone: instead of
	changing their types to type_info when used as arguments of other
	type_infos, create a new variable of type type_info instead, and
	use an unsafe_cast. This would make the HLDS closer to being type
	correct, but this new code is currently commented out, for two
	reasons. First, common.m is currently not smart enough to figure out
	that if X and Y are equal, then similar unsafe_casts of X and Y
	are also equal, and this causes the compiler do not detect some
	duplicate calls it used to detect. Second, the code generators
	are also not smart enough to know that if Z is an unsafe_cast of X,
	then X and Z do not need separate stack slots, but can use the same
	slot.

compiler/type_util.m:
	Add utility predicates for returning the types of type_infos and
	type_ctor_infos, for use by new code in polymorphism.m.

	Move some utility predicates here from other modules, since they
	are now used by more than one module.

	Rename the type `builtin_type' as `type_category', to better reflect
	what it does. Extend it to put the type_info, type_ctor_info,
	typeclass_info, base_typeclass_info and void types into categories
	of their own: treating these types as if they were a user-defined
	type (which is how they used to be classified) is not always correct.
	Rename the functor polymorphic_type to variable_type, since types
	such as list(T) are polymorphic, but they fall into the user-defined
	category. Rename user_type as user_ctor_type, since list(int) is not
	wholly user-defined but falls into this category. Rename pred_type
	as higher_order_type, since it also encompasses functions.

	Replace code that used to check for a few of the alternatives
	of this type with code that does a full switch on the type,
	to ensure that they are updated if the type definition ever
	changes again.

compiler/pseudo_type_info.m:
	Delete a predicate whose updated implementation is now in type_util.m.

compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
	Still treat type_infos, type_ctor_infos, typeclass_infos and
	base_typeclass_infos as user-defined types, but prepare for when
	they won't be.

compiler/hlds_pred.m:
	Require interface typeinfo liveness when term size profiling is
	enabled.

	Add term_size_profiling_builtin.increase_size as a
	no_type_info_builtin.

compiler/hlds_out.m:
	Print the size annotations on unifications if HLDS dump flags call
	for unification details. (The flag test is in the caller of the
	modified predicate.)

compiler/llds.m:
	Extend incr_hp instructions and data_addr_consts with optional fields
	that allow the code generator to refer to N words past the start of
	a static or dynamic cell. Term size profiling uses this with N=1.

compiler/llds_out.m:
	When allocating memory on the heap, use the macro variants that
	specify an optional offset, and specify the offset when required.

compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
	Minor updates to conform to the changes above.

library/term_size_prof_builtin.m:
	New module containing helper predicates for term size profiling.
	size_prof.m generates call to these predicates.

library/library.m:
	Include the new module in the library.

doc/Mmakefile:
	Do not include the term_size_prof_builtin module in the library
	documentation.

library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
	Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
	that we haven't overlooked any places where offsets may need to be
	specified.

	Fix formatting of foreign_procs.

	Use new macros defined by the runtime system when constructing
	terms (which all happen to be lists) in C code. These new macros
	specify the types of the cell arguments, allowing the implementation
	to figure out the size of the new cell based on the sizes of its
	fields.

library/private_builtin.m:
	Define some constant type_info structures for use by these macros.
	They cannot be defined in the runtime, since they refer to types
	defined in the library (list.list and std_util.univ).

util/mkinit.c:
	Make the addresses of these type_info structures available to the
	runtime.

runtime/mercury_init.h:
	Declare these type_info structures, for use in mkinit-generated
	*_init.c files.

runtime/mercury_wrapper.[ch]:
	Declare and define the variables that hold these addresses, for use
	in the new macros for constructing typed lists.

	Since term size profiling can refer to a memory cell by a pointer
	that is offset by one word, register the extra offsets with the Boehm
	collector if is being used.

	Document the incompatibility of MR_HIGHTAGS and the Boehm collector.

runtime/mercury_tags.h:
	Define new macros for constructing typed lists.

	Provide macros for preserving the old interface presented by this file
	to the extent possible. Uses of the old MR_list_cons macro will
	continue to work in grades without term size profiling. In term
	size profiling grades, their use will get a C compiler error.

	Fix a bug caused by a missing backslash.

runtime/mercury_heap.h:
	Change the basic macros for allocating new heap cells to take
	an optional offset argument. If this is nonzero, the macros
	increment the returned address by the given number of words.
	Term size profiling specifies offset=1, reserving the extra
	word at the start (which is ignored by all components of the
	system except term size profiling) for holding the size of the term.

	Provide macros for preserving the old interface presented by this file
	to the extent possible. Since the old MR_create[123] and MR_list_cons
	macros did not specify type information, they had to be changed
	to take additional arguments. This affects only hand-written C code.

	Call new diagnostic macros that can help debug heap allocations.

	Document why the macros in this files must expand to expressions
	instead of statements, evn though the latter would be preferable
	(e.g. by allowing them to declare and use local variables without
	depending on gcc extensions).

runtime/mercury_debug.[ch]:
	Add diagnostic macros to debug heap allocations, and the functions
	behind them if MR_DEBUG_HEAP_ALLOC is defined.

	Update the debugging routines for hand-allocated cells to print the
	values of the term size slot as well as the other slots in the relevant
	grades.

runtime/mercury_string.h:
	Provide some needed variants of the macro for copying strings.

runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
	Supply type information when constructing terms.

runtime/mercury_deep_copy_body.h:
	Preserve the term size slot when copying terms.

runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
	Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
	that allocate cells also allocate space for the term size slot if
	necessary.

	Reduce code duplication by using a now standard macro for copying
	strings.

runtime/mercury_grade.h:
	Handle the two new grade components.

runtime/mercury_conf_param.h:
	Document the C macros used to control the two new grade components,
	as well as MR_DEBUG_HEAP_ALLOC.

	Detect incompatibilities between high level code and profiling.

runtime/mercury_term_size.[ch]:
	A new module to house a function to find and return term sizes
	stored in heap cells.

runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
	New header files. mercury_proc_id.h contains the (unchanged)
	definition of MR_Proc_Id, while mercury_univ.h contains the
	definitions of the macros for manipulating univs that used to be
	in mercury_type_info.h, updated to use the new macros for allocating
	memory.

	In the absence of these header files, the following circularity
	would ensue:

	mercury_deep_profiling.h includes mercury_stack_layout.h
		- needs definition of MR_Proc_Id
	mercury_stack_layout.h needs mercury_type_info.h
		- needs definition of MR_PseudoTypeInfo
	mercury_type_info.h needs mercury_heap.h
		- needs heap allocation macros for MR_new_univ_on_hp
	mercury_heap.h includes mercury_deep_profiling.h
		- needs MR_current_call_site_dynamic for recording allocations

	Breaking the circular dependency in two places, not just one, is to
	minimize similar problems in the future.

runtime/mercury_stack_layout.h:
	Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.

runtime/mercury_type_info.h:
	Delete the macros for manipulating univs, which are now in
	mercury_univ.h.

runtime/Mmakefile:
	Mention the new files.

runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
	Include the new files at appropriate points.

runtime/mercury.c:
	Change the names of the functions that create heap cells for
	hand-written code, since the interface to hand-written code has
	changed to include type information.

runtime/mercury_tabling.h:
	Delete some unused macros.

runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
	Use the new macros supplying type information when constructing lists.

scripts/canonical_grade_options.sh-subr:
	Fix an undefined sh variable bug that could cause error messages
	to come out without identifying the program they were from.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
	Handle the new grade components and the options controlling them.

trace/mercury_trace_internal.c:
	Implement the mdb command "term_size <varspec>", which is like
	"print <varspec>", but prints the size of a term instead of its value.
	In non-term-size-profiling grades, it prints an error message.

	Replace the "proc_body" command with optional arguments to the "print"
	and "browse" commands.

doc/user_guide.tex:
	Add documentation of the term_size mdb command. Since the command is
	for implementors only, and works only in grades that are not yet ready
	for public consumption, the documentation is commented out.

	Add documentation of the new arguments of the print and browse mdb
	commands. Since they are for implementors only, the documentation
	is commented out.

trace/mercury_trace_vars.[ch]:
	Add the functions needed to implement the term_size command, and
	factor out the code common to the "size" and "print"/"browse" commands.

	Decide whether to print the name of a variable before invoking the
	supplied print or browse predicate on it based on a flag design for
	this purpose, instead of overloading the meaning of the output FILE *
	variable. This arrangement is much clearer.

trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
	Supply type information when constructing terms.

browser/program_representation.m:
	Since the new library module term_size_prof_builtin never generates
	any events, mark it as such, so that the declarative debugger doesn't
	expect it to generate any.

	Do the same for the deep profiling builtin module.

tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
	Two new test cases, each testing one of the new grades.

tests/debugger/Mmakefile:
	Enable the two new test cases in their grades.

	Disable the tests sensitive to stack frame sizes in term size profiling
	grades.

tests/debugger/completion.exp:
	Add the new "term_size" mdb command to the list of command completions,
	and delete "proc_body".

tests/debugger/declarative/dependency.{inp,exp}:
	Use "print proc_body" instead of "proc_body".

tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
	Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
	that allocate cells also allocate space for the term size slot if
	necessary.

tests/valid/Mmakefile:
	Disable the IL tests in term size profiling grades, since the term size
	profiling primitives haven't been (and probably won't be) implemented
	for the MLDS backends, and handle_options causes a compiler abort
	for grades that combine term size profiling and any one of IL, Java
	and high level C.
2003-10-20 07:29:59 +00:00
Peter Ross
1fd2a43d9f Allow the library to compile in the grade il (high level data).
Estimated hours taken: 120
Branches: main

Allow the library to compile in the grade il (high level data).

compiler/ml_util.m:
	Add more types which need to be represented using the low level
	representation because of how they are handled in the library.

compiler/mlds_to_il.m:
	Remove an XXX which is no longer necessary.
	Add the heap_pointer type to the list of types whose RTTI is defined
	by hand.

library/exception.m:
	Move the definition of Exception from the runtime to the local module.
	This is needed for when univ/0 is no longer represented as a low level
	type.

runtime/mercury_mcpp.cpp:
	Remove the implementation of Exception that is now in exception.m.

library/Mmakefile:
	The lowlevel Exception type is now defined in the library not the
	runtime, so add rules to ensure that the foreign code is built in
	the correct order.

library/io.m:
	Reimplement io__stream as a foreign_type.  This makes the code more
	type safe and avoids problems with the different representation of
	the io__stream type when using high and low level data.
	Change io__command_line_arguments so that it throws an exception
	when we use high level data, as I am yet to work out how to access
	high level lists.

library/rtti_implementation.m:
	Add a comment that get_subterm doesn't work with high level data.
	Fix some bugs with the default versions of type_ctor_compare_pred and
	type_ctor_unify_pred.

library/sparse_bitset.m:
	Remove the foreign_proc implementation of make_bitset_elem as it
	will not work with both data representations and their is a Mercury
	implementation.

library/string.m:
	Remove the foreign_proc implementation of all the predicates which
	manipulate lists as they all have a Mercury implementation, as I am yet
	to work out how to access high level lists.
	Add a Mercury implementation for string__join_list.

runtime/mercury_mcpp.h:
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
	Define and use typedefs where appropiate for type_info/0, type_info/1,
	comparison_result/0 and univ/0, as there representation may change in
	the future between using high level and low level data.
2002-07-23 08:26:30 +00:00
Peter Ross
5f118f4a81 The tag bootstrap_20020613_intermod can be used to get a compiler which
Estimated hours taken: 20
Branches: main

The tag bootstrap_20020613_intermod can be used to get a compiler which
compiles this change.

configure.in:
	Test that the option --bug-intermod-2002-06-13 exists.  This signifies
	that the a bug in intermodule optimization for predicates which are
	defined as both mercury and foreign code clauses.

library/array.m:
library/benchmarking.m:
library/builtin.m:
library/char.m:
library/construct.m:
library/deconstruct.m:
library/float.m:
library/gc.m:
library/int.m:
library/io.m:
library/library.m:
library/math.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/sparse_bitset.m:
library/std_util.m:
library/store.m:
library/table_builtin.m:
library/time.m:
library/type_desc.m:
	Define a mercury version of every pragma foreign_proc.
	Remove any foreign_procs which are not implemented yet.
2002-06-14 10:18:55 +00:00
Simon Taylor
a529a380e2 Back out Pete's unreviewed change from yesterday.
Estimated hours taken: 0.2
Branches: main

library/*.m
	Back out Pete's unreviewed change from yesterday.
	It doesn't compile without a recent bug fix, but no
	CVS tag was added.
2002-06-12 06:46:46 +00:00
Peter Ross
a86cd4342c Define a mercury version of every pragma foreign_proc, and remove any
Estimated hours taken: 16
Branches: main

Define a mercury version of every pragma foreign_proc, and remove any
foreign_procs which just throw an exception that the code is not implemented.

library/array.m:
library/benchmarking.m:
library/builtin.m:
library/char.m:
library/construct.m:
library/deconstruct.m:
library/exception.m:
library/float.m:
library/gc.m:
library/int.m:
library/io.m:
library/library.m:
library/math.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/sparse_bitset.m:
library/std_util.m:
library/store.m:
library/string.m:
library/table_builtin.m:
library/time.m:
library/type_desc.m:
	Define a mercury version of every pragma foreign_proc, and remove any
	foreign_procs which just throw an exception that the code is not
	implemented.
2002-06-11 11:03:19 +00:00
Tyson Dowd
cdaafbf4b0 Soon foreign_proc will be impure by default unless given a promise_pure
Estimated hours taken: 8
Branches: main

Soon foreign_proc will be impure by default unless given a promise_pure
or promise_semipure attribute.  The syntax has been accepted for some
time, we now add the necessary declarations.

browser/dl.m:
compiler/timestamp.m:
library/*.m:
tests/hard_coded/unused_float_box_test.m:
	Add promise_pure and promise_semipure declarations for foreign_procs.
2002-01-20 07:32:32 +00:00
Simon Taylor
5544aed7ff Change the list constructor from ./2' to [|]/2'. `./2' will
Estimated hours taken: 3
Branches: main

Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.

library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
	Change all references to `./2' to use `[|]/2' instead.

compiler/typecheck.m:
	Handle `./2' as a special case in `report_error_undef_cons'.

	Warn about module list not being imported if `[|]/2' is undefined.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Add name conversions for `[|]' (f_cons) and `[]' (f_nil).

NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
	Document the changes.

tests/debugger/{,declarative}/*.exp*:
	Update test case results. For some tests the output changed
	because they output lists in the non-pretty format. For others,
	the output changed because the alphabetical ordering of the
	constructors of type `list/1' changed, so the numbering of
	the switch branches in the goal paths changed.
2001-09-25 09:37:12 +00:00
Tyson Dowd
404e633644 The MC++ interface for functions is buggy.
Estimated hours taken: 10
Branches: main

The MC++ interface for functions is buggy.
This change generates errors in most cases where a function is
implemented in MC++, and removes all the occurances of such functions
from the library.

compiler/mlds_to_il.m:
        Abort if a function is implemented in MC++.  We don't catch the
        case of functions that return int, as it is difficult to be sure
        this isn't just a semidet predicate (which works and is used).
        However this catches a lot of cases where we were silently
        generating bad code so it is better than nothing.

library/Mmakefile:
	Add flags to control debugging (commented out for the moment).
	Move the .NET flags together.

library/builtin.m:
library/float.m:
library/io.m:
library/math.m:
library/sparse_bitset.m:
library/std_util.m:
library/string.m:
	Implement functions in C#, as functions don't work when a
	foreign_proc is MC++.
	This fixes several latent bugs in the library.

runtime/Mmakefile:
	Add support for debugging (commented out for the moment).

runtime/mercury_mcpp.cpp:
	Add code to manipulate low level data structures (so we can do
	this from C# as well as MC++).
2001-08-14 10:19:02 +00:00
Tyson Dowd
e9d95ada12 Change calls to mercury::runtime::convert to System::Covert.
Estimated hours taken: 2
Branches: main

library/builtin.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
	Change calls to mercury::runtime::convert to System::Covert.
	Use __box instead of mercury::runtime::Convert::ToObject

runtime/Mmakefile:
	Add a rule to remove the DOTNET_DLLS for clean_local.

runtime/mercury_il.il:
	Remove ConvertImpl class, use unbox and ldobj instead of ToInt32.

runtime/mercury_mcpp.cpp:
	Remove Convert class.

runtime/mercury_mcpp.h:
	Use __box instead of mercury::runtime::Convert::ToObject

scripts/Mmake.rules:
	Put the local include directory before the installed one when
	compiling with MC++.
	Also fix the rule for .cpp.dll to be the same as the subdir
	rule.
2001-07-31 10:08:03 +00:00
David Jeffery
19ceeaf30f Merge the changes from the HAL branch onto the main branch.
Estimated hours taken: 40
                       (to do this merge... 100s of hours on the HAL branch
		        itself by myself and Warwick Harvey though).

Merge the changes from the HAL branch onto the main branch. With the recent
changes made to the HAL implementation, this means adding just one grade,
`.rt' or --reserve-tag, which reserves one tag (zero) in each type for
use by HAL's Herbrand constraint solver. This disables no-tag types and
enumerations.

This grade will now bootstrap, and passes all tests, except for a few failing
cases in the debugger and tabling directories.

compiler/options.m:
compiler/handle_options.m:
	Add the `.rt' or --reserve-tag grade option.
runtime/mercury_conf_param.h:
	Document the macro MR_RESERVE_TAG
doc/user_guide.texi:
	Document the `.rt' grade.

compiler/make_hlds.m:
	Don't record any types as no-tag types if we are in a .rt grade.
compiler/make_tags.m:
compiler/type_ctor_info.m:
	Allocate tags starting from `1' in .rt grades.
compiler/rtti_out.m:
	In .rt grades, output a dummy ptag definition for tag `0'.
compiler/type_util.m:
	Add predicates `type_util__constructors_are_dummy_argument_type' and
	`type_constructors_are_type_info' for use when allocating tags to
	ensure that type infos and dummy types (io__state/0 and store__store/1)
	are still treated as no-tag types in .rt grades.

library/sparse_bitset.m:
	When allocating a sparse bitset element, use tag `1' if we are in a
	.rt grade.

runtime/mercury_tags.h:
	Define a macro `MR_UNIV_TAG' which is `1' is we in a .rt grade and
	`0' otherwise. (Now that univ is a user defined type, it is a also
	assigned a `var' tag).
	Also make the definitions of MR_RAW_TAG_NIL and MR_RAW_TAG_CONS take the
	.rt grade into account.
runtime/mercury_type_info.h:
	Define `MR_unravel_univ' and
	`MR_initialise_univ' for taking apart and putting together univs.

	Add a new secondary tag alternative: MR_SECTAG_VARIABLE, used to
	represent Herbrand variables.

library/std_util.m:
	Use MR_UNIV_TAG, MR_unravel_univ and MR_initialise_univ when
	manipulating univs.

	Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.

library/std_util.m:
	Add a constant for MR_SECTAG_VARIABLE in the MC++ back end.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
	Process the new grade.

scripts/mmake.in:
	Add an option `--include-makefile', which includes a Makefile given
	as a command line argument into the Makefile generated by mmake.
	This is used to implement `halmake', a make program for HAL which
	just passes a bunch of extra rules and variable definitions onto
	mmake.

tests/debugger/existential_type_classes.m:
tests/hard_coded/existential_types_test.m:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
	Use MR_UNIV_TAG.

TODO:
	- The declarative debugger falls over in .rt grades. This is possibly
	  because compiler/static_term.m assumes that the generated code uses
	  the same data representation as the compiler itself. This should be
	  fixed, although it is not critical; the declarative debugger won't
	  work with trailing as is, and the .rt grade is only ever used in
	  conjunction with trailing (.tr) at this stage.
2001-03-18 23:10:17 +00:00
Tyson Dowd
fec4b7733b Check for foreign_proc, as we require it to work if we wish to
Estimated hours taken: 2
Branches: main release

configure.in:
	Check for foreign_proc, as we require it to work if we wish to
	bootstrap.

library/*.m:
	Turn foreign_code/3+ into foreign_proc by applying the
	following subsitutions:

	First turn all foreign_code into foreign_proc:
		s/foreign_code\(/foreign_proc\(/g

	Then turn back any foreign_proc with a string as its second
	argument.
		s/foreign_proc(\("[A-Za-z0-9+]*",[ \t\n]*")/foreign_code$1/g
2001-03-15 07:42:27 +00:00
Fergus Henderson
b6708a0801 Various fixes for the GCC back-end.
Estimated hours taken: 4

Various fixes for the GCC back-end.

library/array.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
library/table_builtin.m:
library/time.m:
	Add #includes for header files needed by these modules.

compiler/modules.m:
	Add the extra object files needed for the GCC back-end
	(and for fact tables) to the .pic_os list as well as to
	the .os list.

compiler/gcc.m:
	Delete the second copy of a duplicated paragraph in the comments.

compiler/mlds_to_gcc.m:
	Fix a bug that showed up after my recent change which added
	an MLDS->MLDS optimization that converted assignments into
	initializers.  The bug was that the code here didn't handle
	the case when an initializer for a local variable refers to
	another local variable declared earlier in the same block.
2001-02-26 01:34:09 +00:00
Simon Taylor
80eb4c2d84 Change the copyright notices so that these files
Estimated hours taken: 0.1

library/enum.m:
library/sparse_bitset.m:
	Change the copyright notices so that these files
	are LGPL'd rather than GPL'd.
2001-02-11 11:45:13 +00:00
Tyson Dowd
53f2dbc1b4 First implementation of the standard library in managed C++.
Estimated hours taken: 200

First implementation of the standard library in managed C++.

configure.in:
	Autodetect the .NET SDK, and set MS_DOTNET_SDK_DIR based on it.
	Find the IL assembler, and set ILASM.

compiler/inlining.m:
	Turn off inlining of pragma_foreign_code with the IL backend.

compiler/mlds_to_c.m:
	Add a comment questioning the foreign language interfacing still to be
        done in this backend, and remove the "inline target code" from
        this list (since it has been completed).

compiler/mlds_to_il.m:
	Generate code for :- external.  We generate a forwarding
	function to the expected implementation in
	<modulename>__c_code.cpp

	Rename all the classes to use MixedCase, and to put them in the
	mercury.runtime namespace.

compiler/mlds_to_ilasm.m:
	Don't use the System or mercury namespaces by default.
	Change the names of the runtime cpp files to mercury_mcpp.dll
	and mercury_il.dll.
	Use c_util to output unops and binops.

doc/user_guide.texi:
	Document MS_CL_NOASM, MS_CLFLAGS and EXTRA_MS_CLFLAGS.

library/*.m:
	Rename pragma c_code as pragma foreign_code("C", ...).
	Add pragma foreign_code for MC++.
	Only a fraction of the predicates are implemented, everything
	else simply throws and exception when called.
	Implementations of predicates marked with :- external are
	provided as pragma foreign_code, but are commented out.

library/Mmakefile:
runtime/Mmakefile:
	Add targets for building the dlls for the library.

runtime/mercury_mcpp.cpp:
runtime/mercury_mcpp.h:
	Implementation of the runtime.

runtime/mercury_il.il:
	This file mainly implements things that can't be written in
	managed C++ (e.g. function pointers).

scripts/Mmake.rules:
scripts/Mmake.vars.in:
        Add rules for generating .dlls and .exes from .ils and .cpps.
2001-01-01 04:04:05 +00:00
Zoltan Somogyi
d4920def3b Add missing MR_ prefixes.
Estimated hours taken: 0.5

library/*.m:
	Add missing MR_ prefixes.
2000-11-28 05:52:00 +00:00
Simon Taylor
dedcf29a30 Make the function versions of predicates appear in the
Estimated hours taken: 2.5

library/*.m
	Make the function versions of predicates appear in the
	Mercury Library Reference Manual.
2000-11-12 08:51:39 +00:00
Simon Taylor
1bc37d4307 Use bitsets to store the sets of variables in quantification.
Estimated hours taken: 14

Use bitsets to store the sets of variables in quantification.
This change reduces the time taken by `mmc -C make_hlds' by 7-8%.

library/sparse_bitset.m:
	An ADT for storing sets of integers.

library/set.m:
library/set_ordlist.m:
library/set_unordlist.m:
library/set_bbbtree.m:
library/bintree_set.m:
	Add a predicate contains/2, which is like member/2 but
	only has the `contains(in, in)' mode. For some set representations
	it is difficult to code a predicate which does both the
	`member(out, in)' and `member(in, in)' modes efficiently.

library/enum.m:
	Contains a typeclass `enum/1' describing types which
	can be converted to and from integers.

library/term.m:
	Add an instance declaration for `enum(var(T))'.

library/char.m:
	Add an instance declaration for `enum(character)'.

library/bool.m:
	Add an instance declaration for `enum(bool)'.

library/int.m:
	Add an instance declaration for `enum(int)'.

	Add a function for finding the largest multiple of
	bits_per_int which is less than a given number, for
	use by sparse_bitset.m.

compiler/quantification.m:
	Use `sparse_bitset(prog_var)' rather than `set(prog_var)'
	for all the sets of variables used while quantifying a goal,
	but arrange things so that it is simple use `set(prog_var)'
	when debugging.

library/library.m:
compiler/modules.m:
	Add `enum' and `sparse_bitset' to the list of library modules.

NEWS:
	Document the new modules.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_sparse_bitset.m:
tests/hard_coded/bitset_tester.m:
	Add some tests for predicates and functions in
	sparse_bitset.m which are not used in quantification.m.
	Test storing negative integers in sparse_bitsets.
2000-11-12 05:51:29 +00:00