[m-rev.] for review: reserved address data representation (part 2)

Tyson Dowd trd at cs.mu.OZ.AU
Wed Oct 24 16:24:24 AEST 2001


On 24-Oct-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 24-Oct-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > Allow the compiler to optionally make use of reserved addresses --
> > null pointers, ints cast to pointers, and addresses of global variables --
> > to optimize the representation of constants in discriminated union types.
> 
> Estimated hours taken: 18
> Branches: main
> 
> Add RTTI support for the new reserved address data representations.
> 
> runtime/mercury_type_info.h:
> runtime/mercury_mcpp.h:
> runtime/mercury.h:
> library/private_builtin.m:
> library/rtti_implementation.m:
> 	Add MR_TYPECTOR_REP_RESERVED_ADDR (with and without _USEREQ) to
> 	the MR_TypeCtorRep enum, for discriminated union types containing
> 	one or more functors represented using reserved addresses,
> 	and add new RTTI structs to hold information about how such
> 	types are represented.
> 	
> compiler/type_ctor_info.m:
> compiler/mlds_to_gcc.m:
> compiler/opt_debug.m:
> compiler/rtti.m:
> compiler/rtti_out.m:
> compiler/rtti_to_mlds.m:
> 	Add appropriate code to generate these new RTTI structs.
> 
> runtime/mercury_deep_copy_body.h:
> runtime/mercury_ml_expand_body.h:
> runtime/mercury_unify_compare_body.h:
> runtime/mercury_tabling.c:
> library/std_util.m:
> 	Add code to handle the MR_TYPECTOR_REP_RESERVED_ADDR alternative,
> 	using the information in the new RTTI structs.
> 

> Index: runtime/mercury_deep_copy_body.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy_body.h,v
> retrieving revision 1.38
> diff -u -d -r1.38 mercury_deep_copy_body.h
> --- runtime/mercury_deep_copy_body.h	7 Aug 2001 23:12:25 -0000	1.38
> +++ runtime/mercury_deep_copy_body.h	22 Oct 2001 12:12:53 -0000

>      case MR_TYPECTOR_REP_DU:
>      case MR_TYPECTOR_REP_DU_USEREQ:
> +    	du_type_layout = type_ctor_info->type_layout.layout_du;
> +	/* fallthru */
> +
> +    du_type:
>          {
> -            MR_DuPtagLayout     *ptag_layout;
> -            int                 ptag;
>              MR_Word                *data_value;
> +	    MR_DuPtagLayout     *ptag_layout;
> +	    int                 ptag;
>  
>              ptag = MR_tag(data);
> -            ptag_layout = &type_ctor_info->type_layout.layout_du[ptag];
> +            ptag_layout = &du_type_layout[ptag];
>  
>              switch (ptag_layout->MR_sectag_locn) {
>              case MR_SECTAG_LOCAL:

A comment explaining and highlighting the label there would improve
mantainability.  If we are going to use gotos, we should be nice and
clear about how the entry point works.

> Index: runtime/mercury_ml_expand_body.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_ml_expand_body.h,v
> retrieving revision 1.2
> diff -u -d -r1.2 mercury_ml_expand_body.h
> --- runtime/mercury_ml_expand_body.h	12 Jul 2001 01:30:30 -0000	1.2
> +++ runtime/mercury_ml_expand_body.h	22 Oct 2001 12:55:52 -0000

>          case MR_TYPECTOR_REP_DU_USEREQ:
>              expand_info->non_canonical_type = TRUE;
>              /* fall through */
>  
>          case MR_TYPECTOR_REP_DU:
> +	    du_type_layout = type_ctor_info->type_layout.layout_du;
> +	    /* fall through */
> +
> +	du_type:
>              {
>                  const MR_DuPtagLayout   *ptag_layout;
>                  const MR_DuFunctorDesc  *functor_desc;

Ditto.

> Index: runtime/mercury_tabling.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
> retrieving revision 1.42
> diff -u -d -r1.42 mercury_tabling.c
> --- runtime/mercury_tabling.c	31 May 2001 06:00:16 -0000	1.42
> +++ runtime/mercury_tabling.c	22 Oct 2001 12:14:49 -0000

>          case MR_TYPECTOR_REP_DU: 
>          case MR_TYPECTOR_REP_DU_USEREQ: 
> +	    du_type_layout = type_ctor_info->type_layout.layout_du;
> +	    /* fall through */
> +	
> +	du_type:
>              {
>                  MR_MemoryList           allocated_memory_cells = NULL;
>                  const MR_DuPtagLayout   *ptag_layout;

Ditto... Getting kinda boring now... All the other labels too!


Otherwise this looks fine, although it is certainly convincing me that
we have way too much code that does RTTI in way too many places!

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list