runtime/mercury_type_info.h:
Use unsigned integer types for a few RTTI structure fields that
are known to hold non-negative values.
Add comments for other field types that could be changed later.
compiler/rtti.m:
Use fixed size integer types for fields matching the size
and signedness of the corresponding C RTTI structure fields.
Encode type ctor flags in a uint16 instead of int.
Make type_ctor_details_num_ptags and type_ctor_details_num_functors
return a maybe value, instead of a negative value to represent no
primary tags or no function symbols, respectively.
compiler/type_ctor_info.m:
Conform to type changes.
Use uint16 to represent the "contains var" bit vector.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
Conform to type changes.
Add comments to make it easier to find the code that writes out
each particular RTTI structure field.
compiler/ml_util.m:
Add helper functions.
compiler/add_special_pred.m:
compiler/du_type_layout.m:
compiler/erl_rtti.m:
compiler/erlang_rtti.m:
compiler/hlds_data.m:
compiler/llds_out_data.m:
compiler/ml_unify_gen_construct.m:
compiler/opt_debug.m:
compiler/pseudo_type_info.m:
compiler/stack_layout.m:
compiler/unify_gen_construct.m:
Conform to type changes.
compiler/parse_type_defn.m:
compiler/prog_data.m:
Use uint32 for functor ordinal numbers.
library/rtti_implementation.m:
Use fixed size integer types for RTTI field accessor functions,
and update callers.
java/runtime/DuArgLocn.java:
java/runtime/DuExistInfo.java:
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/TypeCtorInfo_Struct.java:
Use integer types in RTTI structure definitions for Java that match
the types in the C versions of the same structures.
runtime/mercury_dotnet.cs.in:
Use integer types in RTTI structure definitions for C# that match
the types in the C versions of the same structures.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
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.