diff: deep_copy bug fixes & unique_array change

Tyson Richard DOWD trd at students.cs.mu.oz.au
Mon Apr 28 18:07:42 AEST 1997


This is a review of a slightly more up-to-date version of this diff.

> 
> Here's a fully-up-to-date version of those changes.
> 
> -----------------------------------------------------------------------------
> 
> Lots of bug fixes for deep_copy().
> Also an efficiency improvement for uniq_array.
> 
> runtime/type_info.h:
> 	Add definitions for accessing the representation of uniq_arrays.
> 	Add TYPELAYOUT_TYPEINFO_VALUE, TYPELAYOUT_UNIQ_ARRAY_VALUE,
> 	and TYPELAYOUT_C_POINTER_VALUE.
> 	All of those types need special unification predicates
> 	and special treatment in deep_copy.
> 	They may also need special treatment elsewhere.
> 	Also rename TYPELAYOUT_NO_NAME_VALUE as TYPELAYOUT_VOID_VALUE.
> 
> runtime/deep_copy.c:
> 	Add code to deep_copy() to copy uniq_arrays, type_infos,
> 	and c_pointers.  Avoid unnecessary copying for higher-order types.
> 	Fix bugs in copying of boxed floats and univ.
> 
> library/uniq_array.m:
> 	Change the representation of uniq_array so that it is more
> 	efficient (avoid an unnecessary extra level of indirection).
> 	Move the definition of the uniq_array type to runtime/type_info.h,
> 	so that it can be used by deep_copy().
> 	Use `MR_' and `ML_' prefixes as per our C coding standards.
> 	Add a constructor function `uniq_array/1'.
> 	Add code to do unify, compare, type_to_term, and term_to_type
> 	for uniq_array.

> +Word *
> +deep_copy_type_info(Word *type_info, Word *lower_limit, Word *upper_limit)
> +{
> +	if (in_range(type_info)) {
> +		Word *base_type_info;
> +		Word *new_type_info;
> +		Integer arity, i;
> +
> +		base_type_info = MR_TYPEINFO_GET_BASE_TYPEINFO(type_info);
> +		arity = MR_BASE_TYPEINFO_GET_TYPE_ARITY(base_type_info);
> +		new_type_info = make_many(Word, arity + 1);
> +		new_type_info[0] = type_info[0];
> +		for (i = 1; i < arity + 1; i++) {
> +			new_type_info[i] = (Word) deep_copy_type_info(
> +				(Word *) type_info[i],
> +				lower_limit, upper_limit);
> +		}
> +		return new_type_info;
> +	} else {
> +		return type_info;
> +	}
> +}

This isn't right for higher order pred type_infos.

Once this is documented at least (fixed if possible) the change seems fine.

-- 
       Tyson Dowd           #
                            #             Sign on refrigerator:
     trd at cs.mu.oz.au        #           Refrigerate after opening. 
http://www.cs.mu.oz.au/~trd #                  - C. J. Owen.



More information about the developers mailing list