[m-dev.] for review: add type_ctor_reps

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jun 30 01:07:09 AEST 1999


On 29-Jun-1999, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
> representation of this type.
> 
> Use this representation in code that uses RTTI.

The rationale here could explain things in a little more detail.
(For instance, what did we use previously? What's the advantage of
using MR_TYPECTOR_REP_* instead?)

> runtime/mercury_deep_copy_body.h:
...
> 	Also, fix a bug in deep_copy when copying floating point values.
> 	I'm not sure when this stopped working, or if this is exactly
> 	the right fix, but it is more correct than the previous code.
> 
> Index: runtime/mercury_deep_copy_body.h
...
> -        case MR_DATAREP_FLOAT:
> +        case MR_TYPECTOR_REP_FLOAT:
>              #ifdef BOXED_FLOAT
>                  if (in_range(data_value)) {
> -                    incr_saved_hp(new_data, FLOAT_WORDS);
> -                    field(0, new_data, 0) = *data_value;
> +		    new_data = word_to_float(float_to_word(data));
> +//                    incr_saved_hp(new_data, FLOAT_WORDS);
> +//                   field(0, new_data, 0) = *data_value;
>                      leave_forwarding_pointer(data_ptr, new_data);
>                  } else {
>                      new_data = data;

You should definitely not commit anything containing "//" comments,
because they are not supported by the (1989) ANSI/ISO C standard.

Your fix won't quite work, because word_to_float() uses
incr_hp() not incr_saved_hp().  You should add calls to
restore_transient_hp() and save_transient_hp() before and
after the memory allocation:

                if (in_range(data_value)) {
		    restore_transient_hp();
		    new_data = word_to_float(float_to_word(data));
		    save_transient_hp();
                    leave_forwarding_pointer(data_ptr, new_data);
                } else {

> +++ mercury_type_info.h	1999/06/22 17:31:00
> @@ -250,9 +250,9 @@
>  */
>  
>  #define MR_TYPE_CTOR_INFO_HO_PRED				\
> -	((const Word *) &mercury_data___type_ctor_info_pred_0)
> +	((MR_TypeCtorInfo) (const Word *) &mercury_data___type_ctor_info_pred_0)
>  #define MR_TYPE_CTOR_INFO_HO_FUNC				\
> -	((const Word *) &mercury_data___type_ctor_info_func_0)
> +	((MR_TypeCtorInfo) (const Word *) &mercury_data___type_ctor_info_func_0)

Why are the double casts needed here?

----------

Apart from that, this change looks fine.  Thanks.

-- 
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