Commit Graph

13 Commits

Author SHA1 Message Date
Zoltan Somogyi
9b6390b17e Bring the programming style of extras up to date.
extras/curs/curs.m:
extras/curs/curs.panel.m:
    Make panel a separate submodule of curs, not a nested submodule.

extras/base64/base64.m:
extras/curses/mcurses.basics.m:
extras/curses/mcurses.m:
extras/curses/mcurses.misc.m:
extras/curses/mcurses.user.m:
extras/gator/evolve.m:
extras/gator/genotype.m:
extras/gator/phenotype.m:
extras/gator/tausworthe3.m:
extras/monte/dots.m:
extras/monte/geom.m:
extras/monte/hg.m:
extras/monte/monte.m:
extras/monte/rnd.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/mopenssl/mopenssl.m:
extras/net/echo.m:
extras/net/errno.m:
extras/net/getaddrinfo.m:
extras/net/net.m:
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/streams.m:
extras/net/tcp.m:
extras/net/test_lookups.m:
extras/net/types.m:
extras/odbc/odbc.m:
extras/odbc/odbc_test.m:
extras/references/README:
extras/references/reference.m:
extras/references/scoped_update.m:
extras/solver_types/library/any.m:
extras/solver_types/library/any_array.m:
extras/solver_types/library/any_assoc_list.m:
extras/solver_types/library/any_list.m:
extras/solver_types/library/any_map.m:
extras/solver_types/library/any_tree234.m:
extras/solver_types/library/any_util.m:
extras/trail/trail.m:
extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/vqueens.m:
extras/trailed_update/tests/var_test.m:
extras/trailed_update/tr_array.m:
extras/trailed_update/tr_store.m:
extras/trailed_update/trailed_update.m:
extras/trailed_update/unsafe.m:
extras/trailed_update/var.m:
    Bring programming style up to date.
2023-03-30 21:48:10 +11:00
Julien Fischer
aff3343c68 Fix more compilation errors in extras.
extras/trailed_update/tr_store.m:
	Conform to runtime changes.

extras/gator/genotype.m:
extras/gator/phenotype.m:
extras/graphics/samples/maze/maze.m:
extras/trailed_update/samples/interpreter.m:
	Conform to standard library changes.
2014-02-06 03:31:59 +11:00
Peter Wang
0ae65de577 Pack consecutive enumeration arguments in discriminated union types into a
Branches: main

Pack consecutive enumeration arguments in discriminated union types into a
single word to reduce cell sizes.  Argument packing is only enabled on C
back-ends with low-level data, and reordering arguments to improve
opportunities for packing is not yet attempted.  The RTTI implementations for
other back-ends will need to be updated, but that is best left until after any
argument reordering change.

Modules which import abstract enumeration types are notified so by writing
declarations of the form:

	:- type foo where type_is_abstract_enum(NumBits).

into the interface file for the module which defines the type.


compiler/prog_data.m:
	Add an `arg_width' argument to constructor arguments.

	Replace `is_solver_type' by `abstract_type_details', with an extra
	option for abstract exported enumeration types.

compiler/handle_options.m:
compiler/options.m:
	Add an internal option `--allow-argument-packing'.

compiler/make_hlds_passes.m:
	Determine whether and how to pack enumeration arguments, updating the
	`arg_width' fields of constructor arguments before constructors are
	added to the HLDS.

compiler/mercury_to_mercury.m:
compiler/modules.m:
	Write `where type_is_abstract_enum(NumBits)' to interface files
	for abstract exported enumeration types.

compiler/prog_io_type_defn.m:
	Parse `where type_is_abstract_enum(NumBits)' attributes on type
	definitions.

compiler/arg_pack.m:
compiler/backend_libs.m:
	Add a new module.  This mainly contains a predicate which packs rvals
	according to arg_widths, which is used by both LLDS and MLDS back-ends.

compiler/ml_unify_gen.m:
compiler/unify_gen.m:
	Take argument packing into account when generating code for
	constructions and deconstructions.  Only a relatively small part of the
	compiler actually needs to understand argument packing.  The rest works
	at the HLDS level with constructor arguments and variables, or at the
	LLDS and MLDS levels with structure fields.

compiler/code_info.m:
compiler/var_locn.m:
	Add assign_field_lval_expr_to_var and
	var_locn_assign_field_lval_expr_to_var.

	Allow more kinds of rvals in assign_cell_arg.  I do not know why it was
	previously restricted, except that the other kinds of rvals were not
	encountered as cell arguments before.

compiler/mlds.m:
	We can now rely on the compiler to pack arguments in the
	mlds_decl_flags type instead of doing it manually.  A slight downside
	is that though the type is packed down to a single word cell, it will
	still incur a memory allocation per cell.  However, I did not notice
	any difference in compiler speed.

compiler/rtti.m:
compiler/rtti_out.m:
	Add and output a new field for MR_DuFunctorDesc instances, which, if
	any arguments are packed, points to an array of MR_DuArgLocn.  Each
	array element describes the offset in the cell at which the argument's
	value is held, and which bits of the word it occupies.  In the more
	common case where no arguments are packed, the new field is simply
	null.

compiler/rtti_to_mlds.m:
	Generate the new field to MR_DuFunctorDesc.

compiler/structure_reuse.direct.choose_reuse.m:
	For now, prevent structure reuse reusing a dead cell which has a
	different constructor to the new cell.  The code to determine whether a
	dead cell will hold the arguments of a new cell with a different
	constructor will need to be updated to account for argument packing.

compiler/type_ctor_info.m:
	Bump RTTI version number.

	Conform to changes.

compiler/add_type.m:
compiler/check_typeclass.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/erl_rtti.m:
compiler/hlds_data.m:
compiler/hlds_out_module.m:
compiler/intermod.m:
compiler/make_tags.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/special_pred.m:
compiler/type_constraints.m:
compiler/type_util.m:
compiler/unify_proc.m:
compiler/xml_documentation.m:
	Conform to changes.

	Reduce code duplication in classify_type_defn.

compiler/hlds_goal.m:
	Clarify a comment.

library/construct.m:
	Make `construct' pack arguments when necessary.

	Remove an old RTTI version number check as recommended in
	mercury_grade.h.

library/store.m:
	Deal with packed arguments in this module.

runtime/mercury_grade.h:
	Bump binary compatibility version number.

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Bump RTTI version number.

	Add MR_DuArgLocn structure definition.

	Add a macro to unpack an argument as described by MR_DuArgLocn.

	Add a function to determine a cell's size, since the number of
	arguments is no longer correct.

runtime/mercury_deconstruct.c:
runtime/mercury_deconstruct.h:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_expand_body.h:
	Deal with packed arguments when deconstructing.

	Remove an old RTTI version number check as recommended in
	mercury_grade.h.

runtime/mercury_deep_copy_body.h:
	Deal with packed arguments when copying.

runtime/mercury_table_type_body.h:
	Deal with packed arguments in tabling.

runtime/mercury_dotnet.cs.in:
	Add DuArgLocn field to DuFunctorDesc. Argument packing is not enabled
	for the C# back-end yet so this is unused.

trace/mercury_trace_vars.c:
	Deal with packed arguments in MR_select_specified_subterm,
	use for the `hold' command.

java/runtime/DuArgLocn.java:
java/runtime/DuFunctorDesc.java:
	Add DuArgLocn field to DuFunctorDesc. Argument packing is not enabled
	for the Java back-end yet so this is unused.

extras/trailed_update/tr_store.m:
	Deal with packed arguments in this module (untested).

extras/trailed_update/samples/interpreter.m:
extras/trailed_update/tr_array.m:
	Conform to argument reordering in the array, map and other modules in
	previous changes.

tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/lco_pack_args.exp:
tests/hard_coded/lco_pack_args.m:
tests/hard_coded/pack_args.exp:
tests/hard_coded/pack_args.m:
tests/hard_coded/pack_args_copy.exp:
tests/hard_coded/pack_args_copy.m:
tests/hard_coded/pack_args_intermod1.exp:
tests/hard_coded/pack_args_intermod1.m:
tests/hard_coded/pack_args_intermod2.m:
tests/hard_coded/pack_args_reuse.exp:
tests/hard_coded/pack_args_reuse.m:
tests/hard_coded/store_ref.exp:
tests/hard_coded/store_ref.m:
tests/invalid/Mmakefile:
tests/invalid/where_abstract_enum.err_exp:
tests/invalid/where_abstract_enum.m:
tests/tabling/Mmakefile:
tests/tabling/pack_args_memo.exp:
tests/tabling/pack_args_memo.m:
	Add new test cases.

tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
	Add constructors with packed arguments to these cases.

tests/invalid/where_direct_arg.err_exp:
	Update expected output.
2011-07-05 03:34:39 +00:00
Julien Fischer
0d22a819d9 Fix bitrot in extras/trailed_update.
Branches: main

Fix bitrot in extras/trailed_update.

extras/trailed_updated/var.m:
	Don't specify an initialisation predicated for the solver type var/1.

extras/trailed_updated/samples/interpreter.m:
	Conform with the change that added an extra argument to the variable/2
	constructor of the standard library type term/1.

extras/trailed_update/tests/var_test.m:
	Use up-to-date syntax for modes.

extras/trailed_update/Mmakefile:
extras/trailed_update/samples/Mmakefile:
extras/trailed_update/tests/var_test.m:
	Use trail segments since that's what you get in an installation by
	default.

extras/trailed_update/*.m:
	Update syntax and formatting to conform more closely to our
	current coding standards.

	Add require_feature_set pragmas for trailing.
2010-12-16 15:12:02 +00:00
Julien Fischer
34cc756c73 Fix compilation of extras/trailed_update.
Estimated hours taken: 0.1
Branches: main, release

Fix compilation of extras/trailed_update.

extras/trailed_update/var.m:
	Add missing promise_pure scopes.

extras/trailed_update/samples/interpreter.m:
	Conform to recent changes in the standard library.
2006-04-21 04:12:21 +00:00
Julien Fischer
03f647d82b Use more recent syntax and make these modules
Estimated hours taken: 2.5
Branches: main, release

extras/trailed_update/tr_array.m:
extras/trailed_update/tr_store.m:
extras/trailed_update/var.m:
extras/trailed_update/unsafe.m:
extras/trailed_update/samples/vqueens.m:
	Use more recent syntax and make these modules
	conform more closely to our coding standard.

	Use the new foreign language interface.

	Replace deprecated mode and inst syntax.

extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/interpreter.exp:
	s/mutvar/generic_mutvar/
2005-03-01 13:29:04 +00:00
Fergus Henderson
b53bec640a Fix a problem that broke extras/trailed_update/samples/interpreter.
Estimated hours taken: 1
Branches: main

Fix a problem that broke extras/trailed_update/samples/interpreter.

extras/trailed_update/samples/interpreter.m:
	Use an assoc_list rather than a map when mapping from store__mutvars.
	This is needed because store__mutvars (and other reference types)
	can only be tested for equality, not compared.  That changed
	after my previous patch to add a new TYPE_CTOR_REP for references.
	We need to disallow compare/3 on reference types because in *.agc
	grades, their addresses might change after a garbage collection,
	and the changes might not preserve the ordering.

extras/trailed_update/samples/interpreter.exp:
	Update to reflect the above change to interpreter.m.
2003-02-19 06:51:34 +00:00
Fergus Henderson
234858a92c Use `unsafe_promise_unique' rather than impure code.
Estimated hours taken: 0.75
Branches: main

extras/trailed_update/samples/interpreter.m:
	Use `unsafe_promise_unique' rather than impure code.
	This is a cleaner solution.  (We don't want to be
	recommending the use of `impure' in sample code
	when better alternatives are available!)
2003-01-18 14:03:08 +00:00
Fergus Henderson
733f94a539 Change library/store.m to make use of existential types.
Estimated hours taken: 2

Change library/store.m to make use of existential types.

library/store.m:
	Add a new existentially predicate store__new/1, which is like the old
	store__init/1 but existentially typed.  This ensures safety,
	by preventing you from using a key from one store as an index
	into a different store.

	The unsafe store__init predicate is now declared `pragma obsolete'.
	The store__some_store_type type is now also documented as obsolete
	(unfortunately there is currently no equivalent to a `pragma obsolete'
	declaration for types).

browser/declarative_execution.m:
extras/trailed_update/samples/interpreter.m:
	Use store__new rather than the obsolete store__init.

tests/general/intermod_type2.m:
	Avoid using the obsolete type store__some_store_type.

extras/curses/user.m:
	Add a new predicate init_curse_store, and use that
	instead of the obsolete store__init.
	Also rename set_curse and get_curse as set_curse_store
	and get_curse_store respectively.

NEWS:
	Mention this change.
2000-04-13 10:05:42 +00:00
Fergus Henderson
a1ea46ee92 Work around a (spurious) unique mode error, which was
Estimated hours taken: 1

extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/interpreter.exp:
	Work around a (spurious) unique mode error, which was
	caused by the recent changes to make unique mode checking
	of higher-order terms and lambda expressions more strict.
	The work-around is to avoid the use of the higher-order
	pred unsorted_aggregate/4, and instead use impure code (ugh).

	In the long term, a better solution would be to add support
	for `call-once' higher-order modes.
1998-02-15 06:23:47 +00:00
Fergus Henderson
ef70effdae Fix a typo in a comment: s/unindex/unindexed/.
Estimated hours taken: 0.1

extras/trailed_update/samples/interpeter.m:
	Fix a typo in a comment: s/unindex/unindexed/.
1997-10-12 13:39:20 +00:00
Fergus Henderson
4b641e59a8 Add comment "this file is hereby placed in the public domain."
Estimated hours taken: 0.1

extras/trailed_update/samples/interpreter.m:
	Add comment "this file is hereby placed in the public domain."
1997-09-30 15:18:25 +00:00
Fergus Henderson
53330ee842 New file. An example of the use of tr_store.m.
Estimated hours taken: 4

extras/trailed_update/samples/interpreter.m:
	New file.  An example of the use of tr_store.m.

samples/interpreter.m:
	Add pointer to extras/trailed_update/samples/interpreter.m.

extras/trailed_update/Mmakefile:
extras/trailed_update/samples/interpreter.inp:
extras/trailed_update/samples/interpreter.exp:
extras/trailed_update/samples/vqueens.exp:
	New files.  Some testing infrastructure.
1997-09-29 15:24:19 +00:00