Commit Graph

5 Commits

Author SHA1 Message Date
Zoltan Somogyi
4865f11503 Update programming style. 2020-10-04 13:20:42 +11:00
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +11: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
1315102d7c Fix several occurrences of a bug that prevented the compiler from passing
Estimated hours taken: 20
Branches: main

Fix several occurrences of a bug that prevented the compiler from passing
all the tests in deep profiling grades. We now pass all the tests in deep
profiling grades.

Some additional changes were useful in tracking this bug down. Using C types
to represent deep profiling data structures allowed us to delete a bunch of
casts and thus eliminate them as potential bug locations. Another was to fix
some bugs in low level debugging support.

In light of the fragility of the deep profiling invariants, always check them
when writing out deep profiling data files. Since mdprof depends on these
invariants, they have to be checked somewhere, and we already have code for the
checks in the runtime.

Reenable tail recursion support in deep profiling grades, since it now works.
(The bug this change fixes used to occur most in tail recursive procedures,
which is why previously I turned it off.)

compiler/options.m:
	Reenable tail recursion support in deep profiling grades.

runtime/mercury_unify_compare_body.h:
	Fix the bug that prevented us from passing all the tests with
	invariants checked and tail recursion support enabled. The bug was
	that in several cases, the code in mercury_unify_compare_body.h
	did not invoke the appropriate deep profiling routines and thus
	did not fill in the deep profiling data structure they were supposed to
	fill in, breaking an invariant.

	There were several instances of this bug: unify, compare and
	compare_representation on tuples, and compare_representation on
	functions, predicates and user-defined types.

	These oversights were possible because the actions of returning an
	answer and filling in the deep profiling data structures (in deep
	profiling grades) were separate. If one omitted the latter, tests could
	still work in all grades except deep profiling grades.

	The fix therefore uses one macro (return_compare_answer or return
	unify_answer, depending on the the operation) to fill in the deep
	profiling data structure (in deep profiling grades) and return the
	answer, making it impossible to forget to do the former.

	The new approach treats compare_representation the same as compare,
	and gathers the same information for it.

runtime/mercury_ho_call.c:
	Factor out some commonalities in the definitions of the MR_ProcStatic
	data structures used by the code in mercury_unify_compare_body.h.

	Change a macro name to support the changes in
	mercury_unify_compare_body.h.

	Change the module name of compare_representation/3 from std_util to
	builtin, to match unify/2 and compare/3.

compiler/deep_profiling.m:
	Treat compare_representation/3 the same way as we treat compare/3.

library/builtin.m
library/std_util.m
	Move the declaration of compare_representation/3 from std_util to
	builtin, to make it easier to handle it the same way as compare/3.
	Since it is just a variant of compare/3 and is at least as built
	into the implementation, it belongs there anyway.

library/profiling_builtin.m:
	Use C types to represent deep profiling data structures.
	Delete the casts that are redundant after this change.

	Fix formatting of foreign_procs.

runtime/mercury_deep_profiling.c:
	As mentioned above, always check the invariants of the deep profiling
	data structures when writing them out.

runtime/mercury_deep_profiling.h:
	Avoid a warning about nested declarations of variable "i".

runtime/mercury_deep_rec_depth_body.h:
	Delete a bunch of casts we don't need anymore.

runtime/mercury_wrapper.[ch]:
	Initialize a couple of predicate names in the low level debug support
	to "" instead of NULL. The code that accesses these variables passes
	them to strcmp directly, which lead to core dumps. We could change the
	accessing code to test for NULL, but since that code is executed on
	every call when low level debugging is enabled, that would lead to
	even greater slowdowns, which we can do without.

	To avoid a warning about casting away const, make the variables
	involved "const char *" instead of plain "char *"; we don't want
	to update the pointed-to strings anyway.

tools/bootcheck:
	In profiling grades, write out profiling data files by default, and
	require the use of an option to turn them off. This is needed to make
	sure that the deep profiling invariants are checked by default.

tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.m:
	Avoid hard-coding the name of the module defining
	compare_representation/3.
2002-11-08 00:45:55 +00:00
Mark Brown
56e818af67 Implement compare_representation/3, which is like compare except that it
Estimated hours taken: 5.5
Branches: main

Implement compare_representation/3, which is like compare except that it
is cc_multi, and it doesn't abort on non-canonical types.  The implementation
only works for the LLDS backend; in other cases, the runtime aborts with
a "sorry" message.  For this reason, it is not officially part of the
standard library yet.

library/std_util.m:
	Add the new predicate, which is implemented via "external".

runtime/mercury_ho_call.c:
	Implement compare_representation/3, and also a C version.

runtime/mercury_unify_compare_body.h:
	Implement the body of compare_representation/3.  When the macro
	include_compare_rep_code is defined comparison of preds and
	funcs doesn't abort, the code that is used for MR_COMPARE_BY_RTTI
	is enabled, and usereq types are treated as normal types.

runtime/mercury_conf_param.h:
	Document the fact that calls to compare_representation are
	counted as calls to compare for the purposes of MR_TYPE_CTOR_STATS.

runtime/Mmakefile:
	Bug fix: add missing pic_o versions of the explicit dependencies.
	Use variables for the suffixes in these dependencies.

runtime/mercury.c:
runtime/mercury.h:
	Supply a HIGHLEVEL_CODE version of the new predicate.  This just
	gives a "Sorry, not implemented" message and aborts.

tests/hard_coded/Mmakefile:
tests/hard_coded/compare_rep_usereq.exp:
tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.exp:
tests/hard_coded/compare_representation.m:
	Test cases.

tests/hard_coded/compare_rep_array.m:
	A test case which doesn't work yet.
2002-04-25 09:31:59 +00:00