[m-dev.] for review: compressing RTTI using non-word creates (part 1)

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 26 23:11:31 AEST 1999


On 26-Apr-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> runtime/mercury_conf.h.in:
> 	Mention the macros used by the configure script, INT32_TYPE
> 	and INT16_TYPE.
> 
> runtime/mercury_conf_param.h:
> 	Document the macros used by the configure script, INT32_TYPE
> 	and INT16_TYPE.

Those macros should have an `MR_' prefix.

> compiler/llds.m:
> 	Modify the create rval in two ways. First, add an extra argument to
> 	represent the types of the arguments, which used to always be implicit
> 	always a word in size, but may now be explicit and possibly smaller
> 	(e.g. uint8). Second, since the code generator would do the wrong
> 	thing with creates with smaller than wordsize arguments, replace
> 	the old must-be-unique vs may-be-nonunique bool with a three-valued
> 	marker, must_be_dynamic vs must_be_static vs can_be_either.

Hmm, wouldn't it be better to modify the code generator so that it can
cope with creates that have non-word-sized arguments?

It looks to me like this change will break the `--no-static-ground-terms'
option.

> compiler/llds_common.m:
> 	Don't conflate creates with identical argument values but different
> 	argument types.

Why not?  If the argument types have the same size, then this optimization
should still be applicable.

> compiler/code_exprn.m:
> 	If a create is marked must_be_static, don't inspect the arguments
> 	to decide whether it can be static or not.

Would it be better to inspect the arguments
and call error/1 in case of a conflict?

> +	AC_MSG_CHECKING(for a 32-bit integer type)
> +	AC_CACHE_VAL(mercury_cv_int32_type,
> +		AC_TRY_RUN([
> +		#include <stdio.h>
> +		int main() {
> +			FILE *fp;
> +
> +			fp = fopen("conftest.tags", "w");
> +			if (fp == NULL)
> +				exit(1);
> +
> +			if (sizeof(int) >= 4)
> +			{
> +				fprintf(fp, "int\n");
> +				exit(0);
> +			}
> +
> +			if (sizeof(long) >= 4)
> +			{
> +				fprintf(fp, "long\n");
> +				exit(0);
> +			}

It would be better to test SHRT_MAX, INT_MAX, and LONG_MAX,
defined in <limits.h>, rather than testing the results of sizeof,
since sizeof measures the size in chars, not in bits, and ANSI C
only guarantees that CHAR_BIT >= 8 not that CHAR_BIT == 8.

Also testing preprocessor constants is better because it can
be done using AC_TRY_COMPILE rather than AC_TRY_RUN, which is
better because AC_TRY_RUN doesn't work if you're cross-compiling.

> Index: compiler/llds.m
...
> +		% Or it may say that this cell can be allocated either way,
> +		% subject to other constraints (e.g. a cell cannot be allocated
> +		% statically unless all of its components are statically
> +		% allocated as well.

Missing ')'.

> @@ -618,6 +630,13 @@
>  		% The last argument gives the name of the type constructor
>  		% of the function symbol of which this is a cell, for use
>  		% in memory profiling.
> +		%
> +		% For the time being, you must leave the argument types
> +		% implicit if you the cell is to be unique. This is because

Delete the word "you"?

> +	% Values of this type specify the C types and therefore the sizes
> +	% of the arguments of a create rval.
> +	%
> +	% If the type is given as yes(LldsType), then the type is the C type
> +	% corresponding to LldsType. If the type is given as no, then the
> +	% type is implicit; it is llds_out__rval_type_as_arg says when given
> +	% the actual argument.

s/it is/it is what/

>  :- type llds_type
> -	--->	bool		% a boolean value
> -				% represented using the C type `Integer'
> -	;	integer		% a Mercury `int', represented in C as a
> +	--->	bool		% A boolean value
> +				% represented using the C type `Integer'.
> +	;	int8		% A signed value that fits that contains
> +				% at least eight bits, represented using the
> +				% C type int_least8_t. Intended for use in
> +				% static data declarations, not for data
> +				% that gets stored in registers, stack slots
> +				% etc.
> +	;	uint8		% An unsigned version of int8, represented
> +				% using the C type uint_least8_t.
> +	;	int16		% A signed value that fits that contains
> +				% at least sixteen bits, represented using the
> +				% C type int_least16_t. Intended for use in
> +				% static data declarations, not for data
> +				% that gets stored in registers, stack slots
> +				% etc.
> +	;	uint16		% An unsigned version of int16, represented
> +				% using the C type uint_least16_t.
> +	;	int32		% A signed value that fits that contains
> +				% at least 32 bits, represented using the
> +				% C type int_least32_t. Intended for use in
> +				% static data declarations, not for data
> +				% that gets stored in registers, stack slots
> +				% etc.
> +	;	uint32		% An unsigned version of int32, represented
> +				% using the C type uint_least32_t.

These types should be given names that match their names in C,
e.g. `int_least16', not `int16'.  Otherwise the names would be
misleading.

> +	;	string		% A string; represented in C as a value of
> +				% type `String'.

s/A string;/A Mercury string;/

(We might someday want to represent Mercury strings differently than
C strings, e.g. to allow Unicode strings.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list