Commit Graph

4401 Commits

Author SHA1 Message Date
Fergus Henderson
a76b0eeb42 Fix a bug introduced by petdr's Dec 2 bug fix which introduced wrapper
Estimated hours taken: 3
Branches: main

Fix a bug introduced by petdr's Dec 2 bug fix which introduced wrapper
functions for unify and compare procs to unbox their arguments,
which caused the tests/valid/unify_typeinfo_bug test case to fail.

The bug was that with --no-special-preds, we were generating invalid
MLDS code, because the code to introduce wrapper functions assumed
that the function being wrapped was defined in the same module,
but with --no-special-preds, the procedure being wrapped is always
private_builtin.unused/0.

In the case of a procedure with arity zero, the wrapper is not needed
(it's just a tail call), so the simplest fix was to just optimize
that case.

compiler/rtti_to_mlds.m:
	If the procedure being wrapped has arity zero, don't bother to
	generate a wrapper function, since it is not needed.
2003-12-11 02:55:54 +00:00
Julien Fischer
255ac0898c s/fatal_error()/MR_fatal_error()/
Estimated hours taken: 0.1
Branches: main

compiler/notes/coding_standards.html:
	s/fatal_error()/MR_fatal_error()/
2003-12-10 07:09:34 +00:00
Fergus Henderson
b5644bb1ee Ensure that libmer_browser.so and libmer_trace.so link with
Estimated hours taken: 0.25
Branches: main

browser/Mercury.options:
trace/Mmakefile:
	Ensure that libmer_browser.so and libmer_trace.so link with
	the mer_mdbcomp library.  This is needed after my recent fix
	to ensure that the mer_mdbcomp library is referenced from the
	mer_browser library, rather than being included in it.

compiler/Mmakefile:
	Add a missing dependency on libmer_mdbcomp.$A.
2003-12-10 07:04:24 +00:00
Fergus Henderson
8020bfed3c Some Mmakefile tweaks for grade java.
Estimated hours taken: 0.5
Branches: main

Some Mmakefile tweaks for grade java.

boehm_gc/Mmakefile:
browser/Mmakefile:
trace/Mmakefile:
	Don't try to build the boehm_gc, browser, or trace directories
	in grade java.

compiler/Mmakefile:
profiler/Mmakefile:
deep_profiler/Mmakefile:
	Avoid dependencies on *.$A files in grade java.
2003-12-09 14:57:57 +00:00
Simon Taylor
ddcdf3e08f Temporarily disable the equiv_type_hlds pass -- it
Estimated hours taken: 0.1
Branches: main

compiler/mercury_compile.m:
	Temporarily disable the equiv_type_hlds pass -- it
	uses too much memory.
2003-12-09 12:58:29 +00:00
Julien Fischer
112e8b9d00 This just updates some syntax; it doesn't change anything else.
Estimated hours taken: 0.5
Branches: main

This just updates some syntax; it doesn't change anything else.

compiler/lp.m:
	Replace old-style lambdas with new-style ones.
2003-12-09 04:19:18 +00:00
Julien Fischer
caa865fd92 Fix a bug in the termination analyser where setting the termination
Estimated hours taken: 2
Branches: main

Fix a bug in the termination analyser where setting the termination
norm to `num-data-elems' causes the an internal abort when analysing
code involving existential typeclass constraints.

The bug is caused by the length of the list of arguments of a
functor differing from the length of the list in the weight table that
tells the compiler which arguments to count when computing the size
of that functor.

The length mismatch is caused by typeinfo related variables that
are introduced by the compiler for existentially typed terms.  The
termination analyser includes them but the weight table does not.
I committed a diff a few months ago that partially fixed this problem,
but programs that use existential typeclass constraints break that fix
as well.

The diff implements the easiest solution to all this which is to
have the termination analyser remove all the typeinfo related arguments
of a term before calling term_norm.functor_norm/9.

This diff also fixes a few things in the tests/term directory, namely
making sure that we actually run the tests, updating the module qualifier
in a few .trans_opt_exp files and updating some comments.

compiler/term_norm.m:
	Ignore any typeinfo related arguments that a term has when
	building the weight table.

compiler/term_traversal.m:
	Remove any typeinfo related arguments from the lists of
	arguments and modes before computing the size of a term.

tests/term/Mercury.options:
tests/term/existential_error3.m:
tests/term/existential_error3.trans_opt_exp:
	Add a regression test for this bug.

tests/term/Mmakefile:
	Make sure the $(TESTS) and $(PROGS) variables are fully defined
	before Mmake.common is included, otherwise the tests will not run.
	Add the new regression test.

tests/term/existential_error1.m:
tests/term/existential_error2.m:
	The code that caused these bugs has been moved from term_util.m
	to term_norm.m.  Update the references to the old filename.

tests/term/*.trans_opt_exp:
	Replaces instances of `:' as the module qualifier with `.'.
	Quite a few tests cases were failing because the .trans_opt
	files use the latter.
2003-12-08 03:42:16 +00:00
Fergus Henderson
3a086506c0 Add some comments.
Estimated hours taken: 0.5
Branches: main

compiler/mlds.m:
	Add some comments.
2003-12-05 04:19:30 +00:00
Fergus Henderson
b3eaef4f2b Fix a bug where we were incorrectly pruning nondet goals with a non-local
Estimated hours taken: 1
Branches: main

Fix a bug where we were incorrectly pruning nondet goals with a non-local
variable of inst "any" whose type contained a solver type in one of
its fields.

compiler/inst_match.m:
	Fix a bug: when memoizing the results of previous calls to
	inst_matches_*, include the maybe(type) argument in the key
	of the memo table, since that argument can effect the result.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/solver_type_bug.m:
	Add a regression test for the above-mentioned bug.
2003-12-05 04:18:32 +00:00
Peter Ross
a29e58e12f Do constant propogation for string__append.
Estimated hours taken: 1
Branches: main

compiler/const_prop.m:
	Do constant propogation for string__append.
2003-12-04 21:34:59 +00:00
Peter Ross
d40b70fec3 Fix a bug where the compiler was treating pseudo_imported external
Estimated hours taken: 6
Branches: main

Fix a bug where the compiler was treating pseudo_imported external
definitions incorrectly.

compiler/hlds_pred.m:
	Change the defintion of external in import_status so that it
	records the original import status, not just whether it is
	exported or not.

compiler/ml_code_gen.m:
	Don't generate any mlds representation for special predicates
	whose definition is external and pseudo_imported.

compiler/assertion.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
	Adapt to the changes of the definition of status.

tests/hard_coded/Mmakefile:
tests/hard_coded/external_unification_pred.exp:
tests/hard_coded/external_unification_pred.m:
	Test case.
2003-12-03 16:12:10 +00:00
Peter Ross
c4574c6db8 External references are no longer associated with the MC++
Estimated hours taken: 0.25
Branches: main

compiler/mlds_to_il.m:
	External references are no longer associated with the MC++
	instead they are associated with the C# file, and it is
	still hacky!
2003-12-03 08:22:24 +00:00
Peter Ross
2e0f893d22 Don't place predicates whose definition is a foreign_proc into the
Estimated hours taken: 2
Branches: main

Don't place predicates whose definition is a foreign_proc into the
.opt file, if the foreign_proc can't be embedded directly in the
generated code as the gain is minimal for the extra complexity
in the generated code.

compiler/intermod.m:
	For the il backend, don't export MC++ or C# foreign_procs.
2003-12-02 20:49:17 +00:00
Fergus Henderson
425287b6e0 More work on the Java back-end. The standard library now compiles
Estimated hours taken: 6
Branches: main

More work on the Java back-end.  The standard library now compiles
in grade `java', and hello world (the version using io__write_string,
and linked against the standard library in library/*.m, not the
hand-coded one in java/library/*.java) now works!

compiler/make_hlds.m:
	Ignore `pragma type_spec' declarations for the Java back-end.
	This works around a problem where javac was failing to compile
	some of our generated code due to it overflowing limits on
	file name length for the names of the .class files for some
	nested classes.

compiler/mlds_to_java.m:
	Add some comments.  Add myself to the "main authors" list.

library/string.m:
	Provide Java definitions of string__first_char and
	string__unsafe_index.  (These are needed for string.append,
	which is used by private_builtin.sorry.)

library/io.m:
	Provide Java definitions of io__write_{string,int,char,float}/3.

java/runtime/TypeCtorInfo_Struct.java:
	Fix a cut-and-paste error.

java/runtime/TypeInfo_Struct.java:
	Improve the implementation of the TypeInfo_Struct(Object)
	constructor so that it doesn't throw exceptions during
	the initialization of the standard library.

java/runtime/FA_TypeInfo_Struct1.java:
	Make this type inherit from TypeInfo_Struct.
2003-12-02 10:02:07 +00:00
Fergus Henderson
273a8606c8 Add an XXX comment about this module not handling exceptions
Estimated hours taken: 0.5.
Branches: main

compiler/accumulator.m:
	Add an XXX comment about this module not handling exceptions
	and non-termination correctly.
2003-12-02 09:16:50 +00:00
Peter Ross
b0dccf76c4 The comparison and unification function pointers stored in the
Estimated hours taken: 8
Branches: main

The comparison and unification function pointers stored in the
type_ctor_info must be pointers to functions where all the arguments
are boxed.  This wasn't occuring on the IL backend for types which
are value types.

il_compiler/compiler/rtti_to_mlds.m:
	Call ml_gen_closure_wrapper to construct a version of the
	comparison and unification functions where the arguments are
	boxed.  The wrapper function simply unboxes the arguments and
	calls the actual special pred.

il_compiler/compiler/ml_closure_gen.m:
	Adapt ml_gen_closure_wrapper so that it can generate a wrapper
	function for special preds.

tests/hard_coded/Mmakefile:
tests/hard_coded/equality_pred_which_requires_boxing.exp:
tests/hard_coded/equality_pred_which_requires_boxing.m:
	Add a test case for this bug.
2003-12-01 22:31:36 +00:00
Simon Taylor
82c6cdb55e Make definitions of abstract types available when generating
Estimated hours taken: 100
Branches: main

Make definitions of abstract types available when generating
code for importing modules.  This is necessary for the .NET
back-end, and for `:- pragma export' on the C back-end.

compiler/prog_data.m:
compiler/modules.m:
compiler/make.dependencies.m:
compiler/recompilation.version.m:
	Handle implementation sections in interface files.

	There is a new pseudo-declaration `abstract_imported'
	which is applied to items from the implementation
	section of an interface file.  `abstract_imported'
	items may not be used in the error checking passes
	for the curent module.

compiler/equiv_type_hlds.m:
compiler/notes/compiler_design.html:
	New file.

	Go over the HLDS expanding all types fully after
	semantic checking has been run.

compiler/mercury_compile.m:
	Add the new pass.

	Don't write the `.opt' file if there are any errors.

compiler/instmap.m:
	Add a predicate instmap_delta_map_foldl to apply
	a procedure to all insts in an instmap.

compiler/equiv_type.m:
	Export predicates for use by equiv_type_hlds.m

	Reorder arguments so state variables and higher-order
	programming can be used.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
	Handle `:- pragma foreign_type' as a form of type
	declaration rather than a pragma.

compiler/hlds_data.m:
compiler/*.m:
	Add a field to the type_info_cell_constructor cons_id
	to identify the type_ctor, which is needed by
	equiv_type_hlds.m.

compiler/module_qual.m:
	Donn't allow items from the implementation section of
	interface files to match items in the current module.

compiler/*.m:
tests/*/*.m:
	Add missing imports which only became apparent with
	the bug fixes above.

	Remove unnecessary imports which only became apparent with
	the bug fixes above.

tests/hard_coded/Mmakefile:
tests/hard_coded/export_test2.{m,exp}:
	Test case.

tests/invalid/Mmakefile:
tests/invalid/missing_interface_import2.{m,err_exp}:
	Test case.
2003-12-01 15:56:15 +00:00
Fergus Henderson
b50430e8b9 Bug fixes for the Java back-end.
Estimated hours taken: 2
Branches: main

Bug fixes for the Java back-end.
The standard library now almost compiles in grade java.

compiler/mlds_to_java.m:
	Output Java foreign declarations before any other code,
	to fix a problem with references to the TYPE_CTOR_REP
	constants in library/private_builtin.m.

	Fix some bugs where we were not being consistent about mangling
	the module name when naming the classes used to simulate taking
	procedure addresses.  This bug broke Java compilation of library/char.m.

	Fix some bugs where the compiler was getting confused about
	which types map to array types in Java.

	For MLDS casts that cast to type_info or pseudo_type_info,
	generate Java constructor calls, not Java casts.
	This fixes type errors in the generated Java code.

	Simplify the code for hand_defined_type.

compiler/rtti.m:
	Fix a bug in tc_rtti_name_java_type: map typeclass_infos to
	the Java type "java.lang.Object[]", not "java.lang.Integer[]".
	The latter didn't work because the elements which hold the method
	addresses do not have type java.lang.Integer.

java/runtime/DuExistInfo.java:
java/runtime/NotagFunctorDesc.java:
	Define constructors for these types.

java/runtime/TypeInfo_Struct.java:
	Define some additional constructors for this type.

library/builtin.m:
	Provide Java stub definitions of
	- classes for the types func/0 and c_pointer/0;
	- unify/compare preds for func, c_pointer, tuple, and void;

	Define Java definitions for the additional modes of compare/3
	(they just call the first mode).

library/exception.m:
	Define Java versions of make_io_state and consume_io_state,
	and Java stubs for throw_impl and catch_impl.

	Change try_all so that it calls catch_impl, like try does,
	rather than calling builtin_catch directly.  This is needed
	since the .NET and Java back-ends only define catch_impl,
	not builtin_catch.

library/io.m:
	Provide Java `pragma foreign_type' declarations for the types
	array.array(T) and io.system_error.  This is needed to avoid
	compilation errors when building in grade `java'.

library/private_builtin.m:
	Delete the Java definition of the type_info for type_info/1,
	because that is generated automatically now,
	after petdr's recent bug fix.

	Provide Java stubs definitions of the unify/compare preds
	for ref/1, heap_pointer/0, type_ctor_info, type_info,
	base_typeclass_info, and typeclass_info.

	Provide Java definition of dummy_var.

library/type_desc.m:
	Provide Java stub definitions of
	- classes for type_desc/0 and type_ctor_desc/0
	- unify/compare preds for those types

library/store.m:
	Define unification and comparison predicates for the store(S)
	type.  This is needed because the automatically generated ones
	might not have the right semantics, but also because the Java
	back-end generates some invalid code for the automatically
	generated unification and compare predicates (the generated
	code has some invalid references to "dummy_var").
2003-12-01 13:16:53 +00:00
Fergus Henderson
12418653ee Bug fixes for the Java back-end.
Estimated hours taken: 12
Branches: main

Bug fixes for the Java back-end.

compiler/mlds_to_java.m:
	Fix a bug where we were outputting an incorrect type for nested
	structure initializers
	Fix a bug where we were outputting invalid syntax for some
	array initializers.
	Fix a bug where the code output for string comparisons was not properly
	parenthesized.

compiler/mlds.m:
	Add a new argument to init_struct that specifies the type of
	the structure being initialized.  This is needed to handled
	nested structure initializers for the Java back-end.

compiler/rtti.m:
	Add new alternatives to ctor_rtti_name for all the types which
	are used as nested components of RTTI structures.  This is
	needed in order to have appropriate RTTI types to use in
	rtti_to_mlds.m for the new field of init_struct.

compiler/rtti_to_mlds.m:
	Substantial changes to fill in the new field of init_struct
	in all the generated initializers.

compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
	Minor changes to handle the new argument to init_struct.

compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
	Minor changes to handle the new alternatives for ctor_rtti_name.

compiler/mlds_to_gcc.m:
	Fix a bug where it was generating a structure type, rather
	than an array thereof, for res_name_ordered_table.
2003-12-01 06:53:29 +00:00
Zoltan Somogyi
6b432d0448 Split a predicate with a 200-line definition into three.
Estimated hours taken: 1
Branches: main

compiler/polymorphism.m:
	Split a predicate with a 200-line definition into three.

	Fix some formatting issues.

	There is no change in algorithms.
2003-11-30 23:57:12 +00:00
Peter Ross
cea3c7294e Fix a bug where the type_ctor_info for type_info/1 and
Estimated hours taken: 2
Branches: main

Fix a bug where the type_ctor_info for type_info/1 and
type_ctor_info/1 weren't being generated.

compiler/type_ctor_info.m:
	Also have to generate a type_ctor_info for those types which
	have hand defined rtti due to having a fake type body.

compiler/type_util.m:
	Rename builtin_type_ctors_with_no_type_defn as
	builtin_type_ctors_with_no_hlds_type_defn as the former name
	was misleading, and remove an incorrect comment about which
	type_ctors this function returns.

compiler/make_hlds.m:
compiler/typecheck.m:
	Changes due to the renaming of
	builtin_type_ctors_with_no_hlds_type_defn.
2003-11-28 20:40:13 +00:00
Fergus Henderson
04024991b4 A bug fix for the Java back-end.
Estimated hours taken: 1
Branches: main

A bug fix for the Java back-end.

compiler/ml_type_gen.m:
	Fix a bug where we were generating invalid Java code for constructors.
	For a constructor Foo with an argument of type Bar, we were generating

		public Foo(Bar F1) {
			((modulename.Foo)this).F1 =
				modulename.Foo.F1; // XXX
		}

        instead of

		public Foo(Bar F1) {
			((modulename.typename)this).F1 = F1;
		}

	The fix was to change ml_type_gen.m so that for the Java back-end,
	it generates MLDS corresponding to

		public Foo(Bar F1) {
			((modulename.typename)this).F1 = modulename.F1;
		}

	and then the "modulename." qualifier on F1 gets removed by the
	existing code in mlds_to_java.m.
2003-11-28 08:51:32 +00:00
Fergus Henderson
46f73170e9 Disable the dup_elim optimization when accurate GC is enabled,
Estimated hours taken: 12
Branches: main

compiler/handle_options.m:
	Disable the dup_elim optimization when accurate GC is enabled,
	because it does not correctly preserve the accurate GC layout
	information.
2003-11-28 08:40:01 +00:00
Simon Taylor
5df1cedc11 s/goal_cannot_loop/goal_cannot_loop_or_throw/ throughout
Estimated hours taken: 0.5
Branches: main

compiler/constraint.m:
compiler/deforest.m:
compiler/goal_util.m:
compiler/simplify.m:
compiler/rl.m:
	s/goal_cannot_loop/goal_cannot_loop_or_throw/ throughout
	the optimization passes.  This is needed to avoid optimizing
	away calls to error/1 now that it is marked as terminating.

compiler/pd_util.m:
	Remove a duplicate of goal_util__reordering_maintains_termination.
2003-11-28 02:23:07 +00:00
Peter Ross
368eaf2d11 Address review comments of fjh about my change to generate type_ctor and
Estimated hours taken: 1.5
Branches: main

Address review comments of fjh about my change to generate type_ctor and
special preds for the builtin types which don't have an abstract type
declaration.

compiler/make_hlds.m:
	Change parse_tree_to_hlds to use the state variable syntax.

compiler/type_util.m:
	s/builtin_type_ctors/builtin_type_ctors_with_no_type_defn/
	which better reflects which type ctors this function returns.

compiler/type_ctor_info.m:
	Improve the documentation of how the code determines whether
	or not a type_ctor_info needs to be generated.

compiler/typecheck.m:
	Use builtin_type_ctors_with_no_type_defn and make the documentation
	more explicit.
2003-11-21 15:21:37 +00:00
Peter Ross
22e4692ac5 Rather than declare the builtin types as abstract types in builtin.m
Estimated hours taken: 4
Branches: main

Rather than declare the builtin types as abstract types in builtin.m
special case their handling in the compiler to ensure that the
special preds and the type_ctor_infos are generated when needed.

compiler/type_util.m:
	Add a utility predicate which returns the list of type_ctors
	which represent types which are special builtins (ie they have no type
	declaration, even an abstract one).

compiler/make_hlds.m:
	Add the special preds for the special builtins if we are generating
	the rtti for the builtins.

compiler/type_ctor_info.m:
	Add type_ctor_infos for the special builtins if we are generating
	the rtti for the builtins.

compiler/typecheck.m:
	The special predicates for the special builtins don't require
	typechecking.

library/builtin.m:
	Remove the special builtins as they are no longer needed for
	generating the type_ctor_infos for a type.
2003-11-20 22:58:58 +00:00
Peter Ross
71b0c9c399 Get the compiler to generate the type_ctor_infos for all the types
Estimated hours taken: 36
Branches: main

Get the compiler to generate the type_ctor_infos for all the types
which were previously defined by hand.

This change completes the removal of all the MC++ from the compiler.

compiler/make_hlds.m:
	Remove the builtin qualifier from the builtin types, before
	processing them.

compiler/mlds_to_il.m:
	Remove the special code which handled those type_ctor_infos
	which where defined in MC++.

compiler/special_pred.m:
	Add a routine compiler_generated_rtti_for_the_builtins which
	returns if the compiler generates RTTI for builtin types, or
	they are hand-coded.  It returns true for the non-C backends.
	Change can_generate_special_pred_clauses_for_type so that it
	returns true for the builtin types whose body is defined in
	Mercury in private_builtin.m.

compiler/type_ctor_info.m:
	Generate a type_ctor_info for the builtin types if needed.

compiler/unify_proc.m:
	Generate calls to unification and comparison predicates defined
	in private_builtin.m.

library/Mmakefile:
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
	Remove the final MC++ code and rename some of the code to use
	the name which the Mercury compiler generates.
2003-11-20 11:35:43 +00:00
Peter Ross
9e5dc37dc1 Only the RTTI is written in MC++, so any of the variables from
Estimated hours taken: 2
Branches: main

compiler/mlds_to_il.m:
	Only the RTTI is written in MC++, so any of the variables from
	private_builtin are defined in C#.

runtime/mercury_il.il:
	Refer to the C# file not the MC++ file.
2003-11-15 12:57:33 +00:00
Peter Ross
3e2acdb87e Convert the last of the code in the library from MC++ to C#.
Estimated hours taken: 3
Branches: main

Convert the last of the code in the library from MC++ to C#.
However the RTTI datastructures for the builtin types are still defined
in MC++, for the moment.

compiler/mlds_to_il.m:
	Change the mangling so that for the names that need mangling
	that aren't RTTI types we look for them in the C# module.

library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
	Convert all the code from MC++ to C#, and mark that the
	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO macros need to be rewritten in
	Mercury.
2003-11-14 16:02:22 +00:00
Zoltan Somogyi
636f1fec21 Change the calling convention for higher order calls, to make such calls
Estimated hours taken: 1
Branches: main

Change the calling convention for higher order calls, to make such calls
faster.

The change to mercury_ho_call.c will be committed first. The change to the
compiler will be committed later, after people had a chance to do a "cvs
update" of the change of the runtime. This will avoid installed compilers
generating calls to labels that do not exist in the runtime directories of
workspaces.

runtime/mercury_ho_call.c:
	Add versions of mercury_do_call_closure/mercury_do_call_class_method
	that do not expect the argument giving the number of output arguments,
	since the code does not and will not need this information.

compiler/call_gen.m:
	Do not generate the argument giving the number of output arguments,
	and start placing user-specified arguments into the freed-up register.

compiler/llds_out.m:
	Generate code that calls the compact versions of the labels in
	mercury_ho_call.c.
2003-11-14 01:06:03 +00:00
Peter Ross
ce766f3d6a Rename mercury_mcpp.cs to mercury_dotnet.cs and switch it to under
Estimated hours taken: 1.5
Branches: main

Rename mercury_mcpp.cs to mercury_dotnet.cs and switch it to under
control of configure.  Switching to under the control of configure
allows us to define some constants determined at configure time.

runtime/mercury_mcpp.cs:
runtime/mercury_dotnet.cs.in:
	Copy mercury_mcpp.cs to mercury_dotnet.cs.in and define two
	new constants MR_VERSION and MR_FULLARCH which are needed by
	library.version/1.

library/library.m:
	Rewrite library.version/1 in C#.

configure.in:
	Add runtime/mercury_dotnet.cs to the list of files under
	control.

compiler/mlds_to_managed.m:
compiler/modules.m:
library/Mmakefile:
library/private_builtin.m:
runtime/Mmakefile:
	Updates to reflect the name change from mercury_mcpp to
	mercury_dotnet.
2003-11-13 15:08:22 +00:00
Fergus Henderson
c1626d9f1a Specify that code should generally be ordered top-down, not bottom-up.
Estimated hours taken: 0.25
Branches: main

compiler/notes/coding_standards.html:
w3/information/developers/c_coding_standard.html:
	Specify that code should generally be ordered top-down, not bottom-up.
2003-11-13 13:06:07 +00:00
Fergus Henderson
e97939f29b Fix a bug that broke bootstrapping in grade hlc.agc.
Estimated hours taken: 2
Branches: main

Fix a bug that broke bootstrapping in grade hlc.agc.

compiler/ml_closure_gen.m:
	Ensure that we generatine GC tracing code for the closure_arg
	parameter.  This is needed because it gets referenced by the
	GC tracing code for other local variables in this function.
	Without this, if two GCs occur between when a closure is
	called and when it returns, then the first GC will collect
	the closure, and then the second GC will try to dereference
	the closure_arg parameter.
2003-11-13 13:04:33 +00:00
Fergus Henderson
4c8ca5dd41 Add some comments, to address Zoltan's review comments on my
Estimated hours taken: 1
Branches: main

compiler/code_info.m:
compiler/var_locn.m:
	Add some comments, to address Zoltan's review comments on my
	previous change.
2003-11-13 09:51:23 +00:00
Peter Ross
f6ce6f27f7 Define MR_HIGHLEVEL_DATA, when necessary, at the beginning of
Estimated hours taken: 0.1
Branches: main

compiler/mlds_to_managed.m:
	Define MR_HIGHLEVEL_DATA, when necessary, at the beginning of
	the C# file as we do for MC++.
2003-11-13 09:43:16 +00:00
Fergus Henderson
2880344df1 Reorder some code, so that it goes next to the comment which
Estimated hours taken: 0.25
Branches: main

compiler/ml_util.m:
	Reorder some code, so that it goes next to the comment which
	describes it.  Also, fix a misleading comment.
2003-11-12 17:28:48 +00:00
Fergus Henderson
62a15c0da9 Fix a bug with accurate GC. The mapping from code addresses to stack
Estimated hours taken: 4
Branches: main

Fix a bug with accurate GC.  The mapping from code addresses to stack
layouts was not working properly, because GCC was reordering code within
C functions (LLDS modules) so that a label at end of the module did not
necessarily have the highest address.  The solution is to put the end label
in a different C function, i.e. a new LLDS module.

runtime/mercury_goto.h:
	Back out previous attempt to solve this problem, since it didn't work.

compiler/transform_llds.m:
	If accurate GC is enabled, append a module containing a dummy end label
	at the end of the module list.
2003-11-12 17:06:52 +00:00
Peter Ross
8296f11a83 The type private_builtin.ref/1 is abstract, this leads to problems on strongly
Estimated hours taken: 0.1
Branches: main

The type private_builtin.ref/1 is abstract, this leads to problems on strongly
typed backends such as the il backend which can generate references to this
type.

compiler/ml_util.m:
	Add private_builtin.ref/1 to the list of types which need a lowlevel
	representation.
2003-11-12 16:43:13 +00:00
Peter Ross
96f4bb36dd Improve the support for debugging in the il grade, by not optimizing
Estimated hours taken: 4
Branches: main

Improve the support for debugging in the il grade, by not optimizing
the generated il code, unless needed for verifiability.

Using
	mmc --make --grade il --debug diff
now generates code which is relatively easier to debug in an IL
debugger.

compiler/handle_options.m:
	--debug imples --target-debug for the il backend.
	if debugging and --no-trace-optimize and il backend then
	--no-optimize-peep.
	Allow --debug as valid option for the il backend.

compiler/mlds_to_ilasm.m:
	Use --verifiable-code and --optimize-peep to decide what level
	of peephole optimization is needed to be done.

compiler/il_peephole.m:
	Change the peephole optimizer so that it can do all peephole
	optimizations, or only those which are needed for
	verifiability.
2003-11-12 16:15:53 +00:00
Fergus Henderson
868eaec8ec Fix a bug that broke the MLDS back-end in the case when either heap profiling
Branches: main
Estimated hours taken: 0.5

Fix a bug that broke the MLDS back-end in the case when either heap profiling
or accurate GC was enabled.

compiler/mlds_to_c.m:
	Fix a bug in Zoltan's recent change to declare a local variable
	"base" for initializing terms allocated on the heap:
	change the order in which code is output so that the
	declaration of "base" comes immediately after the "{",
	without any intervening code.  Otherwise, it is not legal C89.
2003-11-12 07:00:05 +00:00
Zoltan Somogyi
5e25af41f7 This diff changes the LLDS backend to make it easier to read and to maintain,
Estimated hours taken: 6
Branches: main

This diff changes the LLDS backend to make it easier to read and to maintain,
but contains no changes in algorithms whatsoever.

compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/livemap.m:
compiler/peephole.m:
compiler/reassign.m:
compiler/rtti_out.m:
compiler/use_local_vars.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

compiler/llds_out.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

	Delete predicates which are just specialized forms of foldl, using
	foldl (or foldl2 etc) directly instead.

	Factor out some common code.

compiler/livemap.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

	Remove some special case handling that used to be required by the value
	numbering pass.

library/bintree_set.m:
	Provide a function version of the initialization predicate.
2003-11-11 03:35:13 +00:00
Zoltan Somogyi
7a6192a00f This diff changes goal_util.m to make it easier to read and to maintain,
Estimated hours taken: 1
Branches: main

This diff changes goal_util.m to make it easier to read and to maintain,
but contains no changes in algorithms whatsoever.

compiler/goal_util.m:
	Convert this module to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

compiler/*.m:
	Conform to the changes in the above module.
2003-11-11 03:23:26 +00:00
Zoltan Somogyi
36487eacfd When filling in the fields of a newly allocated cell, use a fresh local
Estimated hours taken: 1
Branches: main

compiler/mlds_to_c.m:
	When filling in the fields of a newly allocated cell, use a fresh local
	variable as the base address for the field references in preference to
	lvals that are more expensive to access. This yields a speedup of about
	0.3%. (The LLDS backend has had a similar optimization for a long
	time.)
2003-11-11 03:19:46 +00:00
Fergus Henderson
3e89507352 Another step towards supporting accurate GC for the LLDs back-end:
Estimated hours taken: 3
Branches: main

Another step towards supporting accurate GC for the LLDs back-end:
modify the LLDS code generator to allocate the proper forwarding pointer
slots for type_infos and typeclass_infos.

compiler/unify_gen.m:
compiler/code_info.m:
compiler/var_locn.m:
	When allocating type_infos or typeclass_infos on the heap,
	if accurate garbage collection is enabled then ensure that we
	reserve a word before the start of the object.  This word is
	used by the collector to store a forwarding pointer.
	For ordinary objects, we store the forwarding pointer in the
	old copy of the object, but we can't clobber the old copies of
	type_infos and typeclass_infos, since they might be used _during_
	garbage collection.
2003-11-06 20:14:28 +00:00
Fergus Henderson
a9a12de210 Fix a bug where the state variable transformation was not
Estimated hours taken: 4
Branches: main

compiler/make_hlds.m:
	Fix a bug where the state variable transformation was not
	correctly handling the case where the condition of an if-then-else
	referred to a state variable, but the "then" part didn't.

	(Also, fix some incorrect comments for get_rev_conj and get_rev_disj,
	and rearrange some misleading whitespace in the comments for the
	svar_info type.)

tests/valid/Mmakefile:
tests/valid/state_var_bug.m:
	Add a regression test.
2003-11-06 11:11:47 +00:00
Zoltan Somogyi
9c9c610f5a This diff changes modes.m, unique_modes.m and mode_info.m to make them easier
Estimated hours taken: 6
Branches: main

This diff changes modes.m, unique_modes.m and mode_info.m to make them easier
to read and to maintain, but contains no changes in algorithms whatsoever.

compiler/modes.m:
compiler/unique_modes.m:
compiler/mode_info.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.
	Delete predicates whose only purpose was to ease programming with DCGs.

	Remove the IO state from the mode_info structure, and pass it
	separately to the (relatively few) predicates that need it. This
	avoids using complicated (and as yet unsupported) modes or lying
	to the compiler (we used to do the latter), and we are no longer
	forced into that choice by being limited to a single hidden (DCG)
	variable.

	Use more expressive variable names and factor out code as appropriate.

compiler/*.m:
	Conform to the changes in the above two modules.
2003-11-06 03:42:36 +00:00
Fergus Henderson
8b7f99b086 Fix an incorrect comment.
Estimated hours taken: 0.25
Branches: main

compiler/ml_call_gen.m:
	Fix an incorrect comment.
2003-11-05 09:01:32 +00:00
Fergus Henderson
1cadb08887 Clarify that this file only applies to the LLDS back-end.
Estimated hours taken: 0.25
Branches: main

compiler/notes/gc_and_c_code.html:
	Clarify that this file only applies to the LLDS back-end.
2003-11-05 08:42:10 +00:00
Zoltan Somogyi
4b1cf91069 Address Fergus's review comments.
Estimated hours taken: 0.1
Branches: main

compiler/prog_data.m:
	Address Fergus's review comments.
2003-11-05 06:05:25 +00:00
Zoltan Somogyi
a2bf36e49a This diff contains no changes in algorithms whatsoever.
Estimated hours taken: 4
Branches: main

This diff contains no changes in algorithms whatsoever.

browser/*.m:
compiler/*.m:
library/*.m:
	Replace old-style lambdas with new-style lambdas or with named
	procedures.
2003-11-05 03:17:49 +00:00